ok, so I’m not sure if it is a real danger, but got me curious, and I want to ask before I’ll lock my installation in the loop [if it is possible ;)].
imagine a scenario:
input_select with light scenes.
automation triggered by time - at specific time conditions turn on specific scene & set the input_select accordingly [for user’s information etc.]
automation triggered by input_select change, so if I choose a scene by hand - it is turned on.
and now, the question:
is it possible, that when time trigger starts and sets the scene & input_select value (2) the input_select-change trigger will start and will try to set the scene again (3)?
given example is simple 3-point simple situation, but I guess I might encounter more complex, when I’ll start to expand it, that’s why I’m asking at the beginning
hmm, good point!
but I had something similar to that - input_boolean with a “tv mode” setting [this mode dims few bulbs, turns off few leds etc], and noticed that not always switching on this boolean by automation, triggers the action. when I switch it by hand - it works, but when switched via automation’s action - sometimes it fails [don’t know why, no issues in the log, I’ve just made peace with that and didn’t bother but tried not to use this kind of automations].
besides that, I always thought it is better to do something directly - thinking about the shortest way which then minimizes any problems. I guess it doesn’t matter as much if I make the automation that triggers another automation etc.? what’s your experience/thought on that? should I consider making it shorter way, or just chain few automations and don’t overthink?
Well, I don’t use this element much if at all, but the following is my thought:
Either a state change event is generated when an automation sets the input_select value, or it isn’t. Depending on which behavior it is, you know whether to just trigger the change in selection, or to do both actions.
If it sometimes is triggered, that’s a bug that should be reported on github.
thanks for the answer.
…looks like the question which method is better remains open I guess…
and right, if I only notice that I can reproduce the situation when the trigger occurs/don’t start when it should - I’ll report. right now I don’t want to start “well, something somewhere doesn’t work” issue [it is possible that the problem was caused by my installation/config/hardware], but anyway, it is OT right now.
What if you have automation 1 that watches the input_select to trigger the scene (state trigger), and automation 2 that sets the input_select at a specific time? Then the input_select would always reflect the most recent scene selected, but eliminate the risk of the looping. Automation 2 would change the input_select, which automation 1 would notice and set the scene.
Just have the input_boolean have a condition when you turn it on. The condition would check the state of the scene. If the scene is on, don’t turn the scene on. That way, the input_boolean is now on and matches the state without it turning on the scene. If the scene is off, it will turn on the scene.
The only way this boolean will actually turn on the scene is if the scene is off. So if you have an automation that turns on the scene before hand, hitting this switch will do nothing.
but doesn’t that mean, that I’ll need to prepare booleans for all scenes?
maybe I’m wrong with my way of think from the beginning, but I try to minimize unnecessary booleans, switches and all the rest - just to have “clean and simple” configuration files [which are easier to polish/edit later I guess].
anyway - that condition and action combination you wrote, will be helpful in other situation, so thanks nonetheless
I’m going the way @anderson110 and later @Dolores wrote - long story short: when scene is turned on, the input_select will keep active scenes’ name. time-trigerred [not only, but let’s simplify] automation1 won’t turn on the scene - it only sets the option in input_select, and then automation2 [with data_templated action] will set active scene according to input_select’s chosen option - and this automation2 will be triggered by input_select’s change. so now I guess that your conditions are unnecessary? I guess that if input_select current value is “selection1” and trigerred automation1 sets [tries to set] it’s value as “selection1” - it isn’t considered as “value change” so it won’t trigger automation2, right?
about templating in action - is this format: {{ ‘scene.scene2’ }} necessary? or I can write just scene.scene2? [I’m rewriting all automations, so didn’t tested it yet ;)]
I would assume so, but don’t be so sure! You should check the hass.log while in debug and watch the events that appear.
Honestly, I was writing that off the top of my head. {{}} may not be required. I know that they are not needed for integers, floats, strings, and booleans. Now that I think about it, I think you are correct. No quotes, no brackets.
sure will keep my eye on that. if something fails, I’ll add conditions you’ve mention and it should be good
I’m still not-too-fluent in jinja2 templating or yaml itself anyway [right now I think yaml isn’t a best choice], so being correct sounds like a surprise for me
jumping a bit late on the wagon, but if you’re worried that changing the option on your input_select keeps calling the same automation you could always add a condition so the automation doesn’t run if it already ran in the last [say] 5 sec?