@@ -59,11 +59,13 @@ def connected(client):
59
59
client .subscribe ("DemoFeed" )
60
60
61
61
62
+ # pylint: disable=unused-argument
62
63
def subscribe (client , userdata , topic , granted_qos ):
63
64
# This method is called when the client subscribes to a new feed.
64
65
print ("Subscribed to {0} with QOS level {1}" .format (topic , granted_qos ))
65
66
66
67
68
+ # pylint: disable=unused-argument
67
69
def unsubscribe (client , userdata , topic , pid ):
68
70
# This method is called when the client unsubscribes from a feed.
69
71
print ("Unsubscribed from {0} with PID {1}" .format (topic , pid ))
@@ -75,6 +77,15 @@ def disconnected(client):
75
77
print ("Disconnected from Adafruit IO!" )
76
78
77
79
80
+ # pylint: disable=unused-argument
81
+ def publish (client , userdata , topic , pid ):
82
+ # This method is called when the client publishes data to a feed.
83
+ print ("Published to {0} with PID {1}" .format (topic , pid ))
84
+ if userdata is not None :
85
+ print ("Published User data: " ,end = "" )
86
+ print (userdata )
87
+
88
+
78
89
# pylint: disable=unused-argument
79
90
def message (client , feed_id , payload ):
80
91
# Message function will be called when a subscribed feed has a new value.
@@ -104,6 +115,7 @@ def message(client, feed_id, payload):
104
115
io .on_subscribe = subscribe
105
116
io .on_unsubscribe = unsubscribe
106
117
io .on_message = message
118
+ io .on_publish = publish
107
119
108
120
# Connect to Adafruit IO
109
121
print ("Connecting to Adafruit IO..." )
0 commit comments