Home Assistant / 'switch' returned non-zero exit status 3

Hello Folks!

I just got Rhasspy running on an rpi 4 in docker with a respeaker 4-mic array following the pi from scratch tutorial.

My goal is to get rhasspy running as an offline voice assistant for Home Assistant. I’ve followed the example, but am running into issues when trying to train after installing the slot program. The log output is below. I can’t make heads or tails of it, is some kind soul willing and able to either tell me what the issue is or propose some debugging steps?

[ERROR:2020-09-15 19:13:43,974] rhasspyserver_hermes: Command '['/profiles/en/slot_programs/hass/entities', 'switch']' returned non-zero exit status 3.
Traceback (most recent call last):
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/quart/app.py", line 1821, in full_dispatch_request
    result = await self.dispatch_request(request_context)
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/quart/app.py", line 1869, in dispatch_request
    return await handler(**request_.view_args)
  File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__main__.py", line 1235, in api_train
    result = await core.train()
  File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__init__.py", line 359, in train
    word_transform=word_transform,
  File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/train.py", line 87, in sentences_to_graph
    slot_visitor=word_visitor,
  File "/usr/lib/rhasspy/rhasspy-nlu/rhasspynlu/slots.py", line 87, in get_slot_replacements
    slot_command, universal_newlines=True
  File "/usr/lib/python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/profiles/en/slot_programs/hass/entities', 'switch']' returned non-zero exit status 3.
[DEBUG:2020-09-15 19:13:43,912] rhasspynlu.slots: Running program for slot hass/entities,switch: ['/profiles/en/slot_programs/hass/entities', 'switch']
[DEBUG:2020-09-15 19:13:43,893] rhasspynlu.ini_jsgf: Loaded ini file
[DEBUG:2020-09-15 19:13:43,888] rhasspyserver_hermes: Generating intent graph
[DEBUG:2020-09-15 19:13:43,884] rhasspyserver_hermes: Loading sentences from [PosixPath('/profiles/en/sentences.ini'), PosixPath('/profiles/en/intents/homeassistant.ini')]
[INFO:2020-09-15 19:13:43,881] rhasspyserver_hermes: Starting training

I wonder perhaps if the syntax on my url and long lived token are wrong, as required in slot_programs/hass/entities? (token redacted of course.)

url="$(jq --raw-output http://192.168.1.193:8123 < "${profile}")"

# Long-lived access token
token="$(jq --raw-output LoNgToKeNhErE < "${profile}")"

What if you run this script slot_programs/hass/entities ‘by hand’? Does it show you a more descriptive error then?

Alas… I am an incompetent. I tried to follow the example for running a command on a docker container (I named the container rhasspy), but I have either failed to run it, or have run it and can’t see the output. I also got confused once it got into the interactive base session… I can’t run the commands as they describe.

pi@rhasspyBase:~/.config/rhasspy/profiles/en/slot_programs/hass $ docker exec -i rhasspy touch entities 
pi@rhasspyBase:~/.config/rhasspy/profiles/en/slot_programs/hass $ docker exec rhasspy entities
OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"entities\": executable file not found in $PATH": unknown
pi@rhasspyBase:~/.config/rhasspy/profiles/en/slot_programs/hass $ docker exec rhasspy touch entities 
pi@rhasspyBase:~/.config/rhasspy/profiles/en/slot_programs/hass $ docker exec -it rhasspy bash
root@a372ee73b3f8:/# ./entities
bash: ./entities: Permission denied

Try executing /bin/bash in the container. Then you get an interactive shell and you can explore the container’s files and run the right script.

This should probably be executed as sh entities if it doesn’t have the executable bit set.

Or maybe that’s the original problem? That the entities program is not executable?

By the way, your ~/.config/rhasspy/profiles should normally be mounted on /profiles in the container, so the script should be /profiles/en/slot_programs/hass/entities there.

some progress here… (thank you!)

When I poke around in the /profiles/en directory I do indeed see the profile.json. I also tried running the script from that directory instead of the one shown below but it also couldn’t find that file. I’m hoping that I’m just doing something silly and that you’ll continue to be so kind!

pi@rhasspyBase:~/.config/rhasspy $ docker exec -it rhasspy bash
root@a372ee73b3f8:/# /bin/bash
root@a372ee73b3f8:/# ls
bin   dev       etc   lib    mnt  proc      qemu_gdk-pixbuf-query-loaders_20200724-142459_10785.core  run   srv  tmp  var
boot  entities  home  media  opt  profiles  root                                                      sbin  sys  usr
root@a372ee73b3f8:/# ./profiles/en/slot_programs/hass/entities 
./profiles/en/slot_programs/hass/entities: line 26: /profile.json: No such file or directory
root@a372ee73b3f8:/# cd profiles
root@a372ee73b3f8:/profiles# cd en
root@a372ee73b3f8:/profiles/en# ./slot_programs/hass/entities 
./slot_programs/hass/entities: line 26: /profile.json: No such file or directory
root@a372ee73b3f8:/profiles/en# cd ..
root@a372ee73b3f8:/profiles# cd ..
root@a372ee73b3f8:/# sh ./profiles/en/slot_programs/hass/entities 
./profiles/en/slot_programs/hass/entities: 26: cannot open /profile.json: No such file
root@a372ee73b3f8:/# cd profiles/en
root@a372ee73b3f8:/profiles/en# sh ./slot_programs/hass/entities 
./slot_programs/hass/entities: 26: cannot open /profile.json: No such file
root@a372ee73b3f8:/profiles/en# sh slot_programs/hass/entities 
slot_programs/hass/entities: 26: cannot open /profile.json: No such file
root@a372ee73b3f8:/profiles/en# 

What if you change this line in your entities script:

profile="${RHASSPY_PROFILE_DIR}/profile.json"

to this:

profile="/profiles/en/profile.json"

By the way, have you tried making the entities script executable to solve the original issue?

chmod +x /path/to/entities

1 Like

yes, I had issues with the permissions last night so I chomd’d it. I changed the profile assignment as you described, and then had to do so for my url and auth token too. It then, and gave me a list of my (many) home assistant sensors! All of them were marked not found, I’m hoping that refers to the fact that they are new.

I then went to train from the web panel and got this error. the colors slot was not in the correct folder but I have now moved it there and restarted the pi, but I still get this error that it is not found. (“proof” here):

pi@rhasspyBase:~/.config/rhasspy/profiles $ ls en/slots/hass
color

[ERROR:2020-09-17 19:12:50,587] rhasspyserver_hermes: Missing slot $hass/colors
Traceback (most recent call last):
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/quart/app.py", line 1821, in full_dispatch_request
    result = await self.dispatch_request(request_context)
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/quart/app.py", line 1869, in dispatch_request
    return await handler(**request_.view_args)
  File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__main__.py", line 1235, in api_train
    result = await core.train()
  File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__init__.py", line 359, in train
    word_transform=word_transform,
  File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/train.py", line 106, in sentences_to_graph
    sentences, replacements=replacements, add_intent_weights=add_intent_weights
  File "/usr/lib/rhasspy/rhasspy-nlu/rhasspynlu/jsgf_graph.py", line 426, in sentences_to_graph
    expand_slots=expand_slots,
  File "/usr/lib/rhasspy/rhasspy-nlu/rhasspynlu/jsgf_graph.py", line 124, in expression_to_graph
    expand_slots=expand_slots,
  File "/usr/lib/rhasspy/rhasspy-nlu/rhasspynlu/jsgf_graph.py", line 124, in expression_to_graph
    expand_slots=expand_slots,
  File "/usr/lib/rhasspy/rhasspy-nlu/rhasspynlu/jsgf_graph.py", line 206, in expression_to_graph
    assert slot_values, f"Missing slot {slot_name}"
AssertionError: Missing slot $hass/colors
[DEBUG:2020-09-17 19:12:50,135] rhasspynlu.slots: Running program for slot hass/entities,light: ['/profiles/en/slot_programs/hass/entities', 'light']
[DEBUG:2020-09-17 19:12:49,723] rhasspynlu.slots: Running program for slot hass/entities,switch: ['/profiles/en/slot_programs/hass/entities', 'switch']
[DEBUG:2020-09-17 19:12:49,495] rhasspynlu.slots: Running program for slot rhasspy/number,0,100,1: ['/usr/lib/rhasspy/rhasspy-profile/rhasspyprofile/profiles/en/slot_programs/rhasspy/number', '0', '100', '1']
[WARNING:2020-09-17 19:12:49,494] rhasspynlu.slots: Failed to load file/program for slot hass/colors (tried: [PosixPath('/profiles/en/slots'), PosixPath('/usr/lib/rhasspy/rhasspy-profile/rhasspyprofile/profiles/en/slots')], [PosixPath('/profiles/en/slot_programs'), PosixPath('/usr/lib/rhasspy/rhasspy-profile/rhasspyprofile/profiles/en/slot_programs')])
[DEBUG:2020-09-17 19:12:49,476] rhasspynlu.ini_jsgf: Loaded ini file
[DEBUG:2020-09-17 19:12:49,471] rhasspyserver_hermes: Generating intent graph
[DEBUG:2020-09-17 19:12:49,468] rhasspyserver_hermes: Loading sentences from [PosixPath('/profiles/en/sentences.ini'), PosixPath('/profiles/en/intents/homeassistant.ini')]
[INFO:2020-09-17 19:12:49,465] rhasspyserver_hermes: Starting training

it’s color, not colors! will fix and try again…

it is looking for a slot called colors and the slot you have is called color.

Thank you! I am semi-pleased that I noticed that 1ms before you. :stuck_out_tongue:

One “final” question, do you think I’ll get burned in the future by getting rid of the gobbledygook in entities?

It’s working now! I don’t know if the intents are being handled by Home Assistant yet but I may have some other entity name things to sort out…

No, that should be fine!

Great! Thank you so very much for all of the help. If I hadn’t received it I suspect that I would have banged my head against it for many more hours before giving up entirely.

1 Like