python-openevse icon indicating copy to clipboard operation
python-openevse copied to clipboard

Many commands don't work

Open stopeject opened this issue 7 years ago • 18 comments

First of all, I'm not a coder, so it could be an user error. I'm trying to write a simple script to set the charge time limit automatically every time the EVSE is charging. I can't get to work some commands:

$ python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import openevse
>>> ev= openevse.WifiOpenEVSE('10.0.0.7')
>>> print ev.version()
{'firmware': '4.8.0', 'protocol': '3.0.1^2E'}
>>> print ev.current_capacity()
32
>>> ev.current_capacity(34)
34
>>> print ev.current_capacity()
34
>>> print ev.status()
sleeping
>>> ev.status('enable')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/gt/.local/lib/python2.7/site-packages/openevse.py", line 238, in status
    raise EvseError
openevse.EvseError
>>> print ev.temperature()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/gt/.local/lib/python2.7/site-packages/openevse.py", line 570, in temperature
    'tmp007temp': float(data[2])/10
>>> print ev.elapsed()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/gt/.local/lib/python2.7/site-packages/openevse.py", line 591, in elapsed
    raise NotCharging
openevse.NotCharging

Please help to figure this out.

stopeject avatar Mar 04 '19 03:03 stopeject

I will check with my evse and will fix if necessary.

vintozver avatar Mar 04 '19 04:03 vintozver

I just noticed this is wifi extension, can you help me providing the command log?

I'm using plain serial connection and don't have this problem.

You may add the print() statements in the _get_response()

I'm particularly interested if the wifi protocol response has any deviations from the plain serial connection.

vintozver avatar Mar 04 '19 04:03 vintozver

I would be happy to help in any way I can, but I will need a bit more hand holding. What exactly should I do? Edit .local/lib/python2.7/site-packages/openevse.py and add something under the _get_response() function?

stopeject avatar Mar 04 '19 04:03 stopeject

If you want to check it out, I can get you remote access.

stopeject avatar Mar 05 '19 04:03 stopeject

I will prepare a couple of curl commands so you will execute them from the console and provide the output. I will be back from an intl trip within a day.

vintozver avatar Mar 05 '19 10:03 vintozver

Any time.

stopeject avatar Mar 07 '19 04:03 stopeject

Please exec a command in the linux console (have curl installed) and provide the command output

curl -vvv "http://10.0.0.7/r?rapi=%24FE"

This command will effectively enable your EVSE

Please also exec

curl -vvv "http://10.0.0.7/r?rapi=%24GV"

and provide its output.

Thank you very much for your assistance.

vintozver avatar Mar 07 '19 19:03 vintozver

curl -vvv "http://10.0.0.7/r?rapi=%24FE"
*   Trying 10.0.0.7...
* TCP_NODELAY set
* Connected to 10.0.0.7 (10.0.0.7) port 80 (#0)
> GET /r?rapi=%24FE HTTP/1.1
> Host: 10.0.0.7
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Length: 519
< Content-Type: text/html
< Access-Control-Allow-Origin: *
< Cache-Control: no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0
< Connection: close
< Accept-Ranges: none
<
<html><font size='20'><font color=006666>Open</font><b>EVSE</b></font><p><b>Open Source Hardware</b><p>RAPI Command Sent<p>Common Commands:<p>Set Current - $SC XX<p>Set Service Level - $SL 1 - $SL 2 - $SL A<p>Get Real-time Current - $GG<p>Get Temperatures - $GP<p><p><form method='get' action='r'><label><b><i>RAPI Command:</b></i></label><input id='rapi' name='rapi' length=32><p><input type='submit'></form>$FE<p>&gt;$OK^20<script type='text/javascript'>document.getElementById('rapi').focus();</script><p></html>

* Closing connection 0

curl -vvv "http://10.0.0.7/r?rapi=%24GV"
*   Trying 10.0.0.7...
* TCP_NODELAY set
* Connected to 10.0.0.7 (10.0.0.7) port 80 (#0)
> GET /r?rapi=%24GV HTTP/1.1
> Host: 10.0.0.7
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Length: 531
< Content-Type: text/html
< Access-Control-Allow-Origin: *
< Cache-Control: no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0
< Connection: close
< Accept-Ranges: none
<
<html><font size='20'><font color=006666>Open</font><b>EVSE</b></font><p><b>Open Source Hardware</b><p>RAPI Command Sent<p>Common Commands:<p>Set Current - $SC XX<p>Set Service Level - $SL 1 - $SL 2 - $SL A<p>Get Real-time Current - $GG<p>Get Temperatures - $GP<p><p><form method='get' action='r'><label><b><i>RAPI Command:</b></i></label><input id='rapi' name='rapi' length=32><p><input type='submit'></form>$GV<p>&gt;$OK 4.8.0 3.0.1^2E<script type='text/javascript'>document.getElementById('rapi').focus();</script><p></html>

* Closing connection 0

By the way, RAPI commands also work without encoding the $- sorry, upon more careful look at the output, the command didn't work.

`

stopeject avatar Mar 07 '19 20:03 stopeject

let me check the regex since there's a mix of html and the actual response.

Thx for bringing this up, really appreciate.

I will follow up within couple days.

vintozver avatar Mar 08 '19 02:03 vintozver

Please check the recent merge by another contributor. If works - we close the issue. Thx.

vintozver avatar Mar 10 '19 08:03 vintozver

I'm afraid I'm not a good tester here because I don't know enough about python. I noticed that latest commit is not on pypi and can't be installed with pip. So I tried to add the new script manually by copying it into /home/user/.local/lib/python2.7/site-packages/ folder. Apparently this is not how it needs to be done because I can't import the module

$python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import openevse
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "openevse.py", line 101, in <module>
    import urllib.request
ImportError: No module named request

stopeject avatar Mar 10 '19 14:03 stopeject

pip3 install git+https://guthub.com/........

vintozver avatar Mar 10 '19 14:03 vintozver

using python2 is discouraged, python2 is no longer supported. use "six" or 3to2 if python2 usage is mandatory for you.

vintozver avatar Mar 10 '19 14:03 vintozver

Thanks, everything worked! I tested all "get" commands, no errors. Changing 'current_capacity' also worked. I haven't tried other "set" commands yet. Thanks again for your help.

I want to ask an unrelated question. I need to check if the EVSE is connected to a vehicle while the charging is not permitted by setting the state to 'sleeping' or 'disable'. I couldn't figure out how to do it except by enabling EVSE for a short duration. But it will cause the contactors in both EVSE and a car to cycle, which is not desirable. Maybe I'm missing something and you know some other way to get that parameter.

stopeject avatar Mar 10 '19 15:03 stopeject

There is a callback function which reports the state change. I'm not sure if pilot is enabled while the EVSE is in disabled state, you can check it with the multimeter or oscilloscope. If pilot is present then it's physically possible.

vintozver avatar Mar 10 '19 15:03 vintozver

I think that the presence of the pilot will direct the car to start charging. There is also a proximity sensor https://openev.freshdesk.com/support/solutions/articles/6000052074-basics-of-sae-j1772, but it seems like its status can't be read with RAPI.

stopeject avatar Mar 10 '19 15:03 stopeject

pilot an and proximity are on the same line, PP evse will energize the circuit when it detects the voltage drop on the pilot (proximity). It's evse's decision to start the charge.

look for callbacks (status changes).

vintozver avatar Mar 10 '19 15:03 vintozver

It looks like Proximity is on a separate wire, but it is not implemented in OpenEVSE. I'll read on callbacks, thanks.

stopeject avatar Mar 10 '19 16:03 stopeject