psa_car_controller
psa_car_controller copied to clipboard
Import trip data and charge data to Home Assisstant
Hi, I would like to import the data of the charging sessions and trips, I have installed both influx and grafana but I cannot read the data I have installed everything as a Home Assistant addon
**Environment **
- OS: HassOS
- Peugeot e208
Additional context
Hi lucasimons,
did you enable the external port? To open them in influx/grafana.
If you want transfer data from other source like manual installation to HASS it is quite complicated, because you need to replace the .db file to get those data in HASS.
I have enabled the port in fact I can see the data but I don't know how to import the trip and charge data inside Home Assistant as sensors . I wanted to create a sensor that counted how many kWh I lcharged and how many kilometers I did, for example, monthly or daily
Ok~ you can use node red to import the data for example. This is what I do, it is more flexible then the other options like creating sensors in config
thats what i have create for me:
Did you manage to read the charge data via node red? For example, how much energy did you charge in the last session? Could I share the nodes?
Good point, no that's nothing I test so far, since i just use this API: /get_vehicleinfo/ to read those data you see.
Here is my NodeRedFlow: flows.zip
About calculating charge value for charge session, I think you can do it like this: Check when Charge start + current SOC and check charge end then calculate the value between soc start+end. or flobz need to create an api which provide those data as well.
thanks
this is what I would like to do...
https://grafana.szambetti.it/d/CPrt7kvnk/e208?orgId=1&kiosk=tv
@flobz is it possible with psa car controller installed as addon?
You can analyse the panels, as far as I can see they do some SQL query's to get the data.
SELECT
strftime('%Y-%m-%dT%H:%M:%S', start_at) || "Z00:00" AS start_time,
COUNT(*) AS times,
SUM((end_level - start_level) * .42) AS kwh_charged,
SUM(((end_level - start_level) * .42) / ((strftime('%s', stop_at) - strftime('%s', start_at)) / 3600.0000))
COUNT(*) AS average_kw
FROM
battery
WHERE
((end_level - start_level) * .42) /((strftime('%s', stop_at) - strftime('%s', start_at)) / 3600.0000) < 22
Many things you might be able to do with NodRed as well, but you may need a database to store the values. But this is a different approach.
Notice: 42 seems not correct because battery has 46kWh (for Corsa-E) instead of 42kWh
It is a different approach in fact I wanted to know if it was possible to do the same thing through the addon, surely the data is in a db but I don't know how to extrapolate the data
Btw. why not follow this: https://github.com/flobz/psa_car_controller/issues/161 Since it is just another install way
Because I have only a rpi with HassOS installed and I works fine, I doesn't have a Linux system to use this method...
the problem is you don't have telegraf which seems to be essential for data transfer.
For me i have it done by rednode+mysql:
But it seems telegraf exist for Hass: https://community.home-assistant.io/t/telegraf-addon-for-hassio-glances-alternative/144662
Hello again,
I have test it with: HassOS I have installed:
- PSA 3.0.3
- InfluxDB (https://addons.community)
- Telegraf (https://github.com/Sabuto/hassio-repo)
- Grafana (https://addons.community)
After install everything you need to change the configs:
InfluxDB:
auth: false
certfile: fullchain.pem
envvars:
- name: INFLUXDB_HTTP_LOG_ENABLED
value: 'true'
keyfile: privkey.pem
reporting: true
ssl: true
log_level: info
Telegraf:
custom_conf:
enabled: true
location: /config/telegraf.conf
Rest of this config can be ignored
After this open [File Editor] or [VSCode] and create the telegraf.conf in conf folder. (like mentioned in Grafana Guide)
After this step you can Start InfluxDB + Telegraf + Grafana.
Everytime you need to wait till everything loads complete (first time it take a while).
Now open Grafana and use instead of localhost the fqdn of you device like: http://homeassistant.fritz.box:8086
And now you can create panels like in your example:
custom_conf: enabled: true location: /config/telegraf.conf
Can you import the trip / charge session to influx?