#Run scene EXCEPT some entities

1 messages · Page 1 of 1 (latest)

upper blaze
#

As title says - I have scenes which run automatically but want some entities to not be included under some conditions.

An example is my Goodnight automation which turns off all the lights in the house at 01:00, but I want it so that if my PC is still on (using my sensor) to turn them all off except the lights in my office.

I know I can apply the scene manually but that means I have to update it as I add devices which I want to avoid doing so that it stays organised - I'd rather it references it from the same source. Is there any way I can go about it without having it just turn the light back on again a few seconds later?

jovial frigate
#

Scenes don't have that kind of logic

#

You could split the office lights into a separate scene and conditionally execute that

grand tiger
#

This is the sort of thing I just wouldn't use a scene for - they are not good at dynamic behaviour
Instead I would use a template to generate the list of lights to turn off and then call light.turn_off directly - you could do this with a label for all your lights, or just start with states.light to get the full list of entities
For defining override switches for certain lights, you can either hardcode it into the template, or do something more dynamic by defining labels pairing lights with the sensor you want to control if the automation runs
Example for something hardcoded:

{% set all_lights_on = states.light | selectattr("state","eq","on") | map(attribute='entity_id') | list %}
{% set light_overrides = {'light.bedroom': states('binary_sensor.pc_on') | bool(false), 'light.living_room': states('binary_sensor.tv_on')} %}
{% set lights_overridden = light_overrides | items | selectattr(1, 'true') | map(attributes=0) | list %}
{% set lights_to_turn_off = all_lights_on | reject('in', lights_overridden) | list %}
upper blaze
#

Hiya, apologies I completely forgot that I had posted this question!

upper blaze