update to docker version
This commit is contained in:
parent
d56a0afcf6
commit
646947df31
@ -1,6 +1,7 @@
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
import docker
|
||||
|
||||
# Import MQTT client.
|
||||
import paho.mqtt.publish as publish
|
||||
@ -22,23 +23,19 @@ client = paho.Client(protocol=paho.MQTTv31) # * set a random string (max 23 cha
|
||||
#client.username_pw_set(mqtt_username, mqtt_password) # MQTT server credentials
|
||||
client.connect(mqtt_broker, 1883, 60) # MQTT server address
|
||||
|
||||
#client.loop_start()
|
||||
# -R 42 HIDEKI TS04 Temperature, Humidity, Wind and Rain Sensor (garden sensor)
|
||||
# -R 187 Inkbird ITH-20R temperature humidity sensor (pool sensor)
|
||||
process = os.popen('docker run --device /dev/bus/usb/001/004 rtl_433:inkbird -R 42 -R 187 -F json -T 65 -M time:utc:usec')
|
||||
docker = docker.from_env()
|
||||
|
||||
processData = process.read().split('\n')
|
||||
container = docker.containers.run("rtl_433:inkbird", "-R 42 -R 187 -F json -T 40 -M time:utc:usec", devices={'/dev/bus/usb/001/004:/dev/bus/usb/001/004:rwm'})
|
||||
|
||||
print("processData: ")
|
||||
print(processData)
|
||||
for line in container.split('\n'):
|
||||
|
||||
for i in processData:
|
||||
print("i: ")
|
||||
print(len(i))
|
||||
print(i)
|
||||
print("line: " + line)
|
||||
print("line length: " + str(len(line)))
|
||||
|
||||
if len(i) > 0:
|
||||
jsonData = (json.loads(i))
|
||||
if len(line) > 0:
|
||||
jsonData = (json.loads(line))
|
||||
|
||||
model = str(jsonData['model'])
|
||||
if model == "Hideki-TS04":
|
||||
@ -47,7 +44,11 @@ for i in processData:
|
||||
topic = 'weathersensors/pool'
|
||||
|
||||
time = str(jsonData['time'])
|
||||
battery = str(jsonData['battery_ok'])
|
||||
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'])
|
||||
|
||||
@ -55,5 +56,3 @@ for i in processData:
|
||||
client.publish(topic + "/battery", "" + battery)
|
||||
client.publish(topic + "/temperature", "" + temperature)
|
||||
client.publish(topic + "/humidity", "" + humidity)
|
||||
|
||||
process.close()
|
||||
|
Loading…
Reference in New Issue
Block a user