All off when go to sleep

I want to make something that by means of a button card I can switch off all defined devices that are also on at the same time. This is useful if, for example, I go to bed and then don’t forget anything to turn it off :wink:

For example, I have the following entities:

       - light.garage_links
       - light.porch_left
       - light.porch_right
       - light.table_left
       - light.table_right
       - light.standing_lamp
       - light.table_tv_livingroom
       - light.hue_lightstrip_plus_kitchen
       - light.hue_lightstrip_plus
       - light.shed
       - media_player.marantz_nr1604

And if possible change the state of my climate to sleep
something with this:

entity_id: climate.toon_thermostat
hvac_mode: sleep

When I press the button, everything that is on must go out (So pressing the button again may not do anything because then everything is turned off by the first press)

There is probably someone who has also come up with something for his devices at home, I would like to hear how I can do this best and if possible with a few examples.

Create a script. Turn off all the entities in the script. Call the script from the button.

here’s a script I use that turns devices I want off, delays 30 seconds then switches off the lights (to give me time to get out of the room):

  - service: remote.send_command #TV Off
      entity_id: remote.lounge_tv
      command: "OFF"
  - service: media_player.turn_off
    entity_id: media_player.lounge_av_rx
  - service: media_player.turn_off
    entity_id: media_player.lounge_av_rx_zone_2
  - service: input_select.select_option #AirCon Off
      entity_id: input_select.lounge_ac_mode
      option: "Off"
  - delay: 00:00:30
  - service: switch.turn_off
    entity_id: switch.pc_monitor
  - service: light.turn_off
    entity_id: light.lifx_front_porch
  - service: switch.turn_off
    entity_id: switch.led_table
  - condition: state
    entity_id: group.most_lights
    state: 'on'
  - service: light.turn_off
      entity_id: "{{ states | selectattr('entity_id', 'in', state_attr('group.most_lights', 'entity_id')) | selectattr('state', 'equalto', 'on') | map(attribute='entity_id') | join(', ')}}"  # comma separated list of entities that are currently turned on

Love that description :rofl:

1 Like

I have a group all_lights as well but when I go to bed I want to exclude the bedside lights from being turned off and likewise when I go out, the front porch light should remain on. So most_lights is everything minus those three and I add them if needed.


Thanks , this is working for me !

1 Like