c-st / auto_areas

πŸ€– A custom component for Home Assistant which automates your areas.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ€– Auto Areas

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 (Area)
  - Motion sensor
  - Motion sensor 2
  - Illuminance sensor
  - Light
  - Light 2
  - Light 3
- Bedroom (Area)
  - Motion sensor
  - Illuminance sensor
  - Light
- Office (Area)
  - Motion sensor
  - Light
- Kitchen (Area)
  - 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
  • additionally the lights should only be turned on if it's sufficiently dark in the area
  • 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.


For information on how to install this component see Installation.

Features

See how πŸ€– Auto Areas can take over some of this work:

Aggregated presence detection

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 single binary_sensor which will be named according to the area: binary_sensor.area_presence_{area_name}.

Presence lock

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.

Aggregated illuminance

Tracks all illuminance measuring sensors in an area. The last known illuminance of all sensors is used. This illuminance is published in a sensor with the ID sensor.area_illuminance_{area_name}.

Control lights automatically

Lights are automatically turned on and off based on presence in an area.

By default all light entities of an area are managed. A list of entities to be ignored can be defined in the configuration options.

Illuminance

To not turn on lights during daytime an illuminance threshold can be configured. Only if an illuminance below this threshold is measured, the lights are turned on. Illuminance is constantly monitored: if an area is constantly occupied, lights would turn on once it's sufficiently dark in the area.

Sleep mode

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.area_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 mark an area as "sleeping area" refer to the configuration section.

Installation

Auto Areas is a custom_component for Home Assistant.

  1. The recommended installation method is using HACS: search for "Auto Areas", install it and restart Home Assistant. Alternatively download a release and copy the folder custom_components/auto_areas to the custom_components folder of your Home Assistant installation.
  2. For each area that you want to control with Auto Areas, go to "Settings"/"Devices & Services"/"Add integration" and search for "Auto Areas". You can then create an instance for each area you want to manage.

Configuration

Navigate to "Settings"/"Devices & Services"/"Auto Areas" and select the area for which you want to change the options for. Select "Configure" and change the behaviour with the following options:

Area option Description Default value
Set as sleeping area Mark area as sleeping area. A switch for controlling sleep mode is created. See more false (disabled)
Excluded light entities Entities to exclude from automatic light control. These lights are never turned on or off. [] (none)
Illuminance threshold Only if area illuminance is lower than this threshold, lights are turned on. 0

Development

Using DevContainer is recommended (see config in .devcontainer).

About

πŸ€– A custom component for Home Assistant which automates your areas.

License:MIT License


Languages

Language:Python 98.1%Language:Shell 1.9%