This is my first “project” that I’m happy enough with to share with the HA community.
For years I used the Fibaro Home Center 2 with various ZWave devices from Aeotec, Greenwave and Fibaro. Recently I decided to move away from the HC2 and look at other home automation systems.
I landed with Home Assistant around 6 weeks ago and have been extremely happy with it since. I’m running my HA on a RPi 3b+.
Anyhow, around December of 2018 I purchased an OilPal system which is basically a Watchman ultrasonic oil sensor and a modem that sends the sensors data back to OilPal. I’m aware that these are possibly generic systems as they are sold by various companies.
I wanted to include my oil tank level in HA.
My first attempt at this was to clone the imap component and create a custom component from is, which checked for mail up to 48 hours old. It seems the original component only checks from when HA is started.
This was working well but the issue was that OilPal only send emails warning of low tank levels when your oil level gets below 50%. This wasn’t ideal.
I then looked at a few Youtube videos which show the Watchman ultrasonic sensor was communicating via radio and you could read that with a USB SDR dongle. I purchased a £10 USB dongle and was half way along the road of using the SDR dongle to pull the data the Watchman was sending using a combination of SDR, Node Red and MQTT.
At this stage I had mentioned I was working on this project on a Facebook group and was contacted by Stig. Stig pointed out that the OilPal modem had a webserver running on it. I wasn’t aware of this or would I have considered looking. So without Stig pointing me this out to me I’d probably have spent days working out SDR etc. etc. So many thanks to Stig.
So I’ve mentioned the OilPal modem, yup, there’s a webserver and yup, it holds the sensor data from the Watchman. This now sent me down another road and finally to the end of this project.
Below is the configuration I’m using to scrape the data from the modem. My tank is a vertical cylinder. I calculated it to be around 1350 Litres in volume. The tank_dimensions are in CM.
Please keep in mind I’m a complete newbie to HA, YAML etc. I’m sure there is a more elegant way to do this, I’d love to hear alternatives, optimised code, etc.
edit: 30th April 2019. I’ve fixed a bug where the oilpal modem returns “No Data”. I’ve also updated the tank types to take into account rectangle tanks, set the tank_type value.
edit: 2nd May 2019. I’ve now fixed a bug when “No Data” was received and the card would report “Unknown”. The value from the modems last response is now used. Scan interval has been reduced to 60 seconds per read to quicker update from “Waiting for first reading”.
# Sensors
sensor:
# scrape oilpal tank level from modem. tank_depth is the amount of air between the bottom of the sensor to the oil level.
# the ip address in the resource: statement is the ip of your oilpal modem.
# tank_type 1 is cylindar, tank_type 2 is a rectangle
- platform: scrape
resource: http://192.168.88.115/diag.htm
name: OilPalData
select: 'table:nth-of-type(2) td:nth-of-type(5)'
unit_of_measurement: 'Litres'
value_template: >-
{% set modem_values = value.split(' ') %}
{% set tank_temp = modem_values[1] %}
{% if tank_temp != "Data" %}
{% set tank_depth = modem_values[0] | int %}
{% set tank_type = {
"value": 1
} %}
{% set tank_dimentions = {
"height": 125,
"radius": 58.65,
"width": 64,
"length": 150,
} %}
{% set tank_area = {
"value": (3.1472 * (tank_dimentions.radius * tank_dimentions.radius) * tank_dimentions.height) / 1000,
} %}
{% if tank_type.value == 1 %}
{% set tank_volume = {
"value": (tank_dimentions.height - tank_depth) * tank_area.value / 100,
} %}
{% else %}
{% set tank_volume = {
"value": (tank_dimentions.height - tank_depth) * tank_dimentions.length * tank_dimentions.width / 1000,
} %}
{% endif %}
{{ tank_volume.value | round (0) }}
{% else %}
{% if states.sensor.oilpaldata.state == "" %}
Waiting for first reading
{% else %}
{{ states.sensor.oilpaldata.state }}
{% endif %}
{% endif %}
scan_interval: 60
Below is my card configuration
entity: sensor.oilpaldata
graph: line
hours_to_show: 720
icon: 'mdi:oil'
name: OilPal
type: sensor
unit: Litres