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'): for line in container.split('\n'):
print("line: " + line) print("line: " + line)
print("line length: " + str(len(line))) print("line length: " + str(len(line)))
if len(line) > 0: if len(line) > 0:
jsonData = (json.loads(line)) jsonData = (json.loads(line))
model = str(jsonData['model']) model = str(jsonData['model'])
if model == "Hideki-TS04": if model == "Hideki-TS04":
topic = 'weathersensors/garden' topic = 'weathersensors/garden'
else: else:
topic = 'weathersensors/pool' topic = 'weathersensors/pool'
time = str(jsonData['time']) time = str(jsonData['time'])
if model == "Inkbird ITH-20R": if model == "Inkbird ITH-20R":
battery_json_key = "battery" battery_json_key = "battery"
else: else:
battery_json_key = "battery_ok" battery_json_key = "battery_ok"
battery = str(jsonData[battery_json_key]) battery = str(jsonData[battery_json_key])
temperature = str(jsonData['temperature_C']) temperature = str(jsonData['temperature_C'])
humidity = str(jsonData['humidity']) humidity = str(jsonData['humidity'])
client.publish(topic + "/time", "" + time) client.publish(topic + "/time", "" + time)
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") client.publish(topic + "/availability", "ON")