#Help with Automation not working
1 messages ยท Page 1 of 1 (latest)
Put it in https://dpaste.org/ and share the link
@rich moat
What is the issue with automation?
I would suggest you to ditch the device_id and move to a nice entity_id setups.
The issue is I sometimes have to manually run the reset automation for the night one to work
I did change everything to entity. That was an oops on my part
What is the idea with the template condition to check for exactly 22:00:00?
And what are the automation traces showing? What is preventing the night automation?
the ran today boolean isnt getting reset
So my questions remain valid to answer ๐
I had to check what I see is itโs looking so it wonโt run before 22:00:00 @uneven umbra
Also please tag me so I see it quicker
@mortal path As starter of this thread, don't you just get a notification for every post?
But seems that dpaste isn't working so can't look at the whole yaml. But what I remember you had a check in it for exactly 22:00:00, which is nearly impossible to hit ๐
Something to try split the time condition into two separate conditions.
In mean this:
- condition: template
value_template: "{{ now().strftime('%H:%M:%S') == '22:00:00' }}"
Very hard to hit exactly 22:00:00.
Where
- condition: state
entity_id: sensor.iphone_battery_state
state: Charging
Is always true as that's the trigger ๐
But what does the trace of the "Reset iPhone Charging Flag" say? As it's a pretty straightforward automation...
Yes, that was what I was typing as well, that whole and-condition doesn't make much sense to me
That conditions block of the first automation could just be
conditions:
- condition: state
entity_id: input_boolean.iphone_charging_ran_today
state: "off"
- condition: time
after: "22:00:00"
before: "09:00:00"
note that the time will be logged in microseconds, so 22:00:00.000001 is also after 22:00:00
It's virtually impossible to trigger on exactly 22:00:00.000000 which could maybe the the reason why you added it
I donโt understand that. I am sorry I am new to this
We are saying that this part of your automation doesn't add any value.
- condition: and
conditions:
- condition: template
value_template: "{{ now().strftime('%H:%M:%S') == '22:00:00' }}"
- condition: state
entity_id: sensor.iphone_battery_state
state: Charging
In the first condition you are checking if it's exactly 22:00:00, but that is already covered by the other condition
And if the second part you are checking if the battery state sensor is on Charging , but that is what you are triggering on, so you already know that that is the case
So your whole conditions section can simply be:
conditions:
- condition: state
entity_id: input_boolean.iphone_charging_ran_today
state: "off"
- condition: time
after: "22:00:00"
before: "09:00:00"
oh and you are turning the same lights on twice (light.stick and light.stick_2). First with only a brightness percentage, then also with a color temperature combined with the same brightness percentage
But all of this is not to fix your issue.
What could be the case is that you start charging your phone between 8:00 and 9:00 in the morning.
Your first automation checks on a time period between 22:00 and 9:00
Your second automation resets the boolean at 8:00
So when you charge your phone between 8:00 and 9:00, the first automation kicks in, and the second automation will not reset the boolean before 8:00 next day
so you might want to align those times
Ok here is what I have
alias: iPhone Wireless Charging Triggered
description: Run once per night when iPhone starts charging
triggers:
- entity_id:
- sensor.iphone_battery_state
to: Charging
for:
hours: 0
minutes: 0
seconds: 0
trigger: state
conditions:
- sensor.iphone_battery_state
- condition: state
entity_id: input_boolean.iphone_charging_ran_today
state: "off" - condition: time
after: "22:00:00"
before: "09:00:00"
actions: - target:
entity_id:
- switch.fan
action: switch.turn_on
data: {} - data:
brightness_pct: 100
target:
entity_id:
- light.stick_2
- light.stick
action: light.turn_on - action: light.turn_on
metadata: {}
data:
brightness_pct: 100
color_temp_kelvin: 2605
target:
entity_id:
- light.floor_lamp_pro
- light.living_room_lamp
- light.stick_2
- light.stick
- light.living_room_overhead
- light.living_room_overhead_2 - target:
entity_id: input_boolean.iphone_charging_ran_today
action: input_boolean.turn_on
data: {} - delay: "00:00:05"
- target:
entity_id:
- light.living_room_lamp
- light.floor_lamp_pro
- light.led_magic_light
- light.office_light
- light.office_light_2
- light.lamp
- light.overhead_2
- light.overhead
- light.living_room_overhead
- light.living_room_overhead_2
- light.stick_2
- light.stick
action: light.turn_off
data: {} - action: switch.turn_off
data: {}
target:
entity_id: switch.roses - data:
preset_mode: sleep
target:
entity_id:
- fan.air_purifier
- fan.core_400s
action: fan.set_preset_mode - action: input_number.set_value
metadata: {}
data:
value: 30
target:
entity_id: input_number.projector_off_minutes
mode: single
The stick ones are two different smart bulbs on one lamp
Please use code formatting
To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.
Here is the new automation for the wireless charging: https://dpaste.com/5N6H6W4A2
Reset automation: https://dpaste.com/E88LBN3TU
Okay, and does it work as expected with these automations?
No I still have to run the reset and then the charging one works
So, after 8:00 today, what does the trace of the reset automation show?
And I just tested the automation did not run. Then I manually run the reset one and as soon as I put my phone on the charger it ran
Which automation did not run? That other automation has a condition to make it only run after 22:00.
It's not after 22:00 now
The main one and it was around 2 am
Which timezone are you on?
CST why?