May 2020
Intermediate to advanced
262 pages
6h 48m
English
The HeaterStatus class imports the built-in MQTTClient class and uses it to set up a client in the update() method:
def update(self, status): client = MQTTClient(client_id="gateway", server="<<CloudMQTT server>>", user="<<CloudMQTT username>>", password="<<CloudMQTT password>>", port=<<CloudMQTT port number>>) client.connect() client.publish("heater_enabled",status)
The MQTTClient object, client, is created with values from our CloudMQTT account. Its connect() method is called and a message is published using the publish() method. In this case, a heater_enabled message along with the status is passed into the update() method.
With the LoRaMessage and HeaterStatus classes created, it becomes very simple for the main.py file to ...
Read now
Unlock full access