Issue with setting up service
loocd opened this issue · 5 comments
Hi all,
I've gone through this guide and am able to manually run the script and send voice commands successfully. However, as soon as I close the command line this is over - plus, if the Pi ever gets powered down I'd have to start the script again.
So I tried setting it up as a service, as described here. Unfortunately, after opening the log I keep seeing this error:
pascal@raspberrypi:~/homeassistant-satellite $ journalctl -u homeassistant-satellite.service -f
Nov 23 11:26:55 raspberrypi run[3324]: raise exceptions.IncompleteReadError(incomplete, n)
Nov 23 11:26:55 raspberrypi run[3324]: asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 960 expected bytes
Nov 23 11:26:55 raspberrypi run[3323]: Traceback (most recent call last):
Nov 23 11:26:55 raspberrypi run[3323]: File "/home/pascal/homeassistant-satellite/script/run", line 13, in <module>
Nov 23 11:26:55 raspberrypi run[3323]: subprocess.check_call(
Nov 23 11:26:55 raspberrypi run[3323]: File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
Nov 23 11:26:55 raspberrypi run[3323]: raise CalledProcessError(retcode, cmd)
Nov 23 11:26:55 raspberrypi run[3323]: subprocess.CalledProcessError: Command '['/home/pascal/homeassistant-satellite/.venv/bin/python3', '-m', 'homeassistant_satellite', '--host', 'REDACTED-IP', '--token', 'REDACTED-Token', '--awake-sound', 'sounds/awake.wav', '--done-sound', 'sounds/done.wav']' returned non-zero exit status 255.
Nov 23 11:26:55 raspberrypi systemd[1]: homeassistant-satellite.service: Main process exited, code=exited, status=1/FAILURE
Nov 23 11:26:55 raspberrypi systemd[1]: homeassistant-satellite.service: Failed with result 'exit-code'.
Nov 23 11:26:56 raspberrypi systemd[1]: homeassistant-satellite.service: Scheduled restart job, restart counter is at 4.
Nov 23 11:26:56 raspberrypi systemd[1]: Stopped homeassistant-satellite.service - Home Assistant Satellite.
Nov 23 11:26:56 raspberrypi systemd[1]: Started homeassistant-satellite.service - Home Assistant Satellite.
Nov 23 11:26:57 raspberrypi run[3330]: INFO:root:Authenticated to Home Assistant version 2023.11.2
Nov 23 11:26:57 raspberrypi run[3332]: ALSA lib pcm_asym.c:105:(_snd_pcm_asym_open) capture slave is not defined
Nov 23 11:26:57 raspberrypi run[3332]: arecord: main:831: audio open error: Invalid argument
Nov 23 11:26:57 raspberrypi run[3330]: ERROR:root:Unexpected error in mic_task_entry
Nov 23 11:26:57 raspberrypi run[3330]: Traceback (most recent call last):
Nov 23 11:26:57 raspberrypi run[3330]: File "/home/pascal/homeassistant-satellite/homeassistant_satellite/mic_process.py", line 361, in mic_task_entry
Nov 23 11:26:57 raspberrypi run[3330]: async for ts_chunk in mic_stream:
Nov 23 11:26:57 raspberrypi run[3330]: File "/home/pascal/homeassistant-satellite/homeassistant_satellite/mic_process.py", line 200, in _skip_mic_state_pipe
Nov 23 11:26:57 raspberrypi run[3330]: async for ts_chunk in mic_input:
Nov 23 11:26:57 raspberrypi run[3330]: File "/home/pascal/homeassistant-satellite/homeassistant_satellite/mic_process.py", line 200, in _skip_mic_state_pipe
Nov 23 11:26:57 raspberrypi run[3330]: async for ts_chunk in mic_input:
Nov 23 11:26:57 raspberrypi run[3330]: File "/home/pascal/homeassistant-satellite/homeassistant_satellite/mic_process.py", line 52, in __ensure_running_pipe
Nov 23 11:26:57 raspberrypi run[3330]: async for ts_chunk in mic_input:
Nov 23 11:26:57 raspberrypi run[3330]: File "/home/pascal/homeassistant-satellite/homeassistant_satellite/mic_record.py", line 101, in record_subprocess
Nov 23 11:26:57 raspberrypi run[3330]: chunk = await proc.stdout.readexactly(bytes_per_chunk)
Nov 23 11:26:57 raspberrypi run[3330]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Nov 23 11:26:57 raspberrypi run[3330]: File "/usr/lib/python3.11/asyncio/streams.py", line 726, in readexactly
Nov 23 11:26:57 raspberrypi run[3330]: raise exceptions.IncompleteReadError(incomplete, n)
Nov 23 11:26:57 raspberrypi run[3330]: asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 960 expected bytes
Nov 23 11:26:57 raspberrypi run[3329]: Traceback (most recent call last):
Nov 23 11:26:57 raspberrypi run[3329]: File "/home/pascal/homeassistant-satellite/script/run", line 13, in <module>
Nov 23 11:26:57 raspberrypi run[3329]: subprocess.check_call(
Nov 23 11:26:57 raspberrypi run[3329]: File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
Nov 23 11:26:57 raspberrypi run[3329]: raise CalledProcessError(retcode, cmd)
Nov 23 11:26:57 raspberrypi run[3329]: subprocess.CalledProcessError: Command '['/home/pascal/homeassistant-satellite/.venv/bin/python3', '-m', 'homeassistant_satellite', '--host', 'REDACTED-IP', '--token', 'REDACTED-Token, '--awake-sound', 'sounds/awake.wav', '--done-sound', 'sounds/done.wav']' returned non-zero exit status 255.
Nov 23 11:26:57 raspberrypi systemd[1]: homeassistant-satellite.service: Main process exited, code=exited, status=1/FAILURE
Nov 23 11:26:57 raspberrypi systemd[1]: homeassistant-satellite.service: Failed with result 'exit-code'.
Nov 23 11:26:58 raspberrypi systemd[1]: homeassistant-satellite.service: Scheduled restart job, restart counter is at 5.
Nov 23 11:26:58 raspberrypi systemd[1]: Stopped homeassistant-satellite.service - Home Assistant Satellite.
Nov 23 11:26:58 raspberrypi systemd[1]: homeassistant-satellite.service: Start request repeated too quickly.
Nov 23 11:26:58 raspberrypi systemd[1]: homeassistant-satellite.service: Failed with result 'exit-code'.
Nov 23 11:26:58 raspberrypi systemd[1]: Failed to start homeassistant-satellite.service - Home Assistant Satellite.
I followed the guide to the dot (at least I think so) and my file looks like this:
[Unit]
Description=Home Assistant Satellite
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
ExecStart=/home/pascal/homeassistant-satellite/script/run --host REDACTED-IP --token REDACTED-Token --awake-sound sounds/awake.wav --done-sound sounds/done.wav
WorkingDirectory=/home/pascal/homeassistant-satellite
Restart=always
RestartSec=1
[Install]
WantedBy=default.target
I have also noticed that when saving the file, it adds a number at the end of homeassistant-satellite.service
, but I'm assuming that's normal due to read/write issues?
I ran into an issue getting this up and running. I see the same error in your logs:
Nov 23 11:26:57 raspberrypi run[3332]: ALSA lib pcm_asym.c:105:(_snd_pcm_asym_open) capture slave is not defined
Nov 23 11:26:57 raspberrypi run[3332]: arecord: main:831: audio open error: Invalid argument
Nov 23 11:26:57 raspberrypi run[3330]: ERROR:root:Unexpected error in mic_task_entry
I was getting this error when it couldn't use whatever default mic of the system was. I needed to specify the mic input and speaker output manually:
https://github.com/synesthesiam/homeassistant-satellite#change-microphonespeaker
Thanks @cmsimike for sharing your experience - I'll give that a try!
using arecord -L
I get the following entry (among others)
Unfortunately, I'm not entirely sure what exactly I should put into the --mic-device plughw:...
command - can you give me some pointers?
Here's my outputs and my run command.
pi@pi005:~ $ arecord -L
null
Discard all samples (playback) or generate zero samples (capture)
playback
ac108
default
output
sysdefault:CARD=seeed4micvoicec
seeed-4mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
Default Audio Device
dmix:CARD=seeed4micvoicec,DEV=0
seeed-4mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
Direct sample mixing device
dsnoop:CARD=seeed4micvoicec,DEV=0
seeed-4mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
Direct sample snooping device
hw:CARD=seeed4micvoicec,DEV=0
seeed-4mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
Direct hardware device without any conversions
plughw:CARD=seeed4micvoicec,DEV=0
seeed-4mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
Hardware device with all software conversions
pi@pi005:~ $ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
playback
ac108
default
output
sysdefault:CARD=Headphones
bcm2835 Headphones, bcm2835 Headphones
Default Audio Device
dmix:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct sample mixing device
dsnoop:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct sample snooping device
hw:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct hardware device without any conversions
plughw:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Hardware device with all software conversions
With the above, I run it like this:
script/run --mic-device plughw:CARD=seeed4micvoicec,DEV=0 --snd-device plughw:CARD=Headphones,DEV=0
I think anything with the plughw
prefix should work per the docs:
Run arecord -L to list available input devices. Pick devices that start with plughw: because they will perform software audio conversions. Use --mic-device plughw:... to use a specific input device.
Run aplay -L to list available output devices. Pick devices that start with plughw: because they will perform software audio conversions. Use --snd-device plughw:... to use a specific output device.
I've just tried it and the errors have in fact gotten fewer, but I'm still getting an error after accessing the logs:
pascal@raspberrypi:~ $ journalctl -u homeassistant-satellite.service -f
Nov 24 21:57:41 raspberrypi systemd[1]: homeassistant-satellite.service: Main process exited, code=exited, status=1/FAILURE
Nov 24 21:57:41 raspberrypi systemd[1]: homeassistant-satellite.service: Failed with result 'exit-code'.
Nov 24 21:57:43 raspberrypi systemd[1]: homeassistant-satellite.service: Scheduled restart job, restart counter is at 14.
Nov 24 21:57:43 raspberrypi systemd[1]: Stopped homeassistant-satellite.service - Home Assistant Satellite.
Nov 24 21:57:43 raspberrypi systemd[1]: homeassistant-satellite.service: Start request repeated too quickly.
Nov 24 21:57:43 raspberrypi systemd[1]: homeassistant-satellite.service: Failed with result 'exit-code'.
Nov 24 21:57:43 raspberrypi systemd[1]: Failed to start homeassistant-satellite.service - Home Assistant Satellite.
Nov 25 16:18:25 raspberrypi systemd[1]: Started homeassistant-satellite.service - Home Assistant Satellite.
Nov 25 16:18:26 raspberrypi run[3169]: INFO:root:Authenticated to Home Assistant version 2023.11.3
Nov 25 16:18:26 raspberrypi run[3171]: Recording raw data 'stdin' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
But it seems to work despite these errors