Home Assistant Hot Tips of the Day
Beginning of September, I started a series on Twitter and Mastodon called Home Assistant Hot Tip of the day.
I'll still post on Twitter and Mastodon, but this post act as a repository of all past tips.
I'll try to keep it as up-to-date as possible.
Last updated: 2023-09-11
Local Assist
Our voice assistant can be set up completely locally if you have enough CPU to perform Speech-to-text and Text-to-speech.
Here is a video comparing the speed of Assist using Home Assistant Cloud and running it locally.
Using Assist with Home Assistant Cloud is a one-click setup
(Actually, we set it up for you, so it's a zero-click setup)
You're also supporting the development of Home Assistant by using it.
Learn more here
Using Assist locally requires you to run Piper and Whisper locally
- https://github.com/home-assistant/addons/tree/master/piper
- https://github.com/home-assistant/addons/tree/master/whisper
The demo you saw above is NOT performed on a Raspberry Pi, it is performed on a powerful NUC i5 with a pretty heavy model for both TTS and STT.
Remote Backups
BACK. UP. YOUR. DATA
Since a few versions, Home Assistant supports network storage.
If you have a NAS, setting up a daily backup takes less than 2 minutes.
Seriously: Watch
Supercharged mushroom person card
Reflecting on yesterday's post about 🍄 Mushroom by @piitaya, I'd like to share my favorite card in my setup: The super-charged person card
It's subtle but this card packs lots of details that I absolutely love.
Can you spot them?
Here is what the card supports
Standard features:
- Show when a person is home
- Show when a person is in a zone
Added features:
- Gendered adjectives (Présent / Présente)
- Show where the person is if he/she is away (City, or City + Country if abroad)
This card is a template 🍄 mushroom card, mixing data coming from two different sources
- The person entity
- The Geocoded Location sensor coming from our companion app
You'll need the app to make this card work:
You can find the card here:
Tile card and its features
Everyone loves 🍄 mushroom cards by @piitaya.
But do you know the native Tile card allows you to create a similar look and feel?
Here are some of my dashboards. 90% is native. I only use Mushroom for titles and subtitles.
The tile card and its features are also built by @piitaya
Turning off and on many automations at once
Most of the time, one "functionality" is implemented in many automations.
(For example, my "Smart cleaning" functionality is split into 12 automations)
Create an input_boolean helper and add it as a condition to every automation.
Result: A single button that controls the complete functionality.
Universal Media Player
So you have your TV as a media player, then Cast, then your speakers, then maybe Plex, Android TV remote
And you wonder how to have a nice media center experience in Home Assistant
The Universal Media Player integration
https://home-assistant.io/integrations/universal/
This integration allows you to create a main media player by picking what works best in all your child media centers.
You can override the turn-on action, the volume actions, the state, etc
Here is mine for inspiration
MacOS Companion app
Working on Mac? Did you know we have a native macOS App?
It exposes lots of sensors coming directly from your machine to your Home Assistant.
One of them is a boolean "Camera in use", I use it when I am in meetings.
The app is available on the AppStore
Testing an automation by faking state change
So, you built an automation but can't test it in the real world?
The developer tools can help you simulate literally everything on Home Assistant.
Look how I can change the outside temperature without waiting to fix global warming.
But be careful, It's a double-edged sword - use it with caution. Make sure you put back real values once you are done testing.
Favorite colors
Did you know that lights have favorite colors?
Long press on them to edit them and add/remove some!
Absolute vs relative time display
In the new more-info screen (Available for Lights, Covers, Switches, Alarms, Fans, Sirens and Locks for now) you can change the way the last state change is displayed by clicking on it.
Aliases
You can add aliases to entities and areas. Aliases are alternate names that you can use when using Assist, our private voice assistant.
Note: Aliases also work with Google Assistant, but not with Alexa
Areas
Areas represent rooms in your home.
Until this year they have been used lightly in the product, but now they are a core part of Assist, our voice assistant.
Look how a good area setup can unlock great assist commands.
Note: Here I am writing the commands for the sake of simplicity but the commands are meant to be spoken
Dynamic scenes
You can capture the state of your devices in order to restore them later with 'scene.create'
Watch how the light state is restored in this video.
Script available here:
Scenes created with 'scene.create' do not survive a restart.
Note: Scenes created with 'scene.create' do not survive a restart.
Copy, Paste and Cut on dashboards
Similarly to yesterday's tip, you can COPY, CUT and PASTE cards within a view, across views, and across dashboards.
Here I recreate a dummy dashboard with only COPY, CUT and PASTE
Super useful when reshuffling views!
Copy, Paste and Cut on automations
You can COPY, CUT and PASTE blocs when creating automations.
It allows you to tweak what you are building with minimal effort.
Here I change the way conditions are checked and actions are run in a few seconds.
Wildcards
Wildcards allow you to match lazily part of a sentence such as "Add {item} to my shopping list"
Let's play a game:
What does this automation do?
(Think carefully)
Well, it chains 2 commands, right?
I can say "{Turn on the living room light} and {close the shades}"
Correct.
But this is not all.
Have a look
Since wildcards are lazily matched, the simple automation above is recursively called.
When I say "1 and 2 and 3 and 4", it is matched as such: "{1} and {2 and 3 and 4}"
And processing "2 and 3 and 4" calls the same automation and matches "{2} and {3 and 4}"
And so on.
Caveats (aka. Why this is just an experiment and you should think twice before adding it on your side):
- The structure is so simple "{1} and {2}" that this automation will be triggered when you don't want to.
Like "{Add peanut} and {jam to my shopping list}" - You won't get feedback if some commands are erroneous:
"{Turn on the living room lights} and {make me a coffee}" will just ... "work"
(But you won't get your coffee)
Still a cool experiment to learn wildcards
expand()
expand() is an advanced templating feature that lets you expand specific parts of your state machine.
This small sensor gives me the number of pending updates and their names.
For the state of the sensor, this is what the template does:
- It expands all the entities in the update domain
- It filters the ones that have a state equal to 'on' (update available)
- It lists them
- And counts them
The result is the number of pending updates (4)
For the attribute "entities", this is what the template does
- It expands all the entities in the update domain
- It only keeps the attribute "friendly_name" for each of them
- It lists them
- And sort them
The result is a list of available updates
[
- Vacuum Update
- ..
]
A very simple automation triggered by this sensor, and you can be notified as soon as updates are available across your system.
Full sensor available here
Sentence trigger
You can extend what Assist understand by creating really simple automations.
Here is one triggered by the custom sentence "Raise the desk".
Automation editor
The automation editor packs a lot of features that help you during an automation creation.
You can:
- See triggers fired
- See the trigger data
- Test conditions
- Run actions
without even saving the automation.
Subviews
A subview is a view that does not appear in the dashboard top bar.
In this simple example, I use a subview per room, and navigate using Tiles.
The navigation card is available here:
Coloring cards
Most cards use the primary color.
The Tile card can use the accent color.
Some entities like battery sensors compute color based on their state.
You can change the primary/accent colors to make Home Assistant your own.
How to use logbook data
The logbook holds valuable information, often overlooked.
In this example I dig up why a toggle was triggered and find out:
- The automation
- The trigger
- The conditions
- The user initially responsible
JL triggered the "Trigger toggle"
and because the sun was above the horizon
the automation "My Automation" was processed
and turned on the "Result toggle"
Display precision
Change the display precision of your numerical sensors directly in the UI.
Note: This does not change the value of the sensor, just the way it is displayed.
Device class of binary sensors
Edit the device class of your binary sensors directly on the UI to change the way they are displayed (Icon + State labels)
Trigger IDs
Combine "Trigger IDs" and the "choose" action to group simple automations by little functional packages.
For example, this is a single automation that toggles a light based on the sun's position.
Decluttering your sidebar
You can declutter your sidebar and organize it by long-pressing on "Home Assistant".
I created a navigation card for everything "technical" so that it's not in my way every day.
The card is here:
Keeping automation instant
Automations are not meant to be running forever.
They reset after a restart.
If you need to wait hours to perform an action, use an input_datetime and a second automation triggered by it.
These 2 automations are instant
Note: From a performance perspective, there is nothing wrong with having automation running for a long time.
You just increase the risk of having a restart in a middle of an automation.
Running a script vs turning on a script
RUNNING a script blocks the subsequent actions until the script is over.
TURNING ON a script is an immediate action that does not wait for the script response to continue to the next actions.
You can find the scripts used in the video here:
Reusable logic on a template sensor
If you keep creating the same complex trigger/condition: Simplify your automation by creating a template sensor.
So that the logic is only in one place.
Here is my "Home Occupancy" sensor for example:
Trigger Data
Triggers convey a lot of data, and you can see the data while building an automation!
Just fire the trigger and click on the "Triggered" banner.
Here is an example with the new wildcard trigger available since the 2023.8 release.
State of zones
The state of a zone represents the number of persons present in it.
You can very easily create triggers that will fire, or conditions that will match, when:
- Your home is empty
- Your home is occupied
- Your home is full
I created a small gist that contains them all: