Hi, I get negative power values from my EmonTx because I have a PV system connected to phase L1. In order to make that work with the python script for the Jeelink receiver from https://github.com/emoncms/development/blob/master/Tutorials/Python/PyLink/pylink.py
I had to change the line:
... value = int(values[i]) + int(values[i+1])*256 if value>32768: value -= -65536 datacsv.append(str(value)) ...
to:
if value>32768: value -= 65536
BR, Jörg.
Re: [SOLVED] Bug in python receive script for Jeelink?
Thanks, it;s been fixed https://github.com/emoncms/development/commit/e17dbab6a3d87bb8b68a62522616e52bf6e3e7e8
Re: [SOLVED] Bug in python receive script for Jeelink?
As I don't know anything about Python at all, I have a question regarding this script (might be slightly off-topic).
I saw that the script stopped this night with an error message. How can the script be made to recover automatically from such a fault (restart)?
Re: [SOLVED] Bug in python receive script for Jeelink?
Depends on the error message.
Best would be to identify what causes it and add an exception to generate a warning and go on processing.
Not difficult to achieve in python, the difficulty may lie in the rootcausing.
Re: [SOLVED] Bug in python receive script for Jeelink?
Jerome,
hope you can give me a hint. The error message created is always due to Emoncms not responding to a GET request:
Traceback (most recent call last): File "C:\Python27\Jeelink", line 56, in <module> conn.request("GET", "/"+emoncmspath+"/input/post.json?apikey="+apikey+"&"+req) File "C:\Python27\lib\httplib.py", line 973, in request self._send_request(method, url, body, headers) File "C:\Python27\lib\httplib.py", line 1007, in _send_request self.endheaders(body) File "C:\Python27\lib\httplib.py", line 969, in endheaders self._send_output(message_body) File "C:\Python27\lib\httplib.py", line 829, in _send_output self.send(msg) File "C:\Python27\lib\httplib.py", line 791, in send self.connect() File "C:\Python27\lib\httplib.py", line 772, in connect self.timeout, self.source_address) File "C:\Python27\lib\socket.py", line 571, in create_connection raise err error: [Errno 10061] Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerteI have no experience with Python, but have now done the following:
try: conn.request("GET", "/"+emoncmspath+"/input/post.json?apikey="+apikey+"&"+req) #response = conn.getresponse() #print response.read() except: print "Emoncms server not available!"It seems to work (script not stopping with the above error any more), but I would like to know how this could be improved. Or is it ok to do it like this?
BR, Jörg.
Re: [SOLVED] Bug in python receive script for Jeelink?
What you're doing seems fine.
I'd to it like this:
try: conn.request("GET", "/"+emoncmspath+"/input/post.json?apikey="+apikey+"&"+req) response = conn.getresponse() except: print "Emoncms server not available!" else: print response.read()Perhaps could you consider using the python OEM Gateway if you want to do this kind of things. It is supposed to be more featured. And it can resend data when server is unreachable.
Re: [SOLVED] Bug in python receive script for Jeelink?
Jérôme,
Thank you very much for your comment. Since using my modified script, it works flawlessly. But I will change it to your proposal and have a look into the OEM Gateway next.
BR, Jörg.
Re: [SOLVED] Bug in python receive script for Jeelink?
You don't have to change it, the only difference is that you commented the lines providing the feedback from Emoncms. But since this feedback is printed into nothing, commenting that is fine.