This is part 3 of my homeassistant migration.
I’ll cover some insights on the automations (especially blueprints) here.
Why use automations?
In the past years, I’ve come across a few things I like to be automated in my home. It started with a few sensors for temperature monitoring, added Tasmota devices, Shellys and ended with open/close sensors for the doors.
So how to cobble all of this together?
Common usecases are e.g. notifications on low temperatures, trigger a switch or light if movement was detected.
HA vs. OH3 automations
My largest fears were how automations will work in comparison to openHAB.
The main difference between the two system lies in HA using YAML configurations with Jinja2 templating support that evaluate to code vs. actual code that’s being written in a Java-like DSL in OH.
In opposition to OH, HA has things like blueprints and scripts to add to your automations. Everything goes into automations.yaml as a big pile of config.
You can choose to just click together what you need as an automation via the provided UI and fit in pieces of YAML config as you go, if you need non-standart stuff or just want to use evaluations via templates.
I strongly suggest you read up on automation basics in the documentation.
In addition to the basics: As soon as you have recurring tasks, consider to use a blueprint. Before you start to write one yourself, check the forums for available solutions you may reuse or adapt to your usecase.
My Automations so far
I went through everything I did in OH3 and made a list of all automations from my previous setup.
Usecases
These are the current usescases I have:
Motion triggered lights at night in my staircase, several instances, timer of 90s after last motion was detected.
Start a timer when a socket switch was turned on (for heating devices e.g.) and turn off after timer is over.
Use remote controls like the IKEA tradfri 5-button or 2-button to not only control lights, but also Shelly or Tasmota devices or groups of lights
Detect opened doors and alert via push messages
Alert on doors being open for >2 minutes
Alert on low temperature indoors
Check the current presence state of inhabitants
Combinations of the above
I’ve collected all my current solutions in a github repository, so make sure to collect what you want to reuse or change there, code samples below might be outdated.
Motion triggered lights
I prefer the lights in my staircase to turn on and off automatically, especially when it’s after dawn or before sunrise and on motion.
The below code is not perfectly elegant, since you can’t configure the offset for sunrise/sundawn.
What’s happeing?
Configure a motion sensor as trigger device
Add as many lights or switch devices, groups etc. as you need
configure brightness and how long lights will be on
The time for the light being on depends on three factors: How long does the sensor stay in the activated state and after it does not detect any more movement, the timer.
{% verbatim %}
{% endverbatim %}
Turn-off timer
I’m using a few devices for heating e.g. water (boiler).
{% verbatim %}
{% endverbatim %}
Door open/close notify
I want to know when my doors are opened… And also if/when they are closed.
The difficulty here, is to provide a name and the state for a message in a notifier service. With this blueprint you only have to c&p the template snippet into the message field.
I would have preferred a pre-filled variable and evaluated/translated state. But this only works for values that come with the inputs themselfs. The trigger is evaluated on state change and is therefore dynamic :-(
{% verbatim %}
{% endverbatim %}
Temperature alert
I stole this nifty piece of code from this template and re-arranged it to fit my usecase.
There are 9 temp sensors in my home and I want to monitor all of them, exept e.g. the outdoor ones, because they are allowed to have temperatures below 10°C.
This blueprint checks the states of the sensors every 15 minutes, whis is the trigger, naturally. It’s running through all sensors with temperature and evaluates vs. the temperature threshold.
If the threshold is met, it sends a notification.
And you can set which sensors to ignore.