Integrations

Labs

Spook adds actions to Home Assistant Labs that switch a preview feature on or off from an automation, like winter mode when it snows.

Home Assistant Labs is where Home Assistant keeps its preview features: what an integration offers to try before it is done. Winter mode is one, with snowflakes falling over your screen. You find them under Settings > System > Labs.

Labs switches them by hand only. Winter mode when it snows, and off again when it stops? Not without walking to the Labs page twice. Spook adds two actions that switch a preview feature from an automation or a script. An assistant with Spook's tools can list them and switch them too.

Actions

Spook adds two actions to Labs. You find them wherever you add an action, marked with a 👻. Both are for administrators only, the same as the Labs page.

A preview feature goes by its full name: its integration, a dot, and the feature. Winter mode is frontend.winter_mode.

Enable preview feature

Switches a preview feature on, like its switch on the Labs page.

One that is on already is left alone: nothing is written, and nothing is told it changed. That matters, because Labs tells every integration when one of its preview features is switched, and some act on it. The Teslemetry integration reloads, for example, to add or remove the entities of its preview feature. So an automation can call this as often as it likes.

Ask for a backup, and Home Assistant makes one first, with your automatic backup settings, the same as the Labs page offers when you switch one on. Like every automatic backup, it follows those settings: afterwards, they may delete the oldest automatic backups beyond the number you keep. The action waits until the backup is done. A backup that fails stops the action, and the preview feature stays off. When it is on already, there is nothing to back up for, and no backup is made.

Only a preview feature the Labs page shows can be switched on. That is the one of an integration that is set up. Switched on before that, nobody could see it is on, nor switch it off there.

How to use it

  1. Open the automation or script that should do this, and select Add action.
  2. Search for preview feature, and select Home Assistant Labs: Enable preview feature 👻.
  3. Under Preview feature, enter its full name, like frontend.winter_mode.
  4. Turn on Create backup if you want a backup first.
  5. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

Disable preview feature

Switches a preview feature off, like its switch on the Labs page.

One that is off already is left alone, the same as the enable action: nothing is written, and nothing is told it changed.

Any preview feature Labs knows can be switched off, also one of an integration that is not set up. Off is what that integration finds once it sets up, so nothing hides.

How to use it

  1. Open the automation or script that should do this, and select Add action.
  2. Search for preview feature, and select Home Assistant Labs: Disable preview feature 👻.
  3. Under Preview feature, enter its full name, like frontend.winter_mode.
  4. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

When a preview feature is switched

Spook adds no trigger for this, as Home Assistant has one already. Labs fires the labs_updated event every time a preview feature is switched, on the Labs page or by these actions, with the domain, the preview_feature, and whether it is now enabled. A plain event trigger listens for it:

triggers:
  - trigger: event
    event_type: labs_updated
    event_data:
      domain: frontend
      preview_feature: winter_mode
      enabled: true

Use cases

What people use this for:

  • Winter mode when the weather says it snows, and off again when it stops.
  • Winter mode for the holidays only: on in December, off again in January.
  • Try a preview feature with a backup made first, so going back is one restore away.

Missing something here?

An action, an entity or a repair this integration should have? Say so. Stuck, or found a bug? There is help.