- alias: 'Turn Party Mode Off'
id: 'Turn Party Mode Off'
initial_state: 'on'
trigger:
platform: state
entity_id: input_boolean.home_mode_party
to: 'off'
action:
service: light.turn_off
entity_id:
- light.buffet
- light.kist
- light.home_theater
which is working fine (though id love to create just one on/off but thats another challenge.
the thing is, this is driving my hassio/Hue integrations into timing issues, since I also have an automation.sense_lights_change that listens to the state of all lights, and runs 2 python scripts when a state-change has been detected.
Id like to disable this automation when party mode is set to On, and re-enable it when party mode is Off again.
Since the party mode automation is triggered as you can see above, it runs each 3 seconds, conditioned by the boolean being on, iâm a bit puzzled how to add the homeassistant.turn_off: automation.sense_lights_change action to it⊠If I simply add it to the list of actions, it would get executed each 3 secondsâŠ
Id need to add the action before the current trigger
What would be the best way of changing this setup, maybe create an intermediary script? boolean flipped, automation_sens_lights flipped, and then party on, an vice versa? would also mean the condition could be taken out here?
If you donât want to go for example the AppDaemon way, then you could try the timer component:
Party_on starts a 3 sec. timer (and disables your other automation). The timer will trigger modification of your lights and restart itself if the party is still running.
Party_off reenables the other automation.
yes, i think thats what i was trying to establish⊠@sebk-666 suggested something very elegant and simple though, which will be quite easy to implementâŠ
thanks all!
Iâm not sure if you were aware that you can specifiy multiple conditions and combine them with and/or clauses (conditions).
So if you already have a condition in you sense_lights_change automation, youâd need to âandâ it with the party mode check condition, e.g.:
condition:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.home_mode_party
state: off
- condition: state
entity_id: ...
state: ...
- condition: ...
sure, i am, cool.
but thanks for making this very clear.
i was wondering if we can write a script with the timing as in the automation above.
that way I would create a switch instead of a boolean, with turn_on and turn_off scripts, one of these containing the timed lights.
Youâre right, thanks for reminding me
I usually explicitely write the and condition clause anyway, because that way I find it easier to read - and while experimenting with clauses you only need to swap the and for an or instead of having to reindent all the code to fit a new clause.
You would have to take the âactionâ part of your old âTurn Party Mode Onâ automation and bind it to the timer.finished event of a new 3-sec timer. Additionally, add timer.start to the actions.
Turn_on would now run timer.start and Turn_off would run timer.cancel.
But eventually youâll end up with the same scenario that you have currently, just a little different behaviour in the background. Iâd go the AppDaemon route and write it down the Pythonic way