mk-maddin / wattpilot-HA

This is a custom component to allow control of Fronius Wattpilot wallbox/electro vehicle charging devices in Homeassistant.
Apache License 2.0
59 stars 10 forks source link

Charging status #34

Closed KlausJuhl closed 9 months ago

KlausJuhl commented 9 months ago

Charging status is not shown directly in the integration

In the App you can see when the charging status is stopped:

In the integration the same information is sort of available in the [Wattpilot ChargingReason] = NotChargingBecauseForceStateOff

Requested feature It would be great to have a clear indication of the Charging state, fx. A new sensor fx. [WattpilotChangeState] with values 'On', 'Off'

To Reproduce Steps to reproduce the behavior:

  1. Go to the WattPilot control element
  2. Click on 'Wattpilot Stop Charging'
  3. The Wattpilot CharingReason changes, fx to 'NotChargingBecauseForceStateOff'
  4. Click on 'Wattpilot Start Charging'
  5. The Wattpilot CharingReason changes, fx to 'NotChargingBecauseScheduler'

Version of Home Assistant Core is installed 2023.12.3

Version of Wattpilot integration is installed v0.1.9

Version of Wattpilot 11KW V2 Firmware 40.7

mk-maddin commented 9 months ago

I do not really see a reason why the integration should handle this kind of "logical" decision. From my point of view the task of an integration is to make sure the data from your smart device is available in HomeAssistant with some context what this data is. Within Home Assistant you can then use this data to take logical decision (like charging -> yes / no).

What you are asking is easily achievable with a HA template sensor looking e.g. like this :

template:
  - binary_sensor:
      - name: CurrentlyChargingBinary
        state: >-
          {% set s = states('sensor.wattpilot_chargingreason') %}
          {% if s | regex_match('^NotCharging.*',ignorecase=True) %}False
          {% elif s | regex_match('^Charging.*',ignorecase=True) %}True
          {% else %}Unknown{% endif %}

Alternatively an already available sensor (which btw is used for the visualization in the native app, too) with "less" options is the following: image

If you preferer to use this as source and still want to use a binary_sensor (on/off), a template looks like this:

template:
  - binary_sensor:
      - name: CurrentlyChargingBinary
        state: >-
          {% set s = states('sensor.wattpilot_carstate') %}
          {% if s in [ 'Idle', 'Wait Car', 'Complete', 'Error' ] %}False
          {% elif s in [ 'Charging' ] %}True
          {% else %}Unknown{% endif %}