Browse Source

erweitert um JSON-Output im Format {"temperature":10.4,"humidity":50,"battery":"ok"} auf Topic PREFIX_TOPIC/SENSOR_NAME/json weil ich gedacht habe das für Home Assistant zu benötigen. Wird allerdings jetzt dort eh nicht genutzt ...

FloKra 5 years ago
parent
commit
288257fb9a
1 changed files with 3 additions and 0 deletions
  1. 3 0
      jeelink2mqtt.py

+ 3 - 0
jeelink2mqtt.py

@@ -196,6 +196,9 @@ try:
                     mqttc.publish(mqtt_topic_prefix+"/"+str(currentsensor_name)+"/humidity", str(hum), qos=2, retain=True)
                     mqttc.publish(mqtt_topic_prefix+"/"+str(currentsensor_name)+"/battery", str(batterystate), qos=2, retain=True)
                     
+                    lacrosse_json = "{\"temperature\":" + str(temp) + ", \"humidity\":" + str(hum) + ", \"battery\":\"" + str(batterystate) + "\"}"
+                    mqttc.publish(mqtt_topic_prefix+"/"+str(currentsensor_name)+"/json", lacrosse_json, qos=2, retain=True)
+                    
                     if verbosemode:
                         print "addr: " + str(addr) + " = 0x" + str(addrhex) + "   batt_new: " + str(batt_new) + "   type: " + str(type) + "   batt_low: " + str(batt_low) + "   temp: " + str(temp) + "   hum: " + str(hum) + "   Name: " + str(currentsensor_name)