add availability topic
This commit is contained in:
parent
a1413281d6
commit
e154723fbe
@ -31,6 +31,7 @@ client = paho.Client(protocol=paho.MQTTv31) # * set a random string (max 23 cha
|
|||||||
temperature_topic = 'weathersensors/' + client_id + '/temperature'
|
temperature_topic = 'weathersensors/' + client_id + '/temperature'
|
||||||
humidity_topic = 'weathersensors/' + client_id + '/humidity'
|
humidity_topic = 'weathersensors/' + client_id + '/humidity'
|
||||||
time_topic = 'weathersensors/' + client_id + '/time'
|
time_topic = 'weathersensors/' + client_id + '/time'
|
||||||
|
availability_topic = 'weathersensors/' + client_id + '/availability'
|
||||||
|
|
||||||
#client connection
|
#client connection
|
||||||
#client.username_pw_set(mqtt_username, mqtt_password) # MQTT server credentials
|
#client.username_pw_set(mqtt_username, mqtt_password) # MQTT server credentials
|
||||||
@ -45,6 +46,7 @@ dt_string = now.strftime("%d-%m-%Y %H:%M:%S")
|
|||||||
print(dt_string)
|
print(dt_string)
|
||||||
# Get Temperature from DHT
|
# Get Temperature from DHT
|
||||||
_, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
|
_, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
|
||||||
|
print("temperature before round: " +str(temperature))
|
||||||
|
|
||||||
temperature = round(float(temperature),2)
|
temperature = round(float(temperature),2)
|
||||||
|
|
||||||
@ -59,3 +61,4 @@ print("humidity after round: " + str(humidity))
|
|||||||
client.publish(temperature_topic, temperature)
|
client.publish(temperature_topic, temperature)
|
||||||
client.publish(humidity_topic, humidity)
|
client.publish(humidity_topic, humidity)
|
||||||
client.publish(time_topic, dt_string)
|
client.publish(time_topic, dt_string)
|
||||||
|
client.publish(availability_topic, "ON")
|
||||||
|
@ -56,3 +56,4 @@ for line in container.split('\n'):
|
|||||||
client.publish(topic + "/battery", "" + battery)
|
client.publish(topic + "/battery", "" + battery)
|
||||||
client.publish(topic + "/temperature", "" + temperature)
|
client.publish(topic + "/temperature", "" + temperature)
|
||||||
client.publish(topic + "/humidity", "" + humidity)
|
client.publish(topic + "/humidity", "" + humidity)
|
||||||
|
client.publish(topic + "/availability", "ON")
|
||||||
|
@ -63,6 +63,7 @@ def write_wallmountedthermostatpro(room,device):
|
|||||||
client.publish(topic + "/actualTemperature", "" + str(actualTemperature))
|
client.publish(topic + "/actualTemperature", "" + str(actualTemperature))
|
||||||
client.publish(topic + "/setPointTemperature", "" + str(setPointTemperature))
|
client.publish(topic + "/setPointTemperature", "" + str(setPointTemperature))
|
||||||
client.publish(topic + "/humidity", "" + str(humidity))
|
client.publish(topic + "/humidity", "" + str(humidity))
|
||||||
|
client.publish(topic + "/availability", "ON")
|
||||||
|
|
||||||
print({"Room":room, "Device Name":device.label, "Last Status Update" : device.lastStatusUpdate, "Actual Temperature":device.actualTemperature, "Set Point Temperature":device.setPointTemperature,"Humidity":device.humidity})
|
print({"Room":room, "Device Name":device.label, "Last Status Update" : device.lastStatusUpdate, "Actual Temperature":device.actualTemperature, "Set Point Temperature":device.setPointTemperature,"Humidity":device.humidity})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user