not sure if this is the right cat but i could not find any better
so i have made a script that should control an electrical heating panel and report to emoncms.org
i have run the script in a putty session and it seems to work… ie it loops correctly first reading the temp from a ds18b20, then checking if it should target daytime temp or nighttime temp, then figure if relay should be on or off and lastly report to emoncms.org about the status of things (temp read, target temp, relay status, button status)
i have observed that the script do go from daytime to nighttime and back, and that the relay goes on and off if correct temp is reached.
also there’s a button that when pressed do raise the target temp for 15 mins
but for some reason it goes dead on reporting to emoncms, a reboot helps but it just goes dead again after the first reporting to emoncms
I recently made a script for getting emoncms data, rather than posting. I have limited undersatanding of posting but I used the ‘requests’ module as a json tool.
I don’t know if ‘requests’ if available on the pi. I found it very easy to use and might be a simpler starting point.
import requests
incoming_data = requests.get("https://emoncms.org/feed/value.json?id=123456789&apikey=b9033cf185b17e***********b9dca2")
parsed_data = incoming_data.json() # to create printable data
Loops since start 10
Current temp: 22.937
Running Daytime Schedule
We have an internet connection? True
NOT Using Override Temp
Target temp: 22.0
HEATING OFF
ok
Data sent to emoncms
16
first line is a baisc indicator if the script as such is running, it will increment by 1 for each loop, and is loop is 60 sec
the ok just before “Data sent to emoncms” is the response from emoncms.org
16 is the variable for the override temp, when button is pressed this will become 0 and target temp is locked to bake_temp until the variable gets to 15 or above, the variable also increments by 1 for each loop
You can get an ‘OK’ back from an emoncms server even if the data is not valid.
As I said before, you would be best to build the URI string outside the request call so you can actually print out what has been sent. It is likely to be an error in how you are building the string.
I doubt it is emoncms.org if the API call works. You could check and see by printing a debug message just before the HTTP call. If it is the last thing you see, that is the issue. However, it is more likely to be ISP/network issue rather than the emoncms.org server itself. You will need to investigate how to handle a timeout in making the HTTP call.