This commit is contained in:
Administrator 2021-12-09 18:53:57 +00:00
parent 8cbdca0043
commit c1ed8fdc68

View File

@ -31,29 +31,29 @@ container = docker.containers.run("rtl_433:inkbird", "-R 42 -R 187 -F json -T 40
for line in container.split('\n'):
print("line: " + line)
print("line length: " + str(len(line)))
print("line: " + line)
print("line length: " + str(len(line)))
if len(line) > 0:
jsonData = (json.loads(line))
if len(line) > 0:
jsonData = (json.loads(line))
model = str(jsonData['model'])
if model == "Hideki-TS04":
topic = 'weathersensors/garden'
else:
topic = 'weathersensors/pool'
model = str(jsonData['model'])
if model == "Hideki-TS04":
topic = 'weathersensors/garden'
else:
topic = 'weathersensors/pool'
time = str(jsonData['time'])
if model == "Inkbird ITH-20R":
battery_json_key = "battery"
else:
battery_json_key = "battery_ok"
battery = str(jsonData[battery_json_key])
temperature = str(jsonData['temperature_C'])
humidity = str(jsonData['humidity'])
time = str(jsonData['time'])
if model == "Inkbird ITH-20R":
battery_json_key = "battery"
else:
battery_json_key = "battery_ok"
battery = str(jsonData[battery_json_key])
temperature = str(jsonData['temperature_C'])
humidity = str(jsonData['humidity'])
client.publish(topic + "/time", "" + time)
client.publish(topic + "/battery", "" + battery)
client.publish(topic + "/temperature", "" + temperature)
client.publish(topic + "/humidity", "" + humidity)
client.publish(topic + "/availability", "ON")
client.publish(topic + "/time", "" + time)
client.publish(topic + "/battery", "" + battery)
client.publish(topic + "/temperature", "" + temperature)
client.publish(topic + "/humidity", "" + humidity)
client.publish(topic + "/availability", "ON")