HomeAssistant - Turning off the lights when nobody is home
Some notes on Home Assistant groups - ‘people’ groups are apparently now ‘old style groups’ and are legacy, so here is how i figured out to use zones to achieve the same thing. These are useful to create a ‘home’ entity that can be used to turn off lights and smart plugs when everyone leaves the house.
You’ll need to assign each user in your home assistant install a device, so we know their current location. Once this is done, we can create an automation based on the entity of ‘zone.home’. This seems to return an numeric count of the number of people within the zone, so we’ll be leverging this in an automation as follows.
This will run the actions when zome.home = 0 for 3 minutes. In my case, this turns off Hue lights and a couple of smart plugs. It also sends me a mobile alert, but I will likely remove this in a few days once I know it’s working well.
alias: Turn off lights description: Turn off all lights when no-body is home trigger: - platform: state entity_id: - zone.home to: "0" for: hours: 0 minutes: 3 seconds: 0 condition: [] action: - service: light.turn_off data: {} target: area_id: - bedroom - downstairs - stairs - service: notify.mobile_app_iphone data: message: ⚡Turned off all the lights! ⚡ mode: single