How to start new service with mosquitto?

Kind of off topic, but in relation to HASS.

I created a service in systemd that runs rtl_433 to scan for my doors/windows if they’re open or closed. I’m running this on my second raspberry pi.

The .service file points to a .sh file

The .sh file has this command:

/usr/bin/rtl_433 -f 344975000 -F json -U | mosquitto_pub -h [HASS IP] -u [REDACTED] -P [REDACTED] -t homeassistant/sensor/honeywell -l

My issue is that when I start the service, it seems to register the rtl_433 program but not the mosquitto part of it. If I type “ps ax”, it shows:

1054 ? Ss 0:00 /bin/bash /usr/local/bin/rtlauto
1055 ? Sl 0:01 /usr/local/bin/rtl_433 -f 344975000 -F json -U

Any tips?

Was trying to emulate your problem but realised, mosquitto_pub is not a persistent service. It simply posts a message then dies, so you will not see it in ps aux.
The way you might need to do it is to use cron or similar to call your SH file regularly.

I actually got it working. I had help from another member on the Gitter chat.

I had to set up the service as User=pi in [Service], and then make sure that the code was correct (which is what my biggest problem was). I missed one 0 in my command and it wouldn’t correctly show up.

Hi 33iguy, I have the same problem. Where exactly did yo set up as User=pi in [Service]?