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.
0.113: Automations & Scripts, and even more performance! 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 CasaToday 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 & ScriptsThis release brings changes to our automations and scripts. Before we start with this all, please note, that the
action
part of an automation is a scriptsequence
.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 fixThere 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 modesWith 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
single
mode, the following modes are now available:
Mode Description single
Do not start a new run, if running already. restart
Start a new run, after stopping the previous run. queued
Start a new run after all previous runs complete. parallel
Start a new, independent, run in parallel with previous runs. For the queued and parallel modes, an additional parameter
max
is 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.
More information about the running mode can be found in the automations and scripts documentation.
Automations & Scripts: RepeatsA 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: ChooserGot 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
if
/else
statement, where thedefault
acts as the else. Or even asif
/else if
/else
statement as shown in the YAML example above.More information about the chooser can be found in the documentation.
Automations & Scripts: Sub-second precisionThanks 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 downscript: 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
The
MDI icons updatedsingle
run mode of this automation, combined with the lastdelay
of 10 seconds, prevents this automation from being ran more often than only once every 10 seconds. This is ideal for things like a doorbell.It has taken some time for us to upgrade to the newest version of Material Design Icons, 5.3.45, there was a reason for that, version 5.0.45 contains a lot of breaking changes.
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.
Most of the removed MDI icons can be found in Simple icons, which is available as a custom integration.
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 updatesThe 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 optimizationsAfter, 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.
This time we have both @bdraco and @pvizeli to thank for some great optimizations that will reduce the CPU usage of Home Assistant.
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 changesNew Integrations
- 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:
New Platforms
- PoolSense, added by @haemishkyd
- Dexcom, added by @gagebenne
- Bond hub, added by @prystupa
The following integration got support for a new platform:
Integrations now available to set up from the UI
- OpenZWave has now support for window covers, added by @Michsior14
The following integrations are now available via the Home Assistant UI: