Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating EV SOC (State of Charge) data: OVMS #7

Closed
glynhudson opened this issue Mar 13, 2019 · 4 comments
Closed

Integrating EV SOC (State of Charge) data: OVMS #7

glynhudson opened this issue Mar 13, 2019 · 4 comments

Comments

@glynhudson
Copy link
Member

glynhudson commented Mar 13, 2019

For demandshaper to be useful for EV charge scheduling the demand shaper ideally needs to know the current SOC (state of charge of an EV). Unfortunately it's not possible to obtain SOC data via the J1772 EV charging protocol.

Various EV's have different proprietary API's retrieve SOC. The API's are often unpublished and reverse engineered. We will try and add support for all EV's (starting the Tesla). However, as a first implementation we have tested integrating with OVMS (Open vehicle Monitoring system). OVMS is an open-source hardware/software telematics platform that supports many types of EV's and is totally independent to the manufacturer.

See OVMS user guide

Data can be retrieved from OVMS via their mobile app, MQTT or HTTP rest API (if using dexters-web OVMS server, default in Europe). See issue openvehicles/Open-Vehicle-Monitoring-System-3#178

Here is an example API call to retrieve OVMS data:

https://dexters-web.de/api/call?fn.name=ovms/export&fn.vehicleid=XXXXXX&fn.carpass=XXXXX&fn.format=csv&fn.types=D,S&fn.last=1
Example responce:

#FILE,d.csv
rec_time,0,doors1,doors2,lockunlock,tpem,tmotor,tbattery,trip,odometer,speed,parktimer,ambient,doors3,staletemps,staleambient,vehicle12v,doors4,vehicle12v_ref,doors5,tcharger,vehicle12v_current
2019-03-13 17:44:08,0,192,0,5,11,0,12,0,434390,0,0,11,0,1,1,14.41,0,12.6,0,0,0,18
#FILE,s.csv
rec_time,0,soc,units,linevoltage,chargecurrent,chargestate,chargemode,idealrange,estimatedrange,chargelimit,chargeduration,chargeb4,chargekwh,chargesubstate,chargestateN,chargemodeN,chargetimer,chargestarttime,chargetimerstale,cac100,charge_etr_full,charge_etr_limit,charge_limit_range,charge_limit_soc,cooldown_active,cooldown_tbattery,cooldown_timelimit,charge_estimate,charge_etr_range,charge_etr_soc,idealrange_max,chargetype,chargepower,battvoltage,soh
2019-03-13 17:44:08,0,28.0,M,0,0,stopped,standard,24,0,0,0,0,0,13,21,0,0,0,0,57.22,0,0,0,0,-1,0,0,0,0,0,0,0,0.00,368.50,86
rec_time 0 soc units linevoltage chargecurrent chargestate chargemode idealrange estimatedrange chargelimit chargeduration chargeb4 chargekwh chargesubstate chargestateN chargemodeN chargetimer chargestarttime chargetimerstale cac100 charge_etr_full charge_etr_limit charge_limit_range charge_limit_soc cooldown_active cooldown_tbattery cooldown_timelimit charge_estimate charge_etr_range charge_etr_soc idealrange_max chargetype chargepower battvoltage soh
17:44:08 0 28.0 M 0 0 stopped standard 24 0 0 0 0 0 13 21 0 0 0 0 57.22 0 0 0 0 -1 0 0 0 0 0 0 0 0.00 368.50 86
rec_time 0 doors1 doors2 lockunlock tpem tmotor tbattery trip odometer speed parktimer ambient doors3 staletemps staleambient vehicle12v doors4 vehicle12v_ref doors5 tcharger vehicle12v_current
2019-03-13 17:44:08 0 192 0 5 11 0 12 0 434390 0 0 11 0 1 1 14.41 0 12.6 0 0 0 18
@TrystanLea
Copy link
Member

Example code to request and parse data to json

<?php

$vehicleID = "";
$carpass = "";

$csv_str = file_get_contents("https://dexters-web.de/api/call?fn.name=ovms/export&fn.vehicleid=$vehicleID&fn.carpass=$carpass&fn.format=csv&fn.types=D,S&fn.last=1");
$csv_lines = explode("\n",$csv_str);

$headings1 = explode(",",$csv_lines[1]);
$data1 = explode(",",$csv_lines[2]);

$headings2 = explode(",",$csv_lines[4]);
$data2 = explode(",",$csv_lines[5]);

$data = array();

for ($i=0; $i<count($headings1); $i++) {
    if (is_numeric($data1[$i])) $data1[$i] *= 1;
    $data[$headings1[$i]] = $data1[$i];
}

for ($i=0; $i<count($headings2); $i++) {
    if (is_numeric($data2[$i])) $data2[$i] *= 1;
    $data[$headings2[$i]] = $data2[$i];
}

print json_encode($data,JSON_PRETTY_PRINT);

@glynhudson glynhudson changed the title Integrating OVMS SOC data Integrating EV SOC (State of Charge) data: OVMS Mar 13, 2019
@glynhudson
Copy link
Member Author

Implemented in 234b38d

@glynhudson
Copy link
Member Author

c860c41cc5774f4c0b89b3ed98d409314157b17b

@KommyKT
Copy link

KommyKT commented Sep 8, 2019

I insatlled emoncms on rpi4 and now in daemondshaper get the following error:
EmonCMS Error

Message: Error: Syntax error, unrecognized expression: .input[name=batterycapacity
Route: Lib/jquery-1.11.3.min.js
Line: 2
Column: 12802
Error: {"line":2,"column":12757,"sourceURL":"http://192.168.1.253/Lib/jquery-1.11.3.min.js"}

How can i add batterycapacity input. i have a OVMS in my car. Now set dexters webpage for V2 server and Server v3 to rpy via mqtt on OVMS .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants