11 min read

Home Assistant Hot Tips of the Day

Home Assistant Hot Tips of the Day
Photo by Stephan Bechert / Unsplash

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.

0:00
/

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

Nabu Casa

Using Assist locally requires you to run Piper and Whisper locally

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

0:00
/

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:

Home Assistant Companion Docs | Home Assistant Companion Docs
Welcome to the Home Assistant App docs

You can find the card here:

Supercharged Mushroom Person card
Supercharged Mushroom Person card. GitHub Gist: instantly share code, notes, and snippets.

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

home-assistant-config/packages/media_center/media_player_universal_media_center.yaml at master · jlpouffier/home-assistant-config
Open source configuration of my connected apartment - jlpouffier/home-assistant-config

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.

0:00
/

The app is available on the AppStore

‎Home Assistant
‎Control and monitor your home from anywhere in the world. Home Assistant Companion lets you control all your devices and provides advanced location and notification engines to allow for complex automations. Home Assistant is an open-source home automation platform that focuses on local control and…

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.

0:00
/

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!

0:00
/

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.

0:00
/

Aliases

You can add aliases to entities and areas. Aliases are alternate names that you can use when using Assist, our private voice assistant.

0:00
/

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.

0:00
/

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.

0:00
/

Script available here:

Home Assistant Hot Tip: Dynamic Scene
Home Assistant Hot Tip: Dynamic Scene. GitHub Gist: instantly share code, notes, and snippets.

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!

0:00
/

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.

0:00
/

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

0:00
/

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

Home Assistant Hot Tip of the Day: Available Updates
Home Assistant Hot Tip of the Day: Available Updates - available_updates.yaml

Sentence trigger

You can extend what Assist understand by creating really simple automations.

0:00
/

Here is one triggered by the custom sentence "Raise the desk".

Home Assistant Hot Tip of the Day: Sentence Trigger
Home Assistant Hot Tip of the Day: Sentence Trigger - automation.yaml

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.

0:00
/

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.

0:00
/

The navigation card is available here:

tile_navigation_card.yaml
GitHub Gist: instantly share code, notes, and snippets.

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.

0:00
/

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

0:00
/

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.

0:00
/

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)

0:00
/

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".

0:00
/

I created a navigation card for everything "technical" so that it's not in my way every day.

The card is here:

Home Assistant Hot Tip of the Day: A Navigation Card to declutter your side bar
Home Assistant Hot Tip of the Day: A Navigation Card to declutter your side bar - card.yaml

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.

0:00
/

You can find the scripts used in the video here:

Home Assistant Hot Tip of the Day: Run vs Turn on Script
Home Assistant Hot Tip of the Day: Run vs Turn on Script - script.yaml

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:

Home Assistant Hot Tip of the Day: Home Occupancy Sensor
Home Assistant Hot Tip of the Day: Home Occupancy Sensor - configuration.yaml

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.

0:00
/

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:

Home Assistant Hot Tip of the day: home occupancy
Home Assistant Hot Tip of the day: home occupancy - conditions.yaml