Home Assistant - How to automatically turn off a socket when nobody's home
Emiliano Guerzoni
Project Manager / Technical Manager renewables/energy efficiency projects | Demand Manager digital energy domain at algoWatt
Hi guys,
In this article we saw how to automatically set a switch state based on presence at home so that your defined switch will appear as follows on the Home Assistant user interface:
When someone is at home
When nobody's at home
Scenario
You need to automatically turn off a critical socket as soon as nobody is at home.
Home Assistant can automatically do this for us, let see how.
What you need in terms of hardware
领英推荐
Software configuration
family
? entities:
? ? - person.A
? ? - person.B
- person.C:
Home Assistant code (yaml) / steps
This is the piece of code -?Automation?- you have to write:
alias: Switch - Turn off your socket if nobody's home
description: Switch - Turn off your socket if nobody's home
trigger:
? - platform: state
? ? entity_id: group.family
? ? from: home
? ? to: not_home
? ? for: "00:00:30"
condition:
? - condition: state
? ? entity_id: switch.your_switch
? ? state: "on"
action:
? - type: turn_off
? ? device_id: xxxxxx
? ? entity_id: switch.your_switch
? ? domain: switch
mode: single
Some specifics about the code above
Thank you for reading. ?? I hope you have enjoyed this article.
I'm available for any feedback so, feel free to contact me or share your thoughts in the comments section below.
Your feedbacks will be very appreciated!
Meanwhile,?if you liked this article share it or?subscribe?to my newsletter?about?Home Assistant?to read all previous episodes and still up to date on latest news.