Automation shut off all switches , help needed

I am trying to create a simple automation to turn off all the lights when all device trackers are “not_home”, but even if one device tracker is not_home the automation executes.

I would appreciate any help with this:

automation:
  alias: Lights Off
  trigger:
    - platform: state
      entity_id: group.all_devices
      to: 'not_home'
  action:
    service: switch.turn_off
    entity_id: group.all_switches

Thanks!

A cleaner way is to use the device_sunlight_trigger…

Putting these four lines in to your configuration.yaml will have the following effects:

  • All lights will switch off when nobody is home.
  • If it is dark and somebody comes home, the light (or group) defined in the light_group line will come on.
  • If somebody is home and it starts to get dark, the light (or group) defined in the light_group line will come on, slowly fading in as the sun goes down
device_sun_light_trigger:
  light_group: [light_or_group_to_switch_on]
  light_profile: relax
  device_group: group.all_devices

No need for an automation unless you want something more complicated, like different lights depending on who comes home etc.

1 Like

Thanks for the tip!

1 Like

only just discovered this, im trying to find info on the light_profiles. Are they also built in, and applicable out of the box, or do we have to create these ourselves?

thx,
marius

Howdy @Mariusthvdb, it looks like from the light component page that there are four light profiles built into Home Assistant, but that you can add additional ones to light_profiles.csv . Follow the link mentioned in the light_profile parameter to see what the existing profiles look like (click on the raw version on github).

wonderful, thanks.

if i were to add profiles, where should this light_profiles.csv file reside? In the /config folder?

That’s my guess too.

Was /config in fact the correct location? I’m trying to determine this as well.