However, the toggle only turns ON when I manually turned the light on. Not when I also turn it OFF, change the brightness or the color temperature.
I want to use this helper as a condition in an ‘until loop’ for gradually dimming the lights until the loop is repeated X times (defined by template) or if the toggle helper is turned ON (meaning I manually changed the light state).
What am I missing here?
Your code contains soooo much unnecessary cruft that serves no purpose/doesn’t do anything. Just with some spring cleaning I cut it down from 120 lines to 50ish lines without really changing any of the logic.
What the remaining initial condition (trigger.to_state.context.parent_id is none) is supposed to achieve I really have no idea, so those two lines can probably just as well be deleted too…
Now we can much more easily tell what is going on. Immediate question marks are your conditions of the inner choose. Not sure where you got those conditions from, but in both of them you are attempting to make comparisons against a nonexistent variable include_auto_off.
In the resulting sequence of the first condition (which will never trigger though, as the condition will never evaluate to true) you are then attempting to turn off a switch where the entity id is generated by a template containing another nonexistent variable target_entities_on.
Wow thank you so much.
I copy-pasted most of the script and it’s based on a blueprint. That’s why the unused variables (include_auto_off) are there.
You helped me understand what I’m doing. Thanks a lot!
For completeness sake, here’s my current automation:
alias: ES Manual Control Status Tracker
description: Toggle 'input.boolean' helper when a manual change is made to the lights
triggers:
- trigger: state
entity_id: light.keuken
to: "on"
id: "On"
- trigger: state
entity_id:
- light.keuken
to: "off"
id: "Off"
- trigger: state
entity_id:
- light.keuken
id: Temp
attribute: color_temp_kelvin
- trigger: state
entity_id:
- light.keuken
attribute: brightness
id: Bright
conditions:
- condition: template
value_template: "{{ trigger.to_state.context.parent_id is none }}"
actions:
- if:
- condition: trigger
id:
- "On"
- "Off"
- Temp
- Bright
then:
- action: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.manual_override
Well… though I’m really happy I finally got something to work in HA, it turns out it doesn’t work the way I want it to.
I changed the script above to reset after time has passed (5 seconds currently for testing purposes, but want to change to 10 minutes).
My automations, triggered by time or template, are not generating a parent_id. I’m thinking of using some workaround:
After the loop starts, wait for 2 seconds until the input_boolean.manual_override changes from “off” to “on”.
The state change is to ensure the helper was not on “on” before the condition started, meaning it was manually triggered.
Do you think this should work? Or is there a better way?
You are asking for a solution without describing the problem. An XY problem as many of the regulars here describe it. This particular automation toggles an input_boolean, but you’ve never told us what its purpose is. Describe what your entire set of automations are supposed to accomplish. Also include the code for any other automations intended to work together.
My end goal is to get something like the Adaptive Lighting integration, but multiple time stamps. So it starts 5 minutes before my alarm, gradually changes the lights fom 50% to 85% and 3500K to 5000K in 10 minutes.
Then I want the lights to dim back to 60% and 3500K in 55 minutes.
Then back to 5000K and 80% in 4 hours
Then 3500K and 50% in 4 hours
Then 2800K and 30% in 4 hours
Then 2500K and 10% in 3 hours
Then 2200K and 1% in 1 hour.
It should start at the (approximate) right settings when I get home based on the time (range), and when I manually change the light settings, wait for 20 minutes until I receive a notification on my phone that asks me if I want to resume the light routine.
I want to take this step by step, so I started with a script that gradually turns on the light 5 minues before my alarm and stops after 10 mintes: