Introduction to Home Assistant (HA) Automations

If you like it, share it


Introduction

In Home Assistant we have two possibilities to create automations that are:

  • Through the editor from WebUi (find it in: CONFIGURATION -> AUTOMATIONS)
  • Writing the automations directly into the automations.yaml file


How to create a new AUTOMATION

For create a new AUTOMATION select:
CONFIGURATION -> AUTOMATIONS

NOTE:
automations.yaml is a file that contain your automations

Normally is more convenient use the graphic editor (WebUi), in case of some complicate configurations is necessary write the code directly in automations.yaml file.


Structure of automations in Home Assistant

The automations in Home Assistant, in general, are composed of 3 parts:

  • A trigger
  • A condition
  • An action

This is an example:
(trigger) When Enrico gets home
(condition) and it’s after sunset
(action) Turn on the hall lights



Graphic Editor (WebUi)

We suggest watching this video (YouTube), below there is an example that turn off the external lighting in sun rising in graphic editor (WebUi).


automations.yaml file

Below there is the same automation (OFF Luci Cortile e Prato all’ALBA) in the automations.yaml file



Example that turn on the home entrance light if is night using the Xiaomi Motion sensor and Shelly 1

You can buy the Xiaomi Motion Sensor for example here and
Shelly 1 here.
For more info about the way to use Shelly 1 see here.
For more info about the way to use Xiaomi Motion Sensor see here.

For create a new automation select: CONFIGURATION -> AUTOMATIONS
and press the blue button: + ADD AUTOMATION
from the new page that appears press: CREATE (see below)

And from the new page that appears press: SKIP

Now compile the page as shown below.

NOTE:
In box TRIGGERSMotion Sensor is our XIAOMI Motion Sensor (PIR)
In box CONDITIONS – we choose to enable our automation only in the night (SUNRISE – SUNSET)
In box ACTIONSLuci Ingresso is the name of our Shelly 1 and
… The first ACTION is turn-on the light
… The second ACTION is a delay of 2 minutes
… The third ACTION is turn-off the light

If you are curious and want more info concerning the below MODE see here.

If you are curious and want more info concerning the below SUN see here.

Now SAVE it.

If you want add your automation in Home Assistant home page (Overview) for enable/disable it see below.

Press the button: + ADD CARD
and from the new page that appears select: BUTTON
and compile the new page as shown below.