OilPal / Watchman Ultrasonic Oil Tank level reading for Home Assistant

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
6 Likes

This is what I love about home assistant and it’s community.

Hi , I was wondering do you know the default credentials to access the TEK608 webserver?

Found it on my network , but seems it’s password protected.

@mrmercedes84 Sorry I never knew the default login or password for the TEK608 webserver. I’m scrapping the tank stats from the only page on the webserver that isn’t password protected.

Hi,

Can i confirm that this is still woking and function for you? I am total Newbee, came from the Smartthings platform and starting to transfer my Smarthome enviroment. Oilpal was always something i was hoping to get on for a visual display in the Kitchen so this got me excited.

I Added the code to the Config file and creasted the card but seem to be stuck on Awaiting data. I know the Oilpal only reads once a day but i wanted to ensure i didnt have false hope

This is what the ip address in the config file brings:

image

@davy932 yup, i can confirm that this still works, still using it without issues. It does take a while to get a reading.

image

Thanks for the reply.

All looks same from the OilPal point of view. Just I don’t have any data in the column we’re looking for. You said it takes a while- couple of days?

@davy932 it shouldn’t take more than a couple of hours to catch your first reading. the oilpal modem gets a reading every hour or so but the reading is cleared after a few minutes, no idea why. You could try changing the 60 minute scan interval in the script to something lower.

I too have implemented your solution, so thank you. But I also get
Waiting for first reading
And have been for two days.
Any tips on getting this working?
What do the figures on the diag/htm mean?

I also get “This entity does not have a unique ID, therefore it’s settings cannot be managed from the UI”
What am I doing wrong?

Thanks

That unique ID message means you configured via configuration.yaml. It is not an error.

Frustration time.
I had this working, sort of.
For three days I got - Waiting for first reading then it changed to 20 litres more than my tank holds. I realised the dimensions of the tank in the code were not the same as for my actual tank, so I changed them. I swear I only altered the dimensions, nothing more or less
.
I also updated Hassio to the latest version. 0.113
now I get the following error:
‘’’’’

Log Details (ERROR)

Logger: homeassistant.components.hassio
Source: components/hassio/init.py:326
Integration: Hass.io (documentation, [issues]
First occurred: 9:44:08 PM (2 occurrences)
Last logged: 9:46:35 PM

Invalid config for [sensor.scrape]: [device_tracker] is an invalid option for [sensor.scrape]. Check: sensor.scrape->device_tracker. (See ?, line ?).

The card now shows: entry not available sensor.oilpaldata

I don’t know enough about Hassio, yaml or coding to be able to fix this myself. Can anybody help, please?

Hi, I’ve been on HA for just over a week (previously on IFTTT) and loving it… We also have Oil Pal, so it was a real bonus seeing your post. The problem that I’ve got is that we’ve got probably 100+ IP addresses on our network and whilst I’ve tried the 'http://192.168.0.x/diag.htm on Safari I can’t find the device. I’ve just grabbed a picture of the underside of the IP modem, which contains lots of MAC address looking numbers, but none correlate to any of the MAC addresses that I can see… of course I may just be tired and emotional and blindly missing it! Any suggestions?

@brianacox you’re going to have to log into your router and check for the IP address there. I’ve no experience of mac’s so I can’t recommend a mac tool to show network IPs.

I’m in the router and as mentioned have hundreds of IP addresses attached to it… some are obvious what they are, e.g. sky box, iMac etc, but loads aren’t. Normally the wait to identify the IP address for a given device is to look at the underside or back of the device to find the MAC address… and then in the router table you can see which IP address it relates to. (When I say MAC, I don’t mean Apple Mac but the media access control address - MAC_address

To ask the question another way, how did you discover the correct IP address on your set up? did you go through with one seeing if each one worked, e.g. 192.168.88.1/diag.htm, http://192.168.88.2/diag.htm etc. or did you find a way of locating it via something on the Oilpal modem?

Turn the oilpal off. Turn it on and watch your dhcp logs to see what ip it gets.

Alternatively, to find a device with a mac address with 31:ba run

arp -l | grep 31:ba

Thanks Nick… I will venture out in the morning and turn it off/on…. It might take a bit more work as I’ve bound mac addresses to IP addresses, but I can downloan the bind (refreshed) between I turn it off and afterwards.

When you say 31:ba d0…. Are you saying that the oil pal modem has 31:ba d0 as part of its Mac address? I did just scan through but couldn’t see anything that stood out like this at all….

no the 31:ba is just an example. Use the mac that you read off the bottom of the oil pal.

Another thing to do would be chack open ports on all your ip addresses. Looks like you are on 192.168.88.0 network. If you run

nmap 192.168.88.0/24 -PN -p 80 -n

That will tell you which hosts on your network are running something on port 80.

That’s the problem - there are a number of MAC looking addresses on the base of the Oilpal. I seem to recall that the first two digits signify the supplier… or have I dreamt this?! I was hoping someone might know oilpal’s? I’m on a 192.168.0.x network.