Having a difficult time getting my service to start automatically. I can get it to start, however, after a trigger or time (not sure which yet), the service comes up with an exit code. Here’s my service file:
[Unit]
After=network.target
[Service]
Type=simple
ExecStart=/bin/bash /home/pi/433Mhz_auto.sh
User=pi
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
Here’s the error I’m getting:
pi@hassbian:/etc/systemd/system $ sudo systemctl status rtlsdr
● rtlsdr.service
Loaded: loaded (/etc/systemd/system/rtlsdr.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2018-06-17 11:50:18 EDT; 18s ago
Main PID: 11581 (code=exited, status=127)
Jun 17 11:49:34 hassbian bash[11581]: Exact sample rate is: 250000.000414 Hz
Jun 17 11:49:35 hassbian bash[11581]: [R82XX] PLL not locked!
Jun 17 11:49:35 hassbian bash[11581]: Sample rate set to 250000.
Jun 17 11:49:35 hassbian bash[11581]: Bit detection level set to 0 (Auto).
Jun 17 11:49:35 hassbian bash[11581]: Tuner gain set to Auto.
Jun 17 11:49:35 hassbian bash[11581]: Reading samples in async mode…
Jun 17 11:49:35 hassbian bash[11581]: Tuned to 344975000 Hz.
Jun 17 11:50:18 hassbian systemd[1]: rtlsdr.service: Main process exited, code=exited, status=127/n/a
Jun 17 11:50:18 hassbian systemd[1]: rtlsdr.service: Unit entered failed state.
Jun 17 11:50:18 hassbian systemd[1]: rtlsdr.service: Failed with result ‘exit-code’.
However, if I run the bash script manually:
rtl_433 -f 344975000 -F json -U | mosquitto_pub -t homeassistant/sensor/honeywell -l -V mqttv311
it gives me this:
mosquitto_pub: command not found
[R82XX] PLL not locked!
rtlsdr_demon_write_reg failed with -9
r82xx_write: i2c wr failed=-9 reg=06 len=1
It does show that PLL is not locked
EDIT: Fixed. For some reason after I had to do a reinstall of my entire system (MicroSD failure), I forgot to install mosquitto_clients:
sudo apt-get install mosquitto-clients
then, edited my .sh file, took off the -v mqttv311 and added:
-u username -P password
after mosquitto_pub. Reloaded daemons, restarted, tested, and now my doors are showing in HASS again! horray!