Home Assistant Assist (How To)


What is

Assist is home assistants new way of interacting with smart devices in your home by typing in sentences and doing actions and telling us some information. This engine is also used with the voice capabilities by using Siri shortcuts and on Android wear.

What can it do out of the box

You can ask home assistant home many devices are on, turn lights on, turn lights off being quite specific about the device name.

Intents

An intent is what I user is seeking to do with their phrase, this concept is valid for all of our voice assistance. The voice command gets converted into text and that text is parsed agains an engine to establish the next best step which might include turning a light on or off in home assistant. Assist will always reply back with some pre-defined text.

Based on the language that you have set it will answer in the correct language.

As always with Home Assistant you can customise and create your own intents. In the section below I’m going to show you how you can expand an existing intent.

Expanding Intents

The GitHub repos with all intents is here:

In the image below on line 3 is an example of an Intent –> HassTurnOn. This intent looks for given sentences that are listed from line 6 to line 11. <light> is looking for a specific light entity. In my example I’m going to use iMac lamp.

You can contribute to the official project, but if you want to quickly add some custom sentences in your home assistant this is how:

  1. Go to your configuration folder either with file editor or visual studio code (add-ons)
  2. Create two new folders the first custom_sentences, inside that create a second folder with your language code in my example en
  3. Create a .yaml files with a name that makes sense to you I’m creating a file called on_off.yaml
  4. inside the file copy this content
# Example on_off.yaml entry
language: "en"
intents:
  HassTurnOn:
    data:
      - sentences:
          - "accendi [la] imac lamp"
        slots:
          name: "imac lamp"
  HassTurnOff:
    data:
      - sentences:
          - "spegni [la] imac lamp"
        slots:
          name: "imac lamp"

My family speaks both English and Italian so I’m creating a command to turn on and turn off using the words accendi and spegni from the Italian language.

As you can see I’m referencing the intent HassTurnOn and HassTurnOff, use the GitHub repository to find out the names of other intents that you can expand.

Keep the structure with the sentences and the slots (name of the device).

You can also make this generic by adding these tags

# Example on_off.yaml entry
language: "en"
intents:
  HassTurnOn:
    data:
      - sentences:
          - "accendi [la] imac lamp"
        slots:
          name: "all"
          domain: "light"
  HassTurnOff:
    data:
      - sentences:
          - "spegni [la] {name}"
        slots:
          name: "all"
          domain: "light"

Creating Custom Phrases

You can also create your own phrases, this is a two step process:

Create a new file under the custom_sentences/en

Add a new file in that folder with .yaml at the end

Example:

I’m creating an intent called CustomFridgeSensor to understand what the status is of the Fridge, by using natural expressions. You can add as many sentences you want by adding – to each line. In my example I have two.

# Example temperature.yaml entry
language: "en"
intents:
  CustomFridgeSensor:
    data:
      - sentences:
          - "Is the Fridge Open or Closed"
          - "Can I eat food from the Fridge"

now that you have that saved, go to your normal configuration.yaml and you need to tell assist what to do once it receives one of these two sentences.

intent_script:
  CustomFridgeSensor:
    speech:
      text: " The Fridge is {{states('binary_sensor.fridge_door')}}"

Above I’m referencing the CustomFridge Sensor (you need to ensure that this is written in the same way as in the custom_sentences folder.

The text uses templating by pulling the state of the binary sensor fridge door.

As you can see from the example above it does work when I’m really specific with my sentence, but if I diverge in some way it doesn’t understand me.

One thing to note, it does not distinguish between lower case or upper case.

Gio

Gio loves rabbits, smart home tech, WWII, travelling to Thailand & my favourite pizza is margherita with parma ham!

Recent Posts