Home Assistant & slot_programs/hass/entities: entities download issues

Hi.

First of all let me thank you for this awesome project. I really love it!

I set up now everything and it’s working. But I cannot get rhasspy to download the entities.

Here are the steps I took to get it partially work.
At first some basic infos.

HA: Runs in a venv with the recent version 2021.5.1
Rhasspy: v2.5.10 runs in a docker environment on the same system

  1. downloaded the script “entitites” from https://github.com/rhasspy/rhasspy/tree/master/examples/homeassistant/profile/slot_programs/hass, put it locally on my HA system under “/home/username/.config/rhasspy/profiles/de/slot_programs/hass/entities” and made in executable. Additionaly I added “intent:” in the configuration.yaml in HA and reloaded it.
  2. I tried it then to add the following to the sentences, but it did not work as it complained about not existing slots (e.g) $hass/entities,light and $hass/entities,switch
[HassTurnOn]
lights = $hass/entities,light
switches = $hass/entities,switch
entities = <lights> | <switches>
schalte [das] (<entities>){name} ein

[HassTurnOff]
schalte [das] (<HassTurnOn.entities>){name} aus

[HassToggle]
entities = <HassTurnOn.entities>
toggle [the] (<entities>){name}

[HassLightSet]
stelle [das] (<HassTurnOn.lights>){name} [color] auf ($hass/colors){color}
stelle [die] (<HassTurnOn.lights>){name} helligkeit auf (0..100){brightness}
stelle [das] (<HassTurnOn.lights>){name} auf (0..100){brightness} prozent helligkeit

Unfortunately that did not work. As it complained about the not existing slots.

  1. I created the slots manually. I guess I did here something wrong because it was a lot of trial and error. I created the slots like this
    a) hass/entities,light
    b) hass/entities,switch
    But when I went back to save the config the slots were deleted again, so i put a dummy line “test” in them, saved the result for switch and light and then saved the configuration again. This time it worked.

It seems that rhasspy is not downloading all the entitites at all. I guess I made a mistake with the slot naming. My guess goes in the direction, that the naming “hass/entities,light” for example is wrong and the “,” indicates somehow that this must be just inside the slot “hass/entities” But please correct me if I am wrong.

I made it now work as I copied some of the friendly names from HA to the two slots. Like
a) to the slot hass/entities,light: Licht Schlafzimmer Ambient
b) to the slot hass/entities,switch: Steckdose Küche

But I really would like to have the possibility to download the entities new every time I hit the train button, as I have a lot of entitites

Furhermore I have another quesion: Unfortunately the voice feedback I get back is in english. This is due to HA I guess. As far as I can see it uses the internal states (e.g ON/OFF) for this. Any ideas how I could change this?
Because in the future I want to be able to get German Time and sensor states back. Like “Wakeword, was ist die Temperatur im Wohnzimmer” and get a german response to that.

Since all this took me the whole day yesterday, is it possible to add some things to the docu? Because the docu is not that clear what to do. Especially when you start from scratch and you never did that before. This would be awesome! :slight_smile:

Again: Thanks all for the outstanding contribution to this!

cheers

nightingale

Bump

Does anyone have an idea? :slight_smile:

Hi Nightingale,

I had the same issues, in the end I approached it from a different angle, not knowing how large your HA system is I guess it’s impossible to know my suggestion would be useful or not, but I put the HA entity_id in the sentence.ini using : method and throw that to HA though MQTT and then pick it up in a template automation. It works, I am new so don’t know if it’s recommend or not.

Here is the post How to specify voice-responses in sentence.ini

My ramblings are at the end, even if you hate it as a newbie to all this I would love feed back

Cheers

MattV

I do not download the entities, so I do not the problem with that. Maybe I should try it :slight_smile:

Why did you use hass/entities,light and not just “lights” and “switches”?
You can than just use this:

[HassTurnOn]
schalte [das] ($lights | $switches){name} ein

Yes, you must use a service to call the Rhasspy TTS from within your intent handler.
I do not know you intent_script, but you probably have speech in it. That used the TTS of Home Assistant, but you want to use Rhasspy

What is not clear? What documentation did you follow?
Also, if you struggle and find your way through and think it is useful for the community, post it in Show us. That way we can all benefit from it :slight_smile:

It seems it worked for some here. But no detailed infos how to do that. In fact rhasspy downloaded the entities somehow. I realized that because it asked me to accept the spelling.

Because it was described like that in the docu.
See: https://github.com/rhasspy/rhasspy/tree/master/examples/homeassistant

I figured out now why. This is related to the build-in intents. They are in english. That is way that happened. Suprisingly we have also other languages included, but unfortunately they are not used for this.
…/homeassistant/components/light/intent.py
and
…/homeassistant/components/light/translations

The Docu from here: https://github.com/rhasspy/rhasspy/tree/master/examples/homeassistant
Absolutely not clear for me. At least not as a first time offender. For example how to really name the slots. hass/entities or hass/entitites,light. Or is this “light” somehow a section in hass/entities? Just as one example…

Thanks for help :slight_smile:

Ah ok, that is not really documentation but maybe I can help
I actually see that github page for the first time, so I don’t know if what I read is correct.

The action you did on step 1 seem correct, is Rhasspy indeed running a de profile?
Also, is the path correct? The /home/ path should be mapped into Rhasspy but when you have used the docker command I think it should be ok. You might want to check it by checking of the sentences.ini is correct if you change something in Rhasspy

Step 2: Do you have some actual logging?

Step 3: That does not work $hass/entities is the program to run and light is a parameter provided to the entities bash script which in turn only returns entities within the light domain.
Maybe this will help in understanding the slot_programs

I tried and had the same issue with the github page. The complaining about missing slots.
When I opened the script, I saw that it uses the HA url and a token from the settings under Intent Handling

When I filled the Home Assistant url and a long lived token, everythting work as expected.
Also note that the script outputs the friendly names and the sentences will be trained on the friendly names.

Hope it helps

Hello @romkabouter,

actually I don’t think I made a mistake. Because I followed what was provided. Therefore I asked for more details.

But let me try to recap what I did.

  1. Downloaded the bash script: https://github.com/rhasspy/rhasspy/blob/master/examples/homeassistant/profile/slot_programs/hass/entities
    and put it under /home/rhasspyuser/.config/rhasspy/profiles/de/slot_programs/entities

  2. created the sentences.ini as followed:

[HassTurnOn]
lights = $hass/entities,light
switches = $hass/entities,switch
entities = |
turn on [the] (){name}

[HassTurnOff]
turn off [the] (<HassTurnOn.entities>){name}

[HassOpenCover]
covers = $hass/entities,cover
open [the] (){name}

[HassCloseCover]
close [the] (<HassOpenCover.covers>){name}

[HassToggle]
entities = <HassTurnOn.entities> | <HassOpenCover.covers>
toggle [the] (){name}

[HassLightSet]
set [the] (<HassTurnOn.lights>){name} [color] to ($hass/colors){color}
set [the] (<HassTurnOn.lights>){name} brightness to (0…100){brightness}
set [the] (<HassTurnOn.lights>){name} to (0…100){brightness} percent brightness

When I did this and pushed “Save sentences” then I got an error, because of the slots where not existing. So I tried a lot. Result was, that I needed to name the slots exactly like this:

hass/entities,light
and 
hass/entities,sensor

File was created under: /home/rhasspyuser/.config/rhasspy/profiles/de/slots/hass
So in fact it was not possible to use just the bash script without creating the slots before.
Furhermore I needed to create dummy entries to create the slots. Otherwise they would have been deleted and the error occured again.

As far as I can see this is not correct. Because like said, when using the sentences from the example it expects slots like $hass/entities,light.

I really appreciate your help, but did you fully read what I wrote? Or maybe I was unclear? If so, please let me know. Because surely I want to help others who struggle at the same issues as I do.

Cheers

ng

Yes, but did you also provide the HA url and a longlived token under the Intent Handling settings in Rhasspy?
Because that is what fixed it for me

Yes of course. For me this was a given fact. As I mentioned also, that the download works, but its not filling the slots. Instead it filled the custom words.
e.g licht_kueche_1_4_vorne_links l 'I C t : k U @ C 'e: : : : f O 6 n 'e : l I N k s
This is just one entity of a group .

Put it in /home/rhasspyuser/.config/rhasspy/profiles/de/slot_programs/hass/entities

Add url and a token under Intent Handling settings

First restart Rhasspy, then add the sentences. Otherwise you will indeed get the slots error.
That error also occurs when not having a url and token.

It is correct, the $hass/entities is your bash script (hass being a subfolder and entities the scriptname in slot_programs)
light is the first parameter of that script.

I have exactly this:

I had exactly the same errors as you had, but that was fixed when adding the url and token:

If it still does not work, can you post the logging from Rhasspy?
Either get it through the frontend or docker logs rhasspy

Did that. :slight_smile: But even before posting here. But this also did not help. The url and token worked before already, so no need to reset it. As I used events before which already worked. The intention to download the entitities came later.

That was done already at least x times. But it was still complaining about not existing slot $hass/entities,light. So after creating exactly “hass/entities,light” under slots and add “blatest” save it, train it, the error was gone

That really worked before for 2-3 days. So I did not need to change that setup at all. Also I’ve rebooted x times within this time.

Like mentioned already, it downloaded the entitites meanwhile, but they are not added under slots where they should occur.
example: “grep -r “kueche” *” in the users home directory…
output:

kaldi/model/graph/phones/align_lexicon.txt:licht_kueche_1_4_vorne_links licht_kueche_1_4_vorne_links

That means it downloaded the entities names but did not fill them into hass/entitites, nor hass/entitites,light, …

Wait, is your expectation that they appear under slots in the web frontend?
If that is the case, then I understand your problem because they won’t
If you have seen that the entities are download, you already had everything setup ok.
For slot programs, there will be no dropdowns. That is only for manually created slots.
The slot programs are run while training, the entities are not saved as slots

Precesiely! OMG! :man_facepalming:

Ok, now I know more. Thanks for the clarification :slight_smile:

KR

nightingale