Rerun automation till state of entity is zero

Hi,
When our ID3 car is charging I would like to force data refresh every five minutes, till charging is stopped. How should I setup the loop and how to have it stopped at stopping of charging? So far I have setup the following.

alias: ID3 refresh during charging
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.id3_charging_time_left
    above: 0.8
conditions: []
actions:
  - type: turn_on
    device_id: 2833d35fb512de4860f10cc53f9e5e32
    entity_id: 2619c7607d860d9c27583fbcf3339982
    domain: switch
mode: single

Hello Senti79,

First set the trigger to something that will look at the time and trigger every 5 minutes with a time pattern.

Then move the logic you have as a trigger now to the conditions section.

1 Like

Cool! thanks for the quick help!!! changed it now to the following

alias: ID3 refresh during charging
description: ""
triggers:
  - trigger: time_pattern
    minutes: /10
conditions:
  - condition: numeric_state
    entity_id: sensor.id3_charging_time_left
    above: 0.8
actions:
  - type: turn_on
    device_id: 2833d35fb512de4860f10cc53f9e5e32
    entity_id: 2619c7607d860d9c27583fbcf3339982
    domain: switch
mode: single
1 Like

If this suggestion solves your problem, please consider clicking the solution button to close the thread.

You don’t need to force any update. and using a time pattern will not force anything.
What is sensor.id3_charging_time_left? Is that in hours?
The sensors will update when the integration allows it to update, having a time pattern just slows things down.

The suggestion you got will not help you at all

It is minutes. And I found the constant pulling of data causing the 12v battery having issues. Also for 90% of the week we don’t care about the sensors, but especially during charging we like to know how long the charge is taking to know when we can unplug the cable.

What does the switch do?

So when there is more than 0.8 minutes left of charging then it should turn on the switch? That is 48 seconds?
I’m really not following your automation.
This means as soon as you drive out of the garage then this will trigger

No, it will not change the value of that entity untill you start charging. So not when starting to drive it will say to return to full charge it will cost you xx minutes. But when you start charging it will say it will take you xx minutes till you reached your target state of battery.

I think time pattern is a horrible advice.
They run all the time, it’s much better to create the automation to just run when needed.
If you have a time pattern then all the traces will be lost by the time you want to look at them.

here is a suggestion to repeat the turn on (not that this is needed either) but as you requested

alias: ID3 refresh during charging
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.id3_charging_time_left
    above: 0.8
conditions: []
actions:
  - repeat:
      sequence:
        - type: turn_on
          device_id: 2833d35fb512de4860f10cc53f9e5e32
          entity_id: 2619c7607d860d9c27583fbcf3339982
          domain: switch
        - delay:
            hours: 0
            minutes: 1
            seconds: 0
            milliseconds: 0
      while:
        - condition: numeric_state
          entity_id: sensor.id3_charging_time_left
          above: 0
mode: single

But are you sure it’s not supposed to be below 0.8?
You still haven’t answered Troons question what the switch is.
And you should avoid device actions and triggers, use the entity or switch.turn_on.

2 Likes

Thanks, have implemented this now. Much appreciated.