How to address ALL lights in scene automation

I wish to create (and later call on) a snapshot scene of all my lights as part of an automation (to turn on movie light scene at start of movie and return all lights to their previous state when playback stops).

I know that I can manually create a group, including all lights individually one-by-one, but I imagine that there is a more user-friendly way to do this. As I have about 40 lights, I rather not add them one by one.

The idea (that does not work) is:

service: scene.create
data:
  scene_id: lights_before
  snapshot_entities: all

If there’s no solution from within the automation, is their an easy script to make a group containing all lights?

Put all your lights in a group and then save that? At least that’s doable quickly via the GUI.

service: scene.create
data:
  scene_id: lights_before
  snapshot_entities: "{{ states.light | map(attribute='entity_id') | list }}"
1 Like

That’s neat but it’s every light in the house. If, for example, a bathroom light is off when you create the scene and someone is in the bathroom when the scene is recalled - they are plunged into darkness :rofl:

That’s exactly what jvdburgt requested.

If you or jvdburgt have other requirements, describe them and I can help devise an appropriate template.

Well, if he wants to set all lights like that he will encounter the above issue. Anyway … I’d be interested if you could limit it to an area - is that possible?

{{ area_entities('kitchen') 
  | select('match', 'light')
  | list }}

Reference:
Templating - Areas

2 Likes

Thanks - I will file that away for future use :slight_smile:

Very much appreciated.

Hi,

The request was as intended. Living in a two person household, when we watch a movie, it’s always the two of us. So when movie starts I want the living room set to movie scene, and all other lights in the house off. When movie pauses or is finished, all lights should return to previous state :slight_smile:

If reality turns out to be harsher then I now imagine, I will use the proposed area approach. Many thanks!

1 Like

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.

1 Like

This looked encouraging - but whenever i run it for lights or climate I get the same error

service: scene.create
data:
scene_id: housetest
snapshot_entities: “{{ states.climate | map(attribute=‘entity_id’) | list }}"”

The trace is

Executed: 10 August 2024 at 15:31:19
Error: Entity ID [‘climate.swimming_pool’ is an invalid entity ID for dictionary value @ data[‘snapshot_entities’]
Result:
params:
domain: scene
service: create
service_data:
scene_id: housetest
snapshot_entities: >-
[‘climate.swimming_pool’, ‘climate.lounge_2’, ‘climate.hall’,
‘climate.office_jeremy’, ‘climate.music_room_2’, ‘climate.spare_bedroom’,
‘climate.wc_gf’, ‘climate.prep_kitchen’, ‘climate.harison_bedroom’,
‘climate.harison_shower’, ‘climate.madison_bedroom_2’,
‘climate.madison_shower’, ‘climate.master_bedroom_2’,
‘climate.sky_lounge_2’, ‘climate.gym_2’, ‘climate.jo_office_2’,
‘climate.master_bathroom’, ‘climate.art_room_2’, ‘climate.kitchen_2’,
‘climate.tv_room’, ‘climate.jo_office_shower’, ‘climate.staff_bedroom’,
‘climate.jeremy_bathroom’, ‘climate.jo_bath’, ‘climate.staff_shower’,
‘climate.pool_shower’, ‘climate.pool_bar_2’, ‘climate.master_bedroom’,
‘climate.art_room’, ‘climate.music_room’, ‘climate.guest_bedroom’,
‘climate.lounge’, ‘climate.jo_office’, ‘climate.cinema’,
‘climate.sky_lounge’, ‘climate.above_garage’, ‘climate.kitchen’,
‘climate.pool_bar’, ‘climate.harrison_bedroom’, ‘climate.gym’,
‘climate.jeremy_office’, ‘climate.madison_bedroom’, ‘climate.lounge_neo’,
‘climate.hall_neo’, ‘climate.office_jeremy_neo’, ‘climate.music_room_neo’,
‘climate.spare_bedroom_neo’, ‘climate.wc_gf_neo’,
‘climate.prep_kitchen_neo’, ‘climate.harison_bedroom_neo’,
‘climate.harison_shower_neo’, ‘climate.madison_bedroom_neo’,
‘climate.madison_shower_neo’, ‘climate.master_bedroom_neo’,
‘climate.sky_lounge_neo’, ‘climate.gym_neo’, ‘climate.jo_office_neo’,
‘climate.master_bathroom_neo’, ‘climate.art_room_neo’,
‘climate.kitchen_neo’, ‘climate.tv_room_neo’,
‘climate.jo_office_shower_neo’, ‘climate.staff_bedroom_neo’,
‘climate.jeremy_bathroom_neo’, ‘climate.jo_bath_neo’,
‘climate.staff_shower_neo’]"
target: {}
running_script: false

Change to light and get the same

Executed: 10 August 2024 at 15:25:17
Error: Entity ID [‘light.kitchen_group’ is an invalid entity ID for dictionary value @ data[‘snapshot_entities’]
Result:
params:
domain: scene
service: create
service_data:
scene_id: housetest
snapshot_entities: >-
[‘light.kitchen_group’, ‘light.test’, ‘light.group_cinema’,
‘light.group_lounge’, ‘light.kitchen’, ‘light.group_bedroom’,
‘light.group_hall’, ‘light.group_study’,
‘light.kitchen_unit_lights_group’, ‘light.test_lights_smart’,
‘light.hall_lights_smart’, ‘light.cinema_lights_smart’,
‘light.kitchen_lights_smart’, ‘light.group_switch_lounge_lamp’,
‘light.connectivity_kit_ledbox’, ‘light.connectivity_kit_ledbox_2’,
‘light.connectivity_kit_ledbox_3’, ‘light.kitchen_celing_dining’,
‘light.master_bedroom_room_lamps’, ‘light.kitchen_ceiling_tv’,
‘light.kitchen_wall_dining’, ‘light.pool_ceiling_lights’,
‘light.cinema_wall’, ‘light.hall_wall_gnd’,
‘light.kitchen_ceiling_island’, ‘light.master_bedroom_wall_light’,
‘light.kitchen_wall_tv’, ‘light.hall_stairs_gnd_wall’,
‘light.kitchen_dining_table’, ‘light.hall_first_downlights’,
‘light.master_bedside’, ‘light.kitchen_ceiling’, ‘light.study_wall’,
‘light.cinema_spare’, ‘light.cinema_ceiling’, ‘light.study_ceiling’,
‘light.music_room_ceiling’, ‘light.study_ceiling_rose’,
‘light.music_room_wall’, ‘light.hall_downlight_gnd_corridor’,
‘light.lounge_ceiling2’, ‘light.pool_bar_spot’, ‘light.pool_wall_lights’,
‘light.hall_downlights_gnd_main’, ‘light.hall_first_stair_wall’,
‘light.hall_second_wall’, ‘light.pool_bar_wall’,
‘light.hall_second_downlights’, ‘light.master_lounge_ceiling_rose’,
‘light.master_lounge_wall_light’, ‘light.hall_first_wall_lights’,
‘light.lounge_wall2’, ‘light.hall_chandalier’, ‘light.pool_feature_spot’,
‘light.kitchen_dining_ceiling_rgbw’, ‘light.kitchen_bar_kick_plates’,
‘light.kitchen_lounge_ceiling_rgbw’, ‘light.kitchen_island_rgbw’,

Any idea how to fix it as it is exactly what i am looking for!