One of the first things I did when starting up with Home Assistant was to create a solution for different house modes.
Basically I wanted to be able to put the house in different modes, and these modes should be a huge part of how we automate our house. For example how should our automations work when leaving the house or being away, and what about at night when we are sleeping?
I also chose to limit the amount of modes, so it wouldn’t be difficult to understand each. We ended up with four modes:
- Home-mode
This mode is used when at least one person is at home. - Away-mode
This mode is set when nobody is at home. - Night-mode
This mode is used when we go to bed, but we are at home. - Guest-mode
This mode is used when we have guests in our home.
The thought is that when the last person leaves the house the house mode should switch directly to Away-mode, and when the house is in Away-mode and a person enters, it should switch directly to Home-mode. We have kids, so of course I also wanted to be able to overwrite the “automatically switch to away-mode” when the grown ups leave the house… you know, so the babysitter shouldn’t sit in the dark 😉
So how did I accomplish the house mode functionality?
Prerequisites
To get the full picture of this blog post, I recommend you to read the following blog posts before starting:
1. Creating helpers
Helpers are a bit like variabels in programming language, or even better, like data saved in a database. In this case I use them to store the current state of the house mode and if it should disable the auto away-mode. The state of each helper will be remember between restarts of Home Assistant.
I started by creating two helpers through the GUI in Home Assistant:
- House Mode
Helper Type: Dropdown
Icon: mdi:home-circle-outline (but you can set the icon as you want)
Options: Home, Away, Night & Guest
Afterwards I clicked on the created helper and set the Entity ID to: input_select.housemode - Disable Auto Away-mode
Helper Type: Toggle
Icon: mdi:cloud-off-outline
Afterwards I clicked on the created helper and set the Entity ID to: input_boolean.housemode_disable_auto_away_mode
You don’t need to change the Entity ID for the two helpers. I do it so it’s easy in Visual Studio Code to access the helpers, because they are related to the functionality (housemode).
2. Creating buttons in Lovelace
In my Lovelace view I always focus on making it easy to use with touch on our phones or on our tablets. Therefore I added 4 buttons in a grid with 2 columns. This way it’s easy to select each house mode from our devices. My idea was to make it look like this:

There are two ways of creating the buttons in Lovelace depending on your requirements of the look and feel.
2.1 The Standard Way
You can do it through 100 % standard Home Assistant components. In this case you create a Grid Card with 2 columns and add 4 buttons. These buttons I created with these properties:
Home
- Name: Home
- Icon: mdi:home
- Tap Action: Call Service
- Service: input_select.select_option
- Target: Entity input_select.housemode
- Option: Home
Night
- Name: Night
- Icon: mdi:weather-night
- Tap Action: Call Service
- Service: input_select.select_option
- Target: Entity input_select.housemode
- Option: Night
Away
- Name: Away
- Icon: mdi:home-export-outline
- Tap Action: Call Service
- Service: input_select.select_option
- Target: Entity input_select.housemode
- Option: Away
Guest
- Name: Guest
- Icon: mdi:party-popper
- Tap Action: Call Service
- Service: input_select.select_option
- Target: Entity input_select.housemode
- Option: Guest
It will work without problems, but I would have liked to be able to see which button is the current state. That is not possible with this method.
2.2 Using a custom”Button Card”
I have HACS installed (which I would recommend everyone to have). Through HACS I found and installed a custom button card. This card gives much more control of the button card, including the possibility of showing the state.
The GitHub repository for this button card is located here: GitHub – custom-cards/button-card
For each state I created a button – like mentioned in 2.1 – but based on this new custom card. There is no GUI setup of this card, so it needs to be done by YAML for each button. Below is an example on how I did it for the Home button.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
type: custom:button-card tap_action: action: call-service service: input_select.select_option service_data: entity_id: input_select.housemode option: Home entity: input_select.housemode icon: mdi:home name: Home color: var(--paper-item-icon-color) state: - value: Home color: var(--paper-item-icon-active-color) |
This way the button will have the Active-state color as all other buttons/entities have in Lovelace. This solution is what I ended up with, because showing the state was and still is important for me.
3. Creating house mode automations
The main purpose of the house mode functionality is to automate different flows based on the state. I also wanted the house mode to update the state automatically based on specific scenarios, for example the last person leaving the house, or the first person coming home.
I therefore setup the following simple scenarios:
- Home-mode
When the first person in a group of persons comes home, I want the house mode to be set to Home. - Away-mode
When the last person in a group of persons leaves home, I want the house mode to be set to Away. - Night-mode
We set this manually when we go to sleep at night. - Guest-mode
We set this manually when we have guests visiting us.
We use the Companion App (iOS Home Assistant app) and have it installed on our phones. We also granted permission to track our whereabouts and report back to Home Assistant. I therefore added our mobile phones to a group, so I could have a state on the group if someone is at home or if we’re “not at home”. Below you can see the YAML code for my group.
File: src/groups/phones.yaml:
1 2 3 4 5 |
phones: name: Phones entities: - device_tracker.k_iphone - device_tracker.m_iphone |
Afterwards I created two automations – one for setting the house mode automatically to Home and one for setting the house mode automatically to Away. I don’t do anything else in these two automations.
I instead want separate the automations that triggers on state changes to the house mode, because I then will then use the same automation regardless if the state is changed based on the automatically update or the manual update. This removes double code/configuration in YAML.
Part of file: src/automations/housemode-home.yaml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
- id: e4e48f25-139c-4d53-b054-635f74b8397f alias: "House mode: Set to Home when first person arrives" trigger: - platform: state entity_id: group.phones from: not_home to: home condition: - condition: state entity_id: input_select.housemode state: Away action: - service: input_select.select_option data: entity_id: input_select.housemode option: Home |
Part of file: src/automations/housemode-away.yaml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
- id: 6b72a5ac-9ab2-4d72-ab5a-b2109f66d21d alias: "House mode: Set to Away when last person leaves" trigger: - platform: state entity_id: group.phones from: home to: not_home condition: - condition: state entity_id: input_boolean.housemode_disable_auto_awaymode state: off action: - service: input_select.select_option data: entity_id: input_select.housemode option: Away |
Notice that I in the automation for setting the state to Away automatically also have a condition to check if that trigger is actually disabled based on the state of input_boolean.housemode_disable_auto_awaymode.
Afterwards I created two automations for when the house mode state is set for either Home or Away. When going into Home mode, I want the entrance light to turn on, and when going into Away mode I want all lights turn off.
Part of file: src/automations/housemode-home.yaml:
1 2 3 4 5 6 7 8 9 |
- id: 3f6baab2-9dbf-4c47-ad58-e8829616cf15 alias: "House mode: Home state set" trigger: platform: state entity_id: input_select.housemode to: Home action: - service: light.turn_on entity_id: light.entrance_ceiling |
Part of file: src/automations/housemode-away.yaml:
1 2 3 4 5 6 7 8 9 |
- id: 8009b93e-2c39-4c8d-8347-3ccff7681a54 alias: "House mode: Away state set" trigger: platform: state entity_id: input_select.housemode to: Away action: - service: light.turn_off entity_id: all |
Of course I also created automations to trigger when the state is set for Night and Guest mode, but above YAML configuration is shown as examples.
4. Using the house mode in other automations
In all other automations that you build, you can chose to use a specific state of the house mode as a condition too. This could for example be to disable motion triggers if the house mode is in Night mode.
You can do it by adding the following condition to your automation:
1 2 3 4 |
condition: - condition: state entity_id: input_select.housemode state: Night |
Examples of usage
Here are some examples on what we use the house mode functionality to do:
- When we are leaving our home our vacuum robots starts a cleaning job (but only once a day).
- When we arrive home and our vacuum robots are doing a cleaning job, they are send home to their base.
- When in Night state we have perimeter protection in our house, activating voice on a Sonos speaker and sending us a notification on the mobile app if it registers any breach.
- When in Away state we have perimeter protection in our house, sending us a notification on the mobile app if it registers any breach.
- Selected lights are turned on when we are on Guest mode. It’s LED lights around the house we normally don’t use in our every day.
I hope this guide / walk-through is useable for you. We use the house mode in almost everything we do, and we are so happy about the functionality surrounding it.
How do you trigger it to go from Night mode to Home mode in the morning?
Hi Taylor,
I just have a simple automation that triggers at a specific time in the morning, setting the housemode to Home, if one of us is home.
Hi,
I’m new to Home Assistant, migrating from a Vera Plus. I used the House Modes in Vera, and I’ve been searching for something like this. I’ve got as far as creating the button cards, but I’m already getting stuck with the groups. I tried going into helpers to create a group with for my users/iPhones, but I don’t see anything in there that will work. Additionally, I tried inserting your group code into my configuration.yaml file, and it’s throwing errors at me. I’m not getting how the !include works, because every attempt, I get a invalid config error.
Any advice?
Hi Tim,
1. Create a file called /config/groups.yaml and add the phone’s code as per the instructions above.
2. Go to /config/configurations.yaml file, and add the following line:
group: !include groups.yaml
Alternatively, skip step 1 and add the phone’s code directly into the configurations.yaml
3. Go to Developer Tools and check the configuration.
4. RESTART
It should work. Mine did.
Hi Tim,
I think it would be a good idea for you to read my post here, since this is the way I’m working with splitting up my configuration in multiple files:
https://kef.dev/split-your-configuration-up-in-multiple-files/
Furthermore creating a group can be done multiple ways, including via the user interface. You can have a look here:
https://www.home-assistant.io/integrations/group/
Best regards,
Kristian
Hi Kef and Taylor, what I used to do with hubitat and am now in the process of implementing with HA for the transition from night to home is: in the morning (anytime after 5am), as soon as someone turns on a light in the main living space, a condition checks time and home status and if status is night and time is after 5 am, the automation will switch mode to home. This permits us to sleep in… If no one touched a switch, it will automatically change to home at 2 hours past sunrise (same time some lights turn off)