I'm trying to config my ESP8266 running Micropython, to notify "last-will", as shown below and according to developer as noted on github.
still- I get no notification when I disconnect my ESP8266, other command and notification work as needed.
Guy
def startMQTTclient(self):
self.mqtt_client = MQTTClient(self.mqtt_client_id, self.server, self.qos, user=self.user,
password=self.password)
self.mqtt_client.set_callback(self.on_message)
self.mqtt_client.set_last_will(topic=self.topic2, msg="last_will")
try:
self.mqtt_client.connect()
for topic in self.topic1:
self.mqtt_client.subscribe(topic)
print("Connected to MQTT server")
return 1
except OSError:
self.notify_error("Error connecting MQTT broker")
return 0