A custom component for Home Assistant which automates your areas.
An area in Home Assistant can represent a room or any other part of your home. Relevant entities and devices can be assigned to these areas; making it possible to create certain kind of automations automatically.
Example setup of areas and entities:
- Living room
- Motion sensor
- Motion sensor 2
- Light
- Light 2
- Light 3
- Bedroom
- Motion sensor
- Light
- Office
- Motion sensor
- Light
- Kitchen
- Motion sensor
- Light
Desired behaviour:
- if there is one or more motion sensors assigned to a room, all of them are used to determine if the room is currently occupied
- the lights in this room should be turned on if presence is detected
- once no presence is detected anymore the lights should turn off again
To achieve this, without this component, it would be necessary to set up automations for all sensors and lights for each of the areas.
🤖 Auto Areas can take over some of this work:
It checks each of your areas for relevant devices and starts managing them automatically. Additionally, it creates a few sensors and switches which allow you to adjust its behaviour as needed.
For the example above the following entities would be created:
As auto-discovery is based on area-related information the requirements for your Home Assistant setup are:
- there is at least one area defined
- it has relevant entities assigned (at least a motion sensor and a light)
For information on how to install this component see Installation.
Tracks the state of multiple sensor entities (for example motion sensors) to detect area presence. It aggregates presence based on these rules:
- An area is considered "occupied" if there is at least one sensor in state
on
(for example motion is detected) - Only if all sensors are
off
the area presence is cleared and the area is considered empty
Currently binary_sensor
entities (with device class: motion
, occupancy
, presence
) are supported.
The presence state is published to a binary_sensor
which will be named according to the area: binary_sensor.area_presence_{area_name}
.
If only relying on motion sensors, presence could be cleared if there is only little or no movement. Presence lock can be used to treat an area as "occupied" regardless of sensor state.
A new switch with ID switch.area_presence_lock_{area_name}
is created for each area. If the switch is on
, lights will not be turned off.
Lights are automatically turned on and off based on presence in an area.
For areas marked as "sleeping area", automatic light control can be temporarily turned off. Lights are never turned on even if presence is detected.
A switch with ID switch.auto_sleep_mode_{area_name}
is created for each sleeping area.
If the switch is turned on
, automatic light control will be disabled and lights will stay off.
For information on how to configure this feature refer to the configuration section.
Install as custom_component for HomeAssistant.
- The recommended installation method is using HACS. Add a new custom repository for
https://github.com/c-st/auto_areas
. Then install it. Alternatively copy the foldercustom_components/auto_areas
to thecustom_components
folder of your Home Assistant installation. - Add an entry in
configuration.yaml
:
auto_areas:
Entities are auto-discovered based on the areas they're assigned to. To customize the behaviour of areas have a look at Configuration.
The behaviour of areas can be customised by adding additional configuration in YAML.
Using the (normalised) name of the area as key, additional options can be enabled. In the following example the area with name bedroom
is marked as sleeping area:
# configuration.yaml
auto_areas:
bedroom:
is_sleeping_area: true
Area option | Description | Default value |
---|---|---|
is_sleeping_area |
Mark area as sleeping area. A switch for controlling sleep mode is created. See more | false (disabled) |
Created entities:
Name | Description |
---|---|
binary_sensor.area_presence_{area_name} |
Indicates whether area is currently considered occupied or not. |
switch.area_presence_lock_{area_name} |
Created for all areas. If enabled, area presence is always on. |
switch.area_sleep_mode_{area_name} |
Only created for sleeping areas. If enabled, light in sleeping areas stays off. |
Install dependencies:
pip install --disable-pip-version-check -r requirements_test.txt
Run tests:
pytest
Using DevContainer is recommended (see config in .devcontainer
).
Auto Areas is inspired by Magic Areas. I created this component to have something more tailored to my use-cases.