Browse Source

Added retain=True for homeassistant

Alex Pauly 4 years ago
parent
commit
d91171c0cd
1 changed files with 1 additions and 1 deletions
  1. 1 1
      miflora-mqtt-daemon.py

+ 1 - 1
miflora-mqtt-daemon.py

@@ -438,7 +438,7 @@ while True:
             sleep(0.5) # some slack for the publish roundtrip and callback function
             sleep(0.5) # some slack for the publish roundtrip and callback function
         elif reporting_mode == 'homeassistant-mqtt':
         elif reporting_mode == 'homeassistant-mqtt':
             print_line('Publishing to MQTT topic "{}/sensor/{}/state"'.format(base_topic, flora_name.lower()))
             print_line('Publishing to MQTT topic "{}/sensor/{}/state"'.format(base_topic, flora_name.lower()))
-            mqtt_client.publish('{}/sensor/{}/state'.format(base_topic, flora_name.lower()), json.dumps(data))
+            mqtt_client.publish('{}/sensor/{}/state'.format(base_topic, flora_name.lower()), json.dumps(data), retain=True)
             sleep(0.5) # some slack for the publish roundtrip and callback function
             sleep(0.5) # some slack for the publish roundtrip and callback function
         elif reporting_mode == 'gladys-mqtt':
         elif reporting_mode == 'gladys-mqtt':
             print_line('Publishing to MQTT topic "{}/mqtt:miflora:{}/feature"'.format(base_topic, flora_name.lower()))
             print_line('Publishing to MQTT topic "{}/mqtt:miflora:{}/feature"'.format(base_topic, flora_name.lower()))