Currently I'm working on a project that reads 5 DS18B20 temperature sensors, connected to the GPIO ports. With the OneWire functionality, the sensors are read correctly and data is being updated. So far, so good
However, the OneWire sensors are only read once a minute, which is not enough for my project requirements (I need it almost continuously for a real-time scenario). So, I created (actually: copy-pasted) python code to read the values from the sensors, which is executed every 5 seconds. Works flawlessly.
Next step is to enhance this python program so that I can:
- send these readings to Domoticz via a JSON command
- send these readings to a local database
- send these reading to a webservice via an API
Currently, I'm stuck with sending the values to Domoticz via JSON. The JSON call works perfectly when I call the whole URL like this:
Code: Select all
curl 'http://IP:PORT/json.htm?type=command¶m=udevice&idx=123&svalue=99'
My python code:
Code: Select all
import requests
import json
url = 'http://192.168.1.2:9096/json.htm'
postdata = {'type':'command', 'param':'udevice','idx':'358','svalue':'66'}
print(postdata)
headers = {'content-type':'application/json'}
response = requests.post(url,data=json.dumps(postdata),headers =headers)
print(requests.post)
print(response)
Again, it works with a direct URL call (with all params in the URL), but since my webservice also works with JSON, I would like to re-use the postdata that I send to Domoticz for the other webservice.
Does anybody have an idea why the values are not updated? What JSON version does Domoticz use? Do I have to give specific headers / postdata?