diff --git a/mqtt_publish_temp.py b/mqtt_publish_temp.py index a54432b..08c12d2 100644 --- a/mqtt_publish_temp.py +++ b/mqtt_publish_temp.py @@ -31,6 +31,7 @@ client = paho.Client(protocol=paho.MQTTv31) # * set a random string (max 23 cha temperature_topic = 'weathersensors/' + client_id + '/temperature' humidity_topic = 'weathersensors/' + client_id + '/humidity' time_topic = 'weathersensors/' + client_id + '/time' +availability_topic = 'weathersensors/' + client_id + '/availability' #client connection #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) # Get Temperature from DHT _, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN) +print("temperature before round: " +str(temperature)) temperature = round(float(temperature),2) @@ -58,4 +60,5 @@ print("humidity after round: " + str(humidity)) # Publish our data client.publish(temperature_topic, temperature) client.publish(humidity_topic, humidity) -client.publish(time_topic, dt_string) \ No newline at end of file +client.publish(time_topic, dt_string) +client.publish(availability_topic, "ON") diff --git a/readBresserTempSensor.py b/readBresserTempSensor.py index 45ab9f7..6aa7a5c 100755 --- a/readBresserTempSensor.py +++ b/readBresserTempSensor.py @@ -56,3 +56,4 @@ for line in container.split('\n'): client.publish(topic + "/battery", "" + battery) client.publish(topic + "/temperature", "" + temperature) client.publish(topic + "/humidity", "" + humidity) + client.publish(topic + "/availability", "ON") diff --git a/readHomematicIP.py b/readHomematicIP.py index 05d898f..baa7032 100755 --- a/readHomematicIP.py +++ b/readHomematicIP.py @@ -63,6 +63,7 @@ def write_wallmountedthermostatpro(room,device): client.publish(topic + "/actualTemperature", "" + str(actualTemperature)) client.publish(topic + "/setPointTemperature", "" + str(setPointTemperature)) 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}) @@ -82,4 +83,4 @@ def main(): write_wallmountedthermostatpro(group.label,device) if __name__ == "__main__": - main() \ No newline at end of file + main()