@@ -40,33 +40,40 @@ def connected(client):
4040 # Subscribe to changes on a feed named DemoFeed.
4141 client .subscribe ("DemoFeed" )
4242
43+
4344def subscribe (client , userdata , topic , granted_qos ):
4445 # This method is called when the client subscribes to a new feed.
45- print ('Subscribed to {0} with QOS level {1}' .format (topic , granted_qos ))
46+ print ("Subscribed to {0} with QOS level {1}" .format (topic , granted_qos ))
47+
4648
4749def unsubscribe (client , userdata , topic , pid ):
4850 # This method is called when the client unsubscribes from a feed.
49- print ('Unsubscribed from {0} with PID {1}' .format (topic , pid ))
51+ print ("Unsubscribed from {0} with PID {1}" .format (topic , pid ))
52+
5053
5154# pylint: disable=unused-argument
5255def disconnected (client ):
5356 # Disconnected function will be called when the client disconnects.
5457 print ("Disconnected from Adafruit IO!" )
5558
59+
5660# pylint: disable=unused-argument
5761def message (client , feed_id , payload ):
5862 # Message function will be called when a subscribed feed has a new value.
5963 # The feed_id parameter identifies the feed, and the payload parameter has
6064 # the new value.
6165 print ("Feed {0} received new value: {1}" .format (feed_id , payload ))
6266
67+
6368# Initialize MQTT interface with the ethernet interface
6469MQTT .set_socket (socket , eth )
6570
6671# Initialize a new MQTT Client object
67- mqtt_client = MQTT .MQTT (broker = "http://io.adafruit.com" ,
68- username = secrets ["aio_user" ],
69- password = secrets ["aio_key" ])
72+ mqtt_client = MQTT .MQTT (
73+ broker = "http://io.adafruit.com" ,
74+ username = secrets ["aio_user" ],
75+ password = secrets ["aio_key" ],
76+ )
7077
7178# Initialize an Adafruit IO MQTT Client
7279io = IO_MQTT (mqtt_client )
0 commit comments