Skip to content

Commit 959dcf1

Browse files
committed
eschava#78 Add retain flag option to last will and birth messages
1 parent 710332d commit 959dcf1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mqtt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def on_message(client, device, msg):
216216
# noinspection PyUnusedLocal
217217
def on_connect(client, device, flags, result_code):
218218
if cf.get('mqtt_birth_payload', False):
219-
mqttc.publish(cf.get('mqtt_birth_topic', 'clients/broadlink'), payload=cf.get('mqtt_birth_payload'), qos=0, retain=False)
219+
mqttc.publish(cf.get('mqtt_birth_topic', 'clients/broadlink'), payload=cf.get('mqtt_birth_payload'), qos=0, retain=True)
220220

221221
topic = topic_prefix + '#'
222222
logging.debug("Connected to MQTT broker, subscribing to topic " + topic)
@@ -588,7 +588,7 @@ def run(self):
588588
mqttc.on_disconnect = on_disconnect
589589

590590
if cf.get('mqtt_will_payload', False):
591-
mqttc.will_set(cf.get('mqtt_will_topic', 'clients/broadlink'), payload=cf.get('mqtt_will_payload'), qos=0, retain=False)
591+
mqttc.will_set(cf.get('mqtt_will_topic', 'clients/broadlink'), payload=cf.get('mqtt_will_payload'), qos=0, retain=True)
592592

593593
# Delays will be: 3, 6, 12, 24, 30, 30, ...
594594
# mqttc.reconnect_delay_set(delay=3, delay_max=30, exponential_backoff=True)

0 commit comments

Comments
 (0)