Closed haraldpaulsen closed 2 years ago
I assume you have a Citigo then? IIRC this is available for Enyaq that use a newer API but not for older cars. It could be done but there's one major difficulty and that is determining what's the capacity of the given vehicle. For some, at least my Superb iV, the charging current gradually drops as the charge increase. So no matter how I implement this it will always be a guesstimate that you might as well create yourself with a template sensor. I'll see if I can make an example at least on how to accomplish this.
Correct, 2020 Citigo IV.
Yes, I saw it was available for Enyaq and that made me think of the option of calculating it. I looked at the data available now and max capacity was not one of them (yet) so it would have to be an option in the integration to specify this.
And yes, the current drops towards the end, naturally. Would still be interesting to be able to have a "charging curve". From home assistant it looks like the car is updating the battery charge every 30 minutes when the battery is at < 90%, and this increases to every 5 minute as the battery is at 90-100%. So I also know that it wouldn't be instant. But it would still be interesting to see how close to the theoretical 7kW slow charging and 50kW rapid charging one can get.
Thank you for the tip about template sensor, this might be just what I need! I'll do some reading about it.
I think I'm on to something... (but it doesn't appear to round it)
template:
- sensor:
- name: "Charge speed guesstimate"
state: >
{% set maxcharge = 36800 %}
{% set percentleft = 100 - states('sensor.oda_battery_level') | float %}
{% set hoursleft = states('sensor.oda_charging_time_left').split(':')[0] | int %}
{% set minutesleft = states('sensor.oda_charging_time_left').split(':')[1] | int %}
{% set totalminutesleft = hoursleft*60 + minutesleft %}
{% set chargeleft = maxcharge * percentleft / 100 | float %}
{% set chargespeed = chargeleft / (totalminutesleft / 60) | float %}
{{ chargespeed / 1000 | round}}
unit_of_measurement: "kW"
I get a value that is supposedly charging speed in kW.
Stuck this in a gauge:
type: gauge
entity: sensor.charge_speed_guesstimate
min: 0
max: 50
needle: true
Might need some failsafe checking when it is not charging or otherwise should be 0.
Looking forward to some input from the rest of the community
After some experimenting I've come up with some small changes.
template:
- sensor:
- name: "Charge speed guesstimate"
state: >
{% if is_state('switch.oda_charging', 'on') %}
{% set maxcharge = 36800 %}
{% set percentleft = 100 - states('sensor.oda_battery_level') | int %}
{% set hoursleft = states('sensor.oda_charging_time_left').split(':')[0] | int %}
{% set minutesleft = states('sensor.oda_charging_time_left').split(':')[1] | int %}
{% set totalminutesleft = hoursleft*60 + minutesleft %}
{% set chargeleft = maxcharge * percentleft / 100 %}
{% set chargespeed = chargeleft / (totalminutesleft / 60) %}
{{ (chargespeed / 1000) | round(1) }}
{% else %}
0
{% endif %}
unit_of_measurement: "kW"
state_class: measurement
The interim variables can of course be eliminated, but as a way to track how I thought my way to the answer it's a good point in having them there..
After some experimenting I've come up with some small changes.
- If the car is not charging we should display 0 (if we don't, the sensor is just listed as unavailable, probably because division by 0 or something)
- correct usage of round, to round to 1 decimal.
- remove unneeded "float"
template: - sensor: - name: "Charge speed guesstimate" state: > {% if is_state('switch.oda_charging', 'on') %} {% set maxcharge = 36800 %} {% set percentleft = 100 - states('sensor.oda_battery_level') | int %} {% set hoursleft = states('sensor.oda_charging_time_left').split(':')[0] | int %} {% set minutesleft = states('sensor.oda_charging_time_left').split(':')[1] | int %} {% set totalminutesleft = hoursleft*60 + minutesleft %} {% set chargeleft = maxcharge * percentleft / 100 %} {% set chargespeed = chargeleft / (totalminutesleft / 60) %} {{ (chargespeed / 1000) | round(1) }} {% else %} 0 {% endif %} unit_of_measurement: "kW" state_class: measurement
The interim variables can of course be eliminated, but as a way to track how I thought my way to the answer it's a good point in having them there..
Looks good! I will give it a try as well and if OK with you I'll add it to README?
Looks good! I will give it a try as well and if OK with you I'll add it to README?
Sure thing! And thank you for the tip about the template sensor. I'm a new home assistant user (but have been running fibaro and doing programming for years), so I have much to learn.
Unfortunately python is not my forte, or I would be able to contribute more.
Added to readme, thanks for your work!
One thing I have been missing in the official skoda app is the ability to see the current effect/charging speed. We did have a timer for "time until fully charged", and I can see that we now also has this sensor in Home Assistant.
However, would it be possible to calculate a "current charging speed", if one is not provided by the car, based on "time left", "battery level" and "max capacity"?
For instance, currently my battery level is at 98% and it is estimated 15 minutes left, and max capacity for battery is a theoretical 36.8.kWh
Some back-of-the-envelope-calculation would therefore mean:
Having this in a sensor would not (for me) be beneficial in home automation, but having it in lovelace would make me able to see how much of the theoretical 50kW charging-speed I get.
sensor.$carname_charging_speed_estimate?