Hi
I have at last worked out how to integrate the Watchman sonic as a tank had both the older watchman sonic plus bullet shape sensor (like the Apollo) and also the newer watchman sonic in a cylindrical shape. I did not have the receiver and wanted to be able to remotely monitor levels.
This may be of use if you want to do the same thing. The watchman would work with other liquids I believe.
This should work on other HA versions but I’m an RPi 3 B+ running HA in a virtual environment on an older install as that gave me functionality with various Zwave and Alexa components.
I bought one of these RF SDR (Software Defined Receiver) dongles below to receive signals and these can be used to receive various devices for integration in HA, review the rtl_433 link below and they list them. They do a lot more if using other software to receive all sorts of radio signals.
You need an aerial for decent signal (note the frequency range as best to get tailored to 433mhz)
I had one of these but you need one if using other dongles in the Pi as there isn’t room for more than one dongle in the USB ports which are close together)
An all in one kit for the popular Nooelec dongle is here, a lot seem to use these;
Amazon also seem to sell the dongle I’m using for less and with an aerial, I note that a user review commented its been used with HA so would assume the frequency range is correct on the tuner, not sure about the antenna for range though;
They run at around 250mA to 300mA max from what I can find and with my Aeon Stick Gen 5 at around 100mA and a USB speaker the 1.2A USB supply would suffice.
I worked out before anything blacklist the drivers for the dongle, create the file blacklist-rtl.conf
in the location below;
/etc/modprobe.d/blacklist-rtl.conf
or create through this on SSH
sudo nano /etc/modprobe.d/blacklist-rtl.conf
Add the content to the file as below and save it, I gave 0777 permissions (WinSCP is great for this to explore files and change permissions with a click);
blacklist dvb_usb_rtl28xxu
Then run
sudo udevadm control --reload-rules && udevadm trigger
And reboot
Next add libraries and so on;
sudo apt-get install git libtool libusb-1.0.0-dev librtlsdr-dev rtl-sdr build-essential autoconf cmake pkg-config
I didn’t need these as running mosquitto already but if your not;
sudo apt-get install mosquitto mosquitto-clients
Then clone the files from rtl_433
git clone https://github.com/merbanan/rtl_433.git
And run the following command to compile and install;
cd rtl_433/
mkdir build
cd build
cmake ..
make
sudo make install
Plugged in the Dongle.
Back in Putty / SSH I opened two instances, in one window ran this to publish topics from rtl_433 software;
rtl_433 -F json -M utc | mosquitto_pub -t home/rtl_433 -l -h <your ip of mosquitto server> -p 1883 -u <yourmosquittousername> -P <yourmosquittopassword>
In another Putty window I ran this;
mosquitto_sub -h <your ip of mosquitto server> -p 1883 -t "home/rtl_433" -u <yourmosquittousername> -P <yourmosquittopassword>
You should see the signals received over rtl_433 with compatible devices coming though onto the SSH where subscribed, in my case it picked up the watchman plus very infrequently and that may be faulty, possibly why there were two on the tank, or it updates differently, both sensors gave the same ID and models in the signal. On the newer watchman sensor if you hold a magnet to the dot on the side it closes a reed switch (you can hear it just), I had to wave the magnet over it a few times and the readings started coming through every second or so (this turns off after a few mins);
{"time" : "2020-08-31 16:29:28", "model" : "Oil-SonicSmart", "id" : 137449064, "flags" : 128, "maybetemp" : 15, "temperature_C" : 23.333, "binding_countdown" : 0, "depth_cm" : 73}
{"time" : "2020-08-31 16:29:29", "model" : "Oil-SonicSmart", "id" : 137449064, "flags" : 128, "maybetemp" : 15, "temperature_C" : 23.333, "binding_countdown" : 0, "depth_cm" : 74}
{"time" : "2020-08-31 16:29:29", "model" : "Oil-SonicSmart", "id" : 137449064, "flags" : 128, "maybetemp" : 15, "temperature_C" : 23.333, "binding_countdown" : 0, "depth_cm" : 74}
{"time" : "2020-08-31 16:29:30", "model" : "Oil-SonicSmart", "id" : 137449064, "flags" : 128, "maybetemp" : 15, "temperature_C" : 23.333, "binding_countdown" : 0, "depth_cm" : 74}
{"time" : "2020-08-31 16:29:30", "model" : "Oil-SonicSmart", "id" : 137449064, "flags" : 128, "maybetemp" : 15, "temperature_C" : 23.333, "binding_countdown" : 0, "depth_cm" : 74}
{"time" : "2020-08-31 16:29:30", "model" : "Oil-SonicSmart", "id" : 137449064, "flags" : 128, "maybetemp" : 15, "temperature_C" : 23.333, "binding_countdown" : 0, "depth_cm" : 73}
In the end I used this just to take signals from the watchman sonic on protocol 43 which is the one I needed, to do this I ran this command to start publishing to mosquitto;
rtl_433 -F json -M utc -R 43 | mosquitto_pub -t home/rtl_433 -l -h <your ip of mosquitto server> -p 1883 <yourmosquittousername> -P <yourmosquittopassword>
The full list of supported devices and information on rtl_433 is here;
https://github.com/merbanan/rtl_433
Once I knew all this was working I added sensors to detect these signals in mosquitto/HA, a bot of searching to find the calcs for 1cm of oil in a round tank and conversion from cubic centimetres, my tank is round and about 115cm fill depth. I had other tries at sensors but HA kept hanging on boot but these are working fine and updating. The oil level as if it were brimmed to the top isn’t accurate it still reads 8cm air gap when there is 0 but its more than accurate enough for me. You can pick and choose what reading were needed.
#Oil Tank Sensor
- platform: mqtt
name: "Oil Tank Air at Top"
state_topic: "home/rtl_433"
value_template: "{{ value_json.depth_cm }}"
unit_of_measurement: 'cm'
- platform: mqtt
name: "Oil Percent"
state_topic: "home/rtl_433"
#tank is 120cm diameter and 115cm high so approx 11.31 Litres per 1cm of fill if search online for calculator
value_template: "{{ 115 - (value_json.depth_cm) * 11.31 / 1300 * 100 | int }}"
unit_of_measurement: '%'
- platform: mqtt
name: "Oil Litres"
state_topic: "home/rtl_433"
value_template: "{{ (115 - (value_json.depth_cm)) * 11.31 | int }}"
unit_of_measurement: 'Litres'
- platform: mqtt
name: "Oil Depth Left"
state_topic: "home/rtl_433"
value_template: "{{ 115 - (value_json.depth_cm) | int }}"
unit_of_measurement: 'cm'
The json parameter above pulls the value though from that topic.
I then added a script to start the sensor reading and ran this from HA to turn readings on (I found the cron jobs and supervisor methods unreliable) and will add an automation on boot to run this automatically if needed;
oil_level:
alias: oil level on
sequence:
- service: shell_command.oil_level
Then the shell command to run the command used in Putty to start the publishing readings;
oil_level: sudo rtl_433 -F json -M utc -R 43 | mosquitto_pub -t home/rtl_433 -l -h <your mosquitto server ip> -p <your mosquitto port default is 1883> -u <your mosquitto user> -P <you mosquitto password>
Note- the -R 43
is only needed for the oil sensor sonic devices
Then added all entities on the groups.yaml, scripts.yaml, shell.yaml, sensors.yaml
(how I have my configuration set up) or through the configure UI interface on HA.
I also tried the method below to publish and subscribe to topics which add the model and device ID but it had a few glitches with the sensor but may work for you, I don’t intend on listening to anything but my watchman but may be useful for multiple devices;
Turn on rtl_433 to mosquitto, publish and then subscribe in another window;
sudo rtl_433 -F "mqtt://<your ip of mosquitto server>:<your port of server default is1883>,retain=0,user=<your username>,pass=<your password>,devices=home/rtl_433[/model][/id]"
mosquitto_sub -h 192.168.1.199 -p 1883 -t "home/rtl_433/#" -u <your username> -P <your password>
The mosquitto log (see below for full logging in this file) showed;
1598889411: Received PUBLISH from rtl_433-5758ffff (d0, q0, r0, m0, 'home/rtl_433/Oil-SonicSmart/137449064/time', ... (19 bytes))
1598889411: Received PUBLISH from rtl_433-5758ffff (d0, q0, r0, m0, ''home/rtl_433/Oil-SonicSmart/137449064/id', ... (9 bytes))
1598889411: Received PUBLISH from rtl_433-5758ffff (d0, q0, r0, m0, ''home/rtl_433/Oil-SonicSmart/137449064/flags', ... (3 bytes))
1598889411: Received PUBLISH from rtl_433-5758ffff (d0, q0, r0, m0, ''home/rtl_433/Oil-SonicSmart/137449064/maybetemp', ... (2 bytes))
1598889411: Received PUBLISH from rtl_433-5758ffff (d0, q0, r0, m0, ''home/rtl_433/Oil-SonicSmart/137449064/temperature_C', ... (8 bytes))
1598889411: Received PUBLISH from rtl_433-5758ffff (d0, q0, r0, m0, ''home/rtl_433/Oil-SonicSmart/137449064/binding_countdown', ... (1 bytes))
1598889411: Received PUBLISH from rtl_433-5758ffff (d0, q0, r0, m0, ''home/rtl_433/Oil-SonicSmart/137449064/depth_cm', ... (2 bytes))
And would need to subscribe to this topic in sensors for the depth;
home/rtl_433/Oil-SonicSmart/137449064/depth_cm
I found this useful to monitor mosquito / mqtt log by turning on full logging, note that the file size can get a lot bigger so best to turn off once any debugging complete.
Adjust this
/etc/mosquito/mosquito.conf
Add log_type all
and save file
Log can be found at var/log/mosquito/mosquito.log
All these links I found helpful;
https://github.com/merbanan/rtl_433
https://www.hagensieker.com/wordpress/2019/01/15/433-mhz-signals-and-shit/
http://blog.techreverence.com/433mhz-sensor-in-home-assistant.html
https://sdr-setup-notes.readthedocs.io/en/latest/dev_rtlsdr.html
https://www.hagensieker.com/wordpress/2019/03/06/how-to-keep-rtl_433-alive-for-your-home-automation-using-supervisor/
https://github.com/mverleun/RTL433-to-mqtt
https://community.home-assistant.io/t/bar-gauge-incorrect-reading/157194
http://blog.techreverence.com/autostart-rtl_433-with-supervisor.html
https://community.home-assistant.io/t/calculations-with-sensor-values/114289/23
I found crashing an issue, sensors were problematic, information was not specific to my use and so thought it helpful to put the hours of work all in one place, enjoy.