Versie 0.113 van Home Assistant Core is uitgebracht. Home Assistant Core is een opensourceplatform voor home-automation dat draait onder Python 3. Het draait via Hassbian op een Raspberry Pi 3 of een Linux-, macOS- of Windows-computer. Het ondersteunt het detecteren van apparaten, zoals Nest-thermostaten, Philips Hue, Belkin WeMo-schakelaars, Mr. Coffee-koffiezetapparaten, de slimme schakelaars van IKEA en het mqtt-protocol. Daarnaast kan het waar mogelijk deze apparaten aansturen en automatisering toepassen. Voor meer informatie verwijzen we naar deze pagina en ons Forum. De aankondiging voor deze uitgave is hieronder te vinden.
Another special, themed, release inbound! It seems like @bdraco is unstoppable; he just keeps going on improving the performance of the Core. I truly admire him for the work he has been delivering the past months, however, that is not the point of this release. Sorry, @bdraco! This release is about: Automations & Scripts! Yes!!!
A long, long time bug with automation triggering has been resolved, but not only that, @pnbruckner went all-in by extending the automation/script engine even more. Adding repeat, a chooser and running modes (with cool down possibilities as a side-effect).
I’ve been playing with these features on my home already and I’ve changed/improved quite a few things. For real, @pnbruckner, thank you!Ludeeus joins Nabu Casa
Today we’re happy to announce that @ludeeus is joining Nabu Casa to work full-time on Home Assistant!
Ludeeus has been a core contributor for a long time working on the Supervisor panel and different bits of the frontend. He is, however, mainly known as the creator of the Home Assistant Community Store (HACS).
We’re looking forward to seeing what he can do now that he is able to focus full-time on Home Assistant. Welcome @ludeeus!Automations & Scripts
This release brings changes to our automations and scripts. Before we start with this all, please note, that the
actionpart of an automation is a script
So, all discussed below, apply to both scripts and automations.
Before diving in: All automation and script changes, have been driven by @pnbruckner! It is awesome! Thanks!Automations & Scripts: Bug fix
There has been an issue with our automations for a long time already, which you actually might have never noticed. It is kinda hard to explain, so this needs an example.
Consider the following automation:
automation: - alias: "Example" description: "On button press, turn on the light bulb for 10 seconds." trigger: - platform: state entity_id: binary_sensor.button to: "on" action: - service: light.turn_on entity_id: light.bulb - delay: seconds: 10 - service: light.turn_off entity_id: light.bulb
This automation turns on a light bulb when the button is pressed, and after 10 seconds, it turns off the light bulb again. A fairly basic automation, which does exactly what one would expect, except when a button is pressed twice.
So it takes 10 seconds for the bulb to turn off, what if you press the button again after 5 seconds?
Please, think about this for a moment…
What actually happened before 0.113, is that the light bulb would turn off immediately! Chances are, you didn’t expect that.
Let’s explain this: So the first button push, turns on the light, and the delay is active for 10 seconds. The second button push, done after 5 seconds, is actually not handled, however, it does cause the delay of the first run to cancel itself and continues to run the rest of the actions/sequence, causing the light to turn off immediately!
That bug, has been fixed. As of this release, the second button press wouldn’t do anything and the light will now turn off after 10 seconds, which the first button push has triggered.Automations & Scripts: Running modes
With the above-mentioned bug fix, it now becomes possible to introduce new running modes for both scripts and automations. It allows you to control what happens if actions of a previous trigger are still running.
Considering the light bulb example in the bug fix paraph above, it shows the default mode:
single, which means: Do not run and ignore the trigger if a previous action of the same automation is still running.
Besides the default
singlemode, the following modes are now available:
Do not start a new run, if running already.
Start a new run, after stopping the previous run.
Start a new run after all previous runs complete.
Start a new, independent, run in parallel with previous runs.
For the queued and parallel modes, an additional parameter
maxis available to control the maximum number of runs that are awaiting each other. When omitting this setting, it would default to 10.
To clarify a little more, remember the first example in the bug fix paragraph where the light bulb would turn on for 10 seconds after a button press?
This would make every button press within the 10 seconds, restart the countdown again:
automation: - trigger: - ... mode: restart action: - ...
And this example, would turn on/off the light, for 10 seconds twice, if the button was pressed after 5 seconds.
automation: - trigger: - ... mode: queue action: - ...
The modes are also available for automations and scripts in the frontend UI:
This is a powerful feature, which allows you to control how automations and scripts are run in ways you could not do before.
A brand new action is made to allow for repeating (also called loops) part of your automations or scripts.
The new repeat feature can be used in three different ways:
- Counted repeat: Control how many times to repeat a sequence.
- While loop: Keep repeating as long the condition(s) is/are met.
- Repeat until: Runs at least once, and decides after that to repeat until the condition(s) is/are met.
For example, this would spam your phone with the same message 10 times:
- alias: Send notification spam to phone repeat: count: 10 sequence: - service: notify.frenck data: message: Ding dong! Someone is at the door!
More information about repeats can be found in the documentation.Automations & Scripts: Chooser
Got multiple automations for that single light to turn it on/off? Or multiple automations/scripts to handle the different buttons on some remote?
You can now combine them using a chooser. The chooser is able to pick the first sequence that matches a condition, or if none match, run a default sequence.
This means each individual sequence in the chooser is paired with its own set of conditions.
automation: - alias: "Example" description: "On button press, turn on the light bulb for 10 seconds." trigger: - platform: state entity_id: - binary_sensor.button1 - binary_sensor.button2 - binary_sensor.button3 action: - choose: - conditions: - condition: state entity_id: binary_sensor.button1 state: "on" sequence: - service: light.turn_on entity_id: light.bulb - conditions: - condition: state entity_id: binary_sensor.button2 state: "on" sequence: - service: light.turn_off entity_id: light.bulb default: - service: notify.frenck data: message: Some other unknown button was pressed!
In the above example, pushing button1, turns on the bulb; while button2 turns it off again. The third button isn’t handled by any of the conditions in the chooser and the (optional) default is run instead.
The chooser can be used as an
elsestatement, where the
defaultacts as the else. Or even as
elsestatement as shown in the YAML example above.
More information about the chooser can be found in the documentation.Automations & Scripts: Sub-second precision
Thanks to a bunch of optimizations done this release, which is discussed later in this blog post, we now have sub-second precision available to our delays.
This precision is helpful in case you want a delay that is less than a second, for example, 500 milliseconds.
An example script that toggles the light every 500 milliseconds 10 times.Automations & Scripts: Bonus! Cool down
script: blink_light: sequence: repeat: count: 10 sequence: - service: light.toggle entity_id: light.bulb - delay: milliseconds: 500
An often requested feature is to allow for a cool down time on an automation. What that entails is setting a limit on the run of an automation or script to a certain time frame.
While this is not a feature specifically added or build, it can be achieved now using the new run modes.
automation: - alias: "Doorbell cool down" description: "Prevent multiple message being send when spamming the doorbell." mode: single # Which is the default trigger: - platform: state state: binary_sensor.doorbell to: "on" action: - service: notify.frenck data: message: Ding dong! Someone is at the door! - delay: seconds: 10
TheMDI icons updated
singlerun mode of this automation, combined with the last
delayof 10 seconds, prevents this automation from being ran more often than only once every 10 seconds. This is ideal for things like a doorbell.
We wanted to handle these well, so it took some time.
A lot of icons are renamed, and some are removed. In this release, we included all new, and all removed icons and we made sure the new and the old name work.
If you use an icon that is renamed or removed we will show a warning in the log, in version 0.115, this conversion path will be removed and removed icons and old names will no longer work.
So make sure to check your logs if you need to adjust any of your used MDI icons.
Please note: It is possible that custom integrations (also known as custom components) use deprecated icons. These can throw warnings that need to be addressed in the custom integration.Script and Scene editor updates
The UI to edit or create a script has been updated, besides support for the new running mode, you can now give your scripts a custom icon and ID from the UI.
Especially the ID is helpful, you no longer have to search your states for a long numeric entity id that matches your script.
The support for setting a custom icon, is also added to the scenes editor.More speed optimizations
After, the well-received, speed optimization done in the 0.111 & 0.112 releases, the saga towards improving resource usage and responsiveness of the platform continues.
First of all, if you are running a Home Assistant OS, Container or Supervised installation, this your Home Assistant instance will run on Python 3.8. No action from your end is needed for this.
It is not just a normal Python version, but @pvizeli has worked on a highly optimized Python version for Home Assistant, hitting performance improvements that can reach up to 40%! He wrote a more technical article about this on our developers blog.
Then @bdraco did his part on adding some improvements to the Core. He changed a lot of handling around event & state listeners, in such a way less things trigger unneeded, which reduces processing when states change.
This lowers CPU usage and improves response speed when you have many state changes happening in a short time span, or when having a lot of automations.
Also, all time listeners now have microsecond precision as they are scheduled on the internal event loop, instead of the previous situation when it relied on the internal clock that triggered every second.
This release should drastically lower the CPU usage of Home Assistant for most installations.Other noteworthy changes
- Philips Hue groups can now be turned on/off in the integration options via the UI.
- The OpenZWave (beta) got 3 new services. Two of those are for setting user codes on locks. The other allows for setting device-specific configuration parameters.
- After a moment of absence, @yosilevy is back! He has been the one fixing all kinds of RTL issues we had in Home Assistant, with his return, this release is full of RTL tweaks again!
Three new integration added this release:
The following integration got support for a new platform:
The following integrations are now available via the Home Assistant UI: