The Ultimate Smart Home Automation Cookbook
Hub Modes are different states your home can be in. These modes can dictate when and how automations run. We will be using them a lot in our automations, so we need to understand how to set them up. Modes are one of the most powerful tools in the smart home.
Automation Details
Required Devices
- Presence Sensors
Triggers:
- Sunrise
- 8am
- Everyone Leaves
- Someone Arrives Home
Actions:
- Change Hub Mode
We will create 4 modes Home, Morning, Night and Away, but you can add as many as you like.
Night is set manually and is part of our Goodnight Routine.
Hubitat
Mode Manager
The Official Documentation for Mode Manager
Setting Up the Automation
First we need to define our modes. Go to Settings/Modes.
Next we need to add the Mode Manager app. Go to Apps then click the Add Built-in App at the top of the screen.
Scroll down and Select Mode Manager.
From the Select Modes to set by time dropdown and select Home and Morning.
For Some reason the table is not populated with the modes we selected. Click the + to add them and set the times. Morning = Sunrise and Home = 8am
Now select Away from the Select Modes to be set by Presence dropdown.
Finally, from the Set Mode with Presence Sensors table click Select Sensors for both Away and returning from away and select your sensors.
Success: The finished automation should look like this. Scroll down to the bottom and select done.
Home Assistant
Home Assistant does not have a built in way to manage hub modes, but we can accomplish this with the use of groups and helpers.
Setting Up the Automation
First we need to create a group of all your presence sensors, this will be the easiest way to detect if someone is home or not. In your configuration files create a new file called groups.yaml and add the code, Be sure to use your sensors entity names.
Then we need to add the groups.yaml to your configuration.yaml.
First, we need to create a group, so go to Settings/Devices & Services/Helpers/Create Helper in the popup window, click Dropdown and here under options we can add our modes.
Next go back to Settings/Automations & Scenes and click Create Automation. Choose Start with an empty automation.
Now we’ll set our Morning mode. The trigger will be sunrise and we’ll set our Mode Helper to Morning.
Next we’ll set our Home mode. The trigger will be 8am and we’ll set our Mode Helper to Home
Next we’ll set our Away mode. The trigger will be When our group Somebody is home, changes from home to not_home and we’ll set our mode to away.
Finally, we need to handle returning from Away. The trigger will be When our group Somebody is home, changes from not_home to home.
For the Action we’ll check to see if it’s after 8am, but before 6am.
Then we will set our Mode to Home.
Else we set Mode to Morning.