i am using a "particulate matter" software from here : https://zefanjas.de/wie-man-feinstaub-m ... ssen-kann/.
I want to send the PM2.5 data to a dummy (custom sensor).
I know that the PM2.5 value is in the 'values[0]' variable, but i don't know how to update my custom sensor in domoticz.
Maybe someone can help me a bit with this problem.
Thanks in advance.
Here is the code
Code: Select all
if __name__ == "__main__":
while True:
cmd_set_sleep(0)
cmd_set_mode(1);
for t in range(15):
values = cmd_query_data();
if values is not None:
print("PM 2.5: ", values[0], ", PM10: ", values[1]) ######## Here is the Values[0] ###################
time.sleep(2)
# open stored data
with open('/var/www/html/aqi.json') as json_data:
data = json.load(json_data)
# check if length is more than 100 and delete first element
if len(data) > 100:
data.pop(0)
# append new values
data.append({'pm25': values[0], 'pm10': values[1], 'time': time.strftime("%d.%m.%Y %H:%M:%S")})
# save it
with open('/var/www/html/aqi.json', 'w') as outfile:
json.dump(data, outfile)
urllib.urlopen('http://192.168.178.83:8080/json.htm?type=command¶m=udevice&idx=1&nvalue=0&svalue= (values[0])')
####### Here i want to update my custom sensor ############
print("Going to sleep for 5min...")
cmd_set_mode(0);
cmd_set_sleep()
time.sleep(300)