Help with condition for Automation

Hi there,

I want to implement an automation to controll the charging of an EV.
The EV does not provide a setting for the max. SoC of the battery… so it will always charge to 100%…

my automation should stop charging, when the SoC reached a configured percentage.
This percentage will be defined within an input_number helper.

So basically, the automation should be like:

if device.Wallbox is charging
conditions:
if selected vehicle is A
AND
SOC is Above state(‘input_number.A_charge_limitation’)

how could this be done?
I can’t use the value of a sensor / helper in the ABOVE setting of the device / entity I am using to get the current SoC of the vehicle.

What does the automation do? I’d have thought you want one automation to turn charging on, and one to turn it off.

Sounds like you’re thinking of an automation as something that is continually running whilst the charger is active — that’s not a good way to build them. Think of them as triggering off an event happening, evaluating some conditions, doing something then finishing.

Trigger on SoC going over your threshold value, check the wall charger is charging that vehicle, turn charger off.

Something like this, with entity IDs invented as you haven’t supplied them:

alias: Turn charger off at SoC threshold
triggers:
  - trigger: numeric_state
    entity_id: sensor.car_a_soc
    above: input_number.soc_limit
conditions:
  - condition: state
    entity_id: binary_sensor.wallbox_charging
    state: 'on'
  - condition: state
    entity_id: sensor.charging_car
    state: "A"   
actions:
  - action: switch.turn_off
    target:
     entity_id: switch.charger

Yes you can, if you use an entity numeric state condition rather than a device one.

1 Like

I’ll try it with an entity based one.

The charging will start automatically, but it should stop, when the ev soc reached the value defined in the helper.

Unfortunately, the Integration / Car does not provide this by default, so I wanted to build that around the given options.

helper “input_number.ev_soc_limitation” => f.e. 80%
if the wallbox is charing, check if current SoC is below the value of the helper.
If current SoC is equal (or higher) than the value of the helper, set the wallbox to “stop”

– Current Automation configuration:

alias: Stop charging Car_A
description: >-
  stop charging based on current SoC compared with settings.
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.car_battery_level
    above: input_number.charge_limitation
conditions:
  - condition: and
    conditions:
      - condition: device
        device_id: wallbox_id
        domain: select
        entity_id: wallbox_entity_1_id
        type: selected_option
        option: car_A
      - type: is_charging
        condition: device
        device_id: wallbox_id
        entity_id: wallbox_entity_2_id
        domain: binary_sensor
actions:
  - device_id: wallbox_id
    domain: select
    entity_id: wallbox_entity_3_id
    type: select_option
    option: Stop
  - action: notify.mobile_app
    metadata: {}
    data:
      message: >-
        Chaging stopped. SoC is now {{trigger.to_state}}.
      title: Stop Charging car_A
mode: single

1 Like