My automation doesn't work - I have no idea why

Heyey

I wrote an autonation that should charge my car (it is called Ingeborg), when I plug it to the wallbox.
When the battery is at 20 percent loading should stop.
For starting and stopping the charging process i wrote two scripts (because I use PV surplus to charge). But those two scripts work 100%.

The automation should not run if its not a workday, and it also shouldnt run if I set the created input boolean to false.
If the car is plugged it should start loading if

  • the battery is below 20% and
  • it hasnt charged this day (for this I created a boolean helper and turn it on, when charging has finished. It goes false every night at 00:05 am.

when my cars battery is over 19% charging should stop.

My automation runs, but nothing is executed. I have no idea why.

alias: Ingeborg Zwangsladen
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.go_echarger_car
    from: "off"
    to: "on"
    id: Auto verbunden
  - trigger: numeric_state
    entity_id:
      - sensor.ingeborg_verbleibende_batterie_in_prozent
    above: 19
    id: Auto geladen
conditions:
  - condition: state
    entity_id: input_boolean.ingeborg_morgens_zwangsladen
    state: "on"
  - condition: state
    entity_id: binary_sensor.workday_sensor
    state: "on"
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Auto verbunden
          - condition: state
            entity_id: input_boolean.ingeborg_wurde_zwangsgeladen
            state: "off"
          - condition: numeric_state
            entity_id: sensor.ingeborg_verbleibende_batterie_in_prozent
            below: 20
        sequence:
          - action: input_boolean.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.ingeborg_wurde_zwangsgeladen
          - action: script.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: script.wallbox_volle_leistung
      - conditions:
          - condition: trigger
            id:
              - Auto geladen
        sequence:
          - action: automation.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: automation.pvwallbox
mode: single

For me it looks like the automation is cancelled at the first option blog.
But I really dont know what ive done wrong.
It looks like all the conditions are true.
For example today the boolean was false and my battery was at 5%. So it should have turned the car loading on, but as you see in the screenshot, nothing happened.

Because of one or more of these:

          - condition: state
            entity_id: input_boolean.ingeborg_wurde_zwangsgeladen
            state: "off"
          - condition: numeric_state
            entity_id: sensor.ingeborg_verbleibende_batterie_in_prozent
            below: 20

Ah damn it. I think I got it.
When I checked why my automation doesnt run, the states were perfecltx fine and it should have charged. But this was always about 10 minutes after plugging the car.
It looks like my car does not report battery state while driving.
So if I leave home with 60% battery and go to work the battery state does not change.
After turning the car off it takes about (atleast it was like that today) 7 minutes untill the new battery state is reported to home assistant.
So while firering the event my battery state was at 60%.
So it didnt start the charging procedure.

Ill analyze the time it takes until new states are reported (think its not always the same time) and change the automations trigger according to that:
e.g. if car is connect for 10 minutes …

Hi Florian Vieten,

It appears that the first choose statement can never happen…
Conditions are and by default, so it cannot be both off and on.

they’re not the same booleans?

and

Ye sorry.
Next time i better translate my german variable names into english.
Those are two different booleans.
The on in the generall condition block is for “turning this automation on and off”.
So if I dont want the automation to charge my car till 20% i turn this off via button on my dashboard.
The second (within the Option 1) gets true, when the car has charged until 20% and false at nignht at 00:05 am to ensure this runs only once a day.
So you could call the both boolean: “ChargeTheCarEveryMorning” and “CarHasCharged”.

But I found the issue after reading @Hellis81 post.
When turning off my car (what happens about 10 seconds before plugging the cable) it takes about 7 minutes until it reports the new battery state.
So i dont use the “wallbox car connected” entity, but my cars “connected” entity.
Here it also takes some until the state is resported (and I wait another minute to ensure).
In addition to this I use the wallbox’s connected as a condition to not start this automation if my car is connected to another wallbox.

No its fine, I was replying to Sir Goodenough who figured those Booleans where the same