skodaconnect / homeassistant-skodaconnect

Skoda Connect - A home assistant plugin to add integration with your car
Apache License 2.0
233 stars 27 forks source link

Update to documentation for charge speed guestimate. #278

Closed tanathka closed 6 months ago

tanathka commented 7 months ago

Please search issues in https://github.com/skodaconnect/skodaconnect and https://github.com/skodaconnect/homeassistant-skodaconnect for duplicates or fixes before reporting a new issue.

Somewhere along the way the timeleft got changed to minutes and the entering the battery capacity in watts seems a little redundant. I may have put too many '| int' in there as well. Not perfect code but it works as of April 2024.4.4 release.


template:
  - sensor:
    - name: "Charge speed guesstimate"
      state: >
        {% if is_state('switch.skoda_<name>_charging', 'on') %}
          {% set battery_capacity = <battery-size-in-kwh> | int %}
          {% set charge = { "remaining": states('sensor.skoda_<name>_minimum_charge_level') | int - states('sensor.skoda_<name>_battery_level') | int } %}
          {% set timeleft = states('sensor.skoda_<name>_charging_time_left') | int %}
          {% set chargeleft = battery_capacity * charge.remaining / 100  %}
          {% set chargespeed = chargeleft / (timeleft / 60) %}
          {{ chargespeed | round (1) }}
        {% else %}
          0
        {% endif %}
      unit_of_measurement: "kW"
      state_class: measurement