Script to send data to Domoticz
Posted: Tuesday 07 July 2020 14:54
Hi,
I got some temp/hum sensors type LYWSD03MMC. So I found a script (https://github.com/JsBergbau/MiTemperature2) to poll them and another to pass the values to Domoticz's virtual device. The script to pass the values is this:
The problem is that it doesn't update anything on Domoticz. The JSON URL does the job well manually but in the script, it doesn't. Can you suggest what is wrong here?
I got some temp/hum sensors type LYWSD03MMC. So I found a script (https://github.com/JsBergbau/MiTemperature2) to poll them and another to pass the values to Domoticz's virtual device. The script to pass the values is this:
Code: Select all
#!/usr/bin/python3
import os
import re
import requests
import time
import sys
domoticzserver = "127.0.0.1"
idx_temp = "57"
#Cuisine
val_temp = sys.argv[3] # change to sys.argv[5] for calibrated
val_hum = sys.argv[4]
val_bat = sys.argv[6]
val_comfort = "0"
if float(val_hum) < 40:
val_comfort = "2"
elif float(val_hum) <= 70:
val_comfort = "1"
elif float(val_hum) > 70:
val_comfort = "3"
res = requests.get(
"http://"
+ domoticzserver
+ "/json.htm?type=command¶m=udevice&idx="
+ idx_temp
+ "&nvalue=0&svalue="
+ val_temp
+ ";"
+ val_hum
+ ";"
+ val_comfort
+ "&battery="
+ val_bat
)