miniconfig / python-openevse-wifi Goto Github PK
View Code? Open in Web Editor NEWA python library for communicating with the ESP8266-based wifi module from OpenEVSE
License: MIT License
A python library for communicating with the ESP8266-based wifi module from OpenEVSE
License: MIT License
I'm working on an updated Home Assistant integration. Per OpenEVSE docs the HTTP API is now the recommended way to send commands to OpenEVSE, so this may require significant changes to this library as it currently uses RAPI.
I wanted to check in if you prefer I make a PR to this library, or create a new library?
I am running Openevse 2.9.1 and the authentication is not working.
When I clear the username/password on the openevse wifi module, then the library works but once it's enabled, it always failed. It appears that the openevse uses a different way to authenticate (I checked my dev tools in the browser and it looks like it only sends the username and an additional exchange using nonce).
Also noticed that when the charger is in Sleep mode (sending $FS, not $FD) it returns an unexpected "status" namely "fe" which is not in your list of options.
I'm trying to get this working with Home Assistant https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/sensor/openevse.py and it is failing.
I think it is because the newer (2.7.5) WiFi firmware requires login.
I tried setting the host to user:passwd@hostname
but this doesn't seem to parse. I tried several other permutations like user:passwd@hostname:80
user:passwd@hostip:80
etc, but none seem to work with urllib on Python 3.6.
Any advice? Any chance of getting explicit basic auth support?
Thank you!
self._state = float(self.charger.getUsageTotal()) / 1000
File "~/.homeassistant/deps/lib/python3.5/site-packages/openevsewifi/__init__.py", line 279, in getUsageTotal
usage = self.sendCommand(command)
File "~/.homeassistant/deps/lib/python3.5/site-packages/openevsewifi/__init__.py", line 37, in sendCommand
return response.group(1).split()
AttributeError: 'NoneType' object has no attribute 'group'
I tried to manually query the EVSE like this:
data = urllib.request.urlopen(c.url + urllib.parse.urlencode({'json':1, 'rapi': '$GS'}))
>>> data.read().decode('utf-8')
'{"cmd":"$GS","ret":"$OK 2 2793^1D"}'
And it looked like the ^1D was confusing the regex.
I found that the javascript in the openevse wifi uses the following regex. "self.regex = /$([^\^]*)(^..)?/;"
https://github.com/OpenEVSE/ESP8266_WiFi_v2.x/blob/master/src/html/openevse.js#L70
Which splits the ^hex code into another group.
When I tried to modify openevsewifi I'd found the json argument and used that to simplify parsing which looked like this:
def sendCommand(self, command):
"""Sends a command through the web interface of the charger and parses the response"""
data = { 'json': 1, 'rapi' : command }
full_url = self.url + urllib.parse.urlencode(data)
data = urllib.request.urlopen(full_url)
data = json.loads(data.read().decode('utf-8'))
match = re.search('\$([^\^]*)(\^..)?', data['ret'])
if match is None:#If we are using version 1 - https://github.com/OpenEVSE/ESP8266_WiFi_v1.x/blob/master/OpenEVSE_RAPI_WiFi_ESP8266.ino#L357
response = re.search('\>\>\$(.+)\<p>', data.read().decode('utf-8'))
return response.group(1).split()
But I'm not sure how far back the json parameter is supported so I don't know if it'll break with earlier firmwares.
There are some methods which claim to return an int but return strings instead, and there are other places where a float is returned, unless something is unset, in which case 0 is returned as an int.
As mentioned in #7 , this project needs to implement better error handling and reporting
Hello,
Regarding this issue - https://github.com/home-assistant/home-assistant/issues/12954
This seems to be fixed in the supporting library, https://github.com/miniconfig/python-openevse-wifi/pull/1 ... so I humbly ask for a new PyPI release. (I hope somebody knows what this means
'cause I don't!) When that is released, as I understand, the Home Assistant manifest must be updated to actually start using it. And how that happens, once again, I dunno, but I have it on good authority that's what will start to get this fixed.
Thanks everybody, this is a fantastic project, I realize you're all probably even more busy than me.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.