I only hesitate to share because I know just enough about systemd to be dangerous. One should NOT use these as a template but as additional information to learn from. The rtl_433 file. There is additional lines because I use https://pushover.net to monitor things related to WeeWX # systemd unit configuration file for rtl_433 #
[Unit] Description=rtl_433 service Documentation=https://github.com/merbanan/rtl_433/README.md # StartLimitIntervalSec=5 After=syslog.target network.target StartLimitIntervalSec=500 StartLimitBurst=5 [Service] Environment=UUID=replace_me Restart=on-failure RestartSec=5s # Type=exec #ExecStart=/usr/local/bin/rtl_433 -M utc -F json -F mqtt://localhost:1883,retain=0,devices=rtl_433[/host]/devices[/type][/model][/subtype][/channel][/id] ExecStart=/usr/local/bin/rtl_433 -M utc -F mqtt://localhost:1883,retain=0,devices=rtl_433[/host]/devices[/type][/model][/subtype][/channel][/id] ## ExecStartPre runs before, the "-" in the beginning is to let systemd continue even on non-zero exit ExecStartPre=-/bin/bash -c "curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/$UUID" ## ExecStopPost runs after, no matter if ExecStart was success or not. The "-" in the beginning is like ExecStartPre ExecStopPost=-/bin/bash -c "curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/$UUID/fail" # Restart script if stopped #Restart=always # Wait 30s before restart #RestartSec=30s # Tag things in the log # View with: sudo journalctl -f -u rtl_433 -o cat #SyslogIdentifier=rtl_433 # NOTE: only works in systemd v236+ # Debain "stretch" includes v232, "buster" includes v239 # Note also the user must be able to create the file and logrotate must be amended to rote the log. StandardOutput=file:/var/log/rtl_433.log StandardError=file:/var/log/rtl_433.log #StandardOutput=syslog #StandardOutput=null #StandardError=syslog # To run as a non-root user, uncomment and set username and group here: #User=pi #Group=pi [Install] WantedBy=multi-user.target My WeeWX file. I hacked this up in 4.x. I would think 5.x would work just fine. # source bellrichm-configs weewx/multi/systemd [Unit] Description=WeeWX gather %i data Documentation=https://weewx.com/docs Requires=time-sync.target After=time-sync.target RequiresMountsFor=/home [Service] ExecStart=/home/weewx/bin/weewxd --log-label=weewx-%i /home/weewx/%i.conf StandardOutput=null # To run as a non-root user, uncomment and set username and group here: User=pi Group=pi [Install] WantedBy=multi-user.target Yup MQTTSubscribe runs as either driver or service. Nothing special to running as a driver. rich On Wednesday 6 March 2024 at 17:20:42 UTC-5 vince wrote: > Nice. Lets see your system service file(s) to match ! > > How would you use that way as a driver and not even need to user weewx-sdr > ? Not remembering if MQTT subscribe can run as a driver. I just run it as > an extension. > > On Wednesday, March 6, 2024 at 2:06:27 PM UTC-8 bell...@gmail.com wrote: > >> Vince, >> Nice write up. >> Begin shameless plug… >> Since I am heavily invested in reading things from MQTT, I just run >> rtl_433 as a separate service and subscribe to the topic. I did this >> primarily to get the data in a service and secondarily to get sensors that >> were not ’mapped’. >> The service invocation, ‘ExecStart=/usr/local/bin/rtl_433 -M utc -F >> mqtt://localhost:1883,retain=0,devices=rtl_433[/host]/devices[/type][/model][/subtype][/channel][/id]’ >> And one topic config looks like this >> [[topics]] >> ignore = True >> [[[message]]] type = individual # Upright freezer (basement) >> [[[rtl_433/weather-data/devices/Acurite-606TX/77/temperature_C]]] ignore = >> False unit_system = METRIC name = extraTemp8 >> >> It may seem more complicated, but since I was invested in MQTT, it >> actually simplified it. This was primarily because I could treat rtl_433 as >> a separate service >> >> End plug >> >> On Wednesday 6 March 2024 at 16:14:25 UTC-5 vince wrote: >> >>> In working with another weewx user to help him gets his SDR station >>> online, it was clear that lots of people (like me) have some problems >>> really understanding some of the rtl-433 and sdr documentation that is out >>> there. >>> >>> After working through it end-to-end a few times on both ubuntu and on a >>> raspberry pi, I wrote up the whole setup as a howto with examples mainly >>> for future-me but I thought it might be of general interest. At worst a >>> google search should find it for future folks trying to battle SDR into >>> submission :-) >>> >>> The howto and a small github repo with a patched/enhanced fork of the >>> SDR driver is at https://github.com/vinceskahan/sdr-howto if you have >>> interest. Start with the toplevel readme file then read the howto.txt file >>> for how I got it working here. >>> >>> -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/03c4bcb8-f125-4d44-b52a-08baefc958d3n%40googlegroups.com.