I have integrated my solar inverter and have for example the when set to when the battery percentage drops below a certain level it will charge.
If I just have the when and then do set it works but I would like to set the and if to check if the time is above 23:30 for example but when I set that the automation doesn’t run.
Thank you, I now have the trigger checking for any state or attribute changes to the battery and then have the condition set for the time and below a certain percentage.
One thing I have now come across is it now wants to constantly run even if the conditions have been met and the actions ran.
Is there a way to stop it running once the conditions have been met and the action has run. I only want to stop it until the following day.
This is an edited version but the same automation.
As you can see I have the battery sensor set to trigger on any state change, then the condition to check its after 23.30 and the battery percentage is below 12%.
I know the way I have it setup it will constantly trigger which is what I want but the way I would like it to work is that once the conditions are met and the actions have run it doesn’t then run again until the next day.
Hope that makes sense.
alias: 4. Charge Solar Battery after 23:30pm
description: ""
trigger:
- platform: state
entity_id:
- sensor.lux_battery
condition:
- condition: time
after: "23:30:00"
weekday:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
- condition: numeric_state
entity_id: sensor.lux_battery
below: 12
action:
- type: turn_off
device_id: ad77094e2a4ab2ea42d2651055d5de64
entity_id: 85a40bdd5831db74670dfb73d5ed6300
domain: switch
- device_id: ad77094e2a4ab2ea42d2651055d5de64
domain: number
entity_id: 2058baf222419feb3d11ce006b4b68e6
type: set_value
value: 100
- type: turn_on
device_id: ad77094e2a4ab2ea42d2651055d5de64
entity_id: 9fc721d2c3ef5eb78702bb2fb8223b6d
domain: switch
- service: notify.mobile_app_jamie_s_iphone
metadata: {}
data:
message: Please check the Lux app.
title: Solar Battery now Charging
mode: single
alias: Test 4. Charge Solar Battery after 23:30pm
description: ""
trigger:
- platform: state
entity_id:
- sensor.lux_battery
condition:
- condition: time
after: "23:30:00"
- condition: numeric_state
entity_id: sensor.lux_battery
below: 12
- condition: template
value_template: >
{{ (this.attributes.last_triggered | as_local).date() != now().date() if this.attributes.last_triggered is defined else true }}
action:
- device_id: ........
Because you used device_id my editor mangled it… So I’m cutting off to just the condition part which is the key aspect…
It looks at the last triggered date and today’s date and says they must be different dates
your approach of doing a delay (or do a wait for midnight) would also work. However there’s no need to wait for 23 hours. Just wait for 30 minutes. Once it’s past midnight your condition of 23:30 takes over
Your way does have the vulnerability that if there is a restart before midnight it doesn’t resume so it will trigger again.
I think I have mine right, but I am on mobile and did not test it…
I would use a toggle helper for this. In your script, you toggle the helper on indicating it’s run for the day and have that toggle as part of your conditions (if toggle is false and other conditions pass, run the actions, toggle the toggle and then further executions of the automation would not pass).
Then, I would reset the toggle daily at 23:15 via a “reset” automation.
Template condition… 100%.
@armedad FTW! I completely forgot about the template condition… Nicely done!!!