OilPal / Watchman Ultrasonic Oil Tank level reading for Home Assistant

None of those look like a mac address…

Try nmap to narrow it down.

Try page 8 of this https://www.tankmonitoring.net/wp-content/uploads/2017/08/Operating-Instructions-TEK-608A.pdf

Thanks… I found it with an internal network scanner - the vendor (against the MAC address is) - Tekelek Europe Ltd, Amazingly none of the numbers on the bottom of the device are anything like the MAC address…

P.S. I’ve changed the PI value in the code to 3.1416 (rounded from 3.14159265)… I wasn’t sure if this was a typo or what it was meant to be? and here’s the code for anyone, like me, with a horizontal cylinder (just need to change back the spelling of dimensions):

{% if tank_type.value == 2 %}
      {% set tank_volume = {
      "value": (tank_dimensions.length * (((tank_dimensions.radius * tank_dimensions.radius) * acos((tank_dimensions.radius - (tank_dimensions.height - tank_depth)) / tank_dimensions.radius)) - ((tank_dimensions.radius - (tank_dimensions.height - tank_depth)) * sqrt(2 * tank_dimensions.radius * (tank_dimensions.height - tank_depth) - ((tank_dimensions.height - tank_depth) * (tank_dimensions.height - tank_depth)))))/1000),
      } %}
2 Likes

Thanks @c0rnflake - this is so useful.

Dunraven Systems have stopped the OilPal online service, but this has given my tank monitor a new lease of life.

I think I found an error in the calculation though - I have a vertical cylindrical tank, and I think your tank area calculation was actually calculating volume, but then multiplying again by the height.

I changed the following lines - hope this helps:

        {% set tank_area = {
          "value": (3.14159 * tank_dimentions.radius * tank_dimentions.radius) / 1000,
        } %}
        {% if tank_type.value == 1 %}
          {% set tank_volume = {
            "value": (tank_dimentions.height - tank_depth) * tank_area.value,
          } %}

Keep up the good work.

1 Like

Hi @PatrickT1

From looking at your post I believe that there’s an easier step for those of use using veritcal cylindrical tanks.

The formula for volume is: pi * radius squared * height

So rather than the using the old formulas, i beleive we only need to calculate with the reading from the oilpal data, replacing the following:

        {% set tank_area = {
          "value": (3.14159 * (tank_dimensions.radius * tank_dimensions.radius) * tank_dimensions.height) / 1000,
        } %}
        {% if tank_type.value == 1 %}
          {% set tank_volume = {
            "value": (tank_dimensions.height - tank_depth) * tank_area.value / 100,
          } %}
        {% else %}

With

        {% if tank_type.value == 1 %}
          {% set tank_volume = {
            "value": (3.14159 * (tank_dimensions.radius * tank_dimensions.radius) * (tank_dimensions.height - tank_depth)) / 1000,
          } %}
        {% else %}

I’m working with my original tank values, which gives me a total volume of 1350L. If I set the oilpal modem value to 62.5 which is half the height of my tank I get a volume left value of 676L.

Yes @c0rnflake - that simplifies it.

I’m also interested in trying to calculate a usage rate to get a rough “days left” number, like OilPal used to. Don’t suppose you’ve done anything like that with yours?

I think the maths is simple, but the fly in the ointment is dealing with a big jump in the number after a tank refill.

Patrick

I haven’t done anything for any stats, but as i store all the oilpal data in mariadb it shouldn’t be hard to pull 30 days worth of data, average that to get a daily usage amount and then divide the current tanks volume by the daily used value to get a rough days left.

But as you say there’s a few factors that could mess with that, a fill or a leak.

2 Likes

@PatrickT1

I’m going to assume you’re running Influx, if so, the following should expose 2 new sensors that will give you a 30 day average usage and days left.

In your configuration.yaml (or sensors.yaml) add the following under sensor:/platform: influxdb
(you won’t need the queries: line if it’s already there)

    queries:
    - name: OilPalData 1 Hour Ago
      unit_of_measurement: Litres
      value_template: '{{ value | round(0) }}'
      group_function: last
      where: '"entity_id" = ''oilpaldata'' and time < now() - 1h'
      measurement: '"Litres"'
      field: value
      database: homeassistant    
    - name: OilPalData 30 Days Ago
      unit_of_measurement: Litres
      group_function: mean
      where: '"entity_id" = ''oilpaldata'' and time < now() - 30d'
      measurement: '"Litres"'
      field: value
      database: homeassistant
      value_template: '{{ value | round(0) }}'

under sensor:/platform: template add the following
(you probably won’t need the sensors: line as it should already be there)

    sensors:
      oilpal30dayaverageusage:
        friendly_name: "OilPal 30 Day Average Usage"
        value_template: "{{ (((states.sensor.oilpaldata_30_days_ago.state | int) - (states.sensor.oilpaldata_1_hour_ago.state | int)) / 30) | round(0) }}"
      oilpaldaysleft:
        friendly_name: "OilPal Days Left"
        value_template: "{{ ((states.sensor.oilpaldata.state | int) / (states.sensor.oilpal30dayaverageusage.state | int)) | round(0) }}"

You should now be able to add an entities card and display the new sensors

type: entities
entities:
  - entity: sensor.oilpal30dayaverageusage
    name: Average Daily Usage (Litres)
    icon: mdi:oil-level
  - entity: sensor.oilpaldaysleft
    name: Days Left
    icon: mdi:calendar-clock

While you’re at it, you may also want to edit the following, as I’ve added a quicker update to the original script to update the oilpal value from influx if there has been no reading from the modem. The value is taken from the previous hour reading.

        {% if states.sensor.oilpaldata.state == "" %}
          {{ states.sensor.OilPalData_1_Hour_Ago.state }}
        {% else %}

Let me know how you get on and if this works as expected for you

Wow. Thanks for the effort @c0rnflake . I’m not yet running Influx, but you’ve given me lots to play with there.

I know the oilpal system used to have a fill alert and a theft alert where you’d get a notification if there was a sudden change in oil level. Do you have any idea if that gets triggered by data from the sensor itself (in one of those other data fields) or if that was calculated on the Web service?

Thanks again.

Hi @PatrickT1

In the TEK608 manual there is a statement

And the webserver provides what I’m assuming is this info

But I’ve absolutely no idea how to interpet the values or how often they change. I’m pretty sure that the FL is Fill and would only be populated when the tank is filled so it wouldn’t be practical to test that.

Thanks @c0rnflake - I think I’ll have to take the sensor off the tank and play with what data I can get it to report.

Thanks again for your help.

So the above posts gave me a little motivation to tinker with the original scipt. I’m now using the Apex Charts integration and have finally settled with the below chart and information. Once I’m 100% happy that everythings working as expected I’ll post the updates needed to reproduce this.

1 Like

Hi,

I have my oilpal up and running, but can’t seem to get the right dimensions reporting back. My oil tank is a horizontal cylinder type, and the dimensions are

95 cm (w) x 165 cm (l) x 95 cm (h)

Could someone tell me what settings I need to put in, it’s a horizontal cylinder type tank

in the configuration here

        {% set tank_type = {
          "value": 1
        } %}
        {% set tank_dimentions = {
          "height": 125,
          "radius": 58.65,
          "width": 64,
          "length": 150,
        } %}

change the tank type to 2, and put your dimensions in height, width, and length. If you keep the tank type as 1 you’ll get volume calculation for a cylindrical tank with height and radius as specified.

The height you need is from the floor of the tank to the sensor, which might be slightly less than the total height, depending on the sensor mounting position on your tank.

Hope that helps.

1 Like

sorry for the late reply, that helped, ths js very much.

I was wondering how this is going now,

Also if anyone has developed anything to check optimal time to buy , I was thinking if could check qty of tank needed and trend oil pricing , it could be an a nice automation to secure oil at best price.

The updates seem to be working just fine. Famous last words eh? :slight_smile:

As for the tracking you mentioned, I’ve had something similar running for a while now also. The problem is where to scrape the info from. As I’m in the UK, i’m scraping local suppliers for mine.

1 Like

Hi everyone, just wondering is this in HACS to pull down or what’s the easiest way of installing.

I think it’s a case of adding the code to the config file and creating a card on dashboard.

Probably also need to edit code for type of tank you have. The OP also is using apex cards from HACS he mentioned.

Just going to try it out myself once get sensor working again, my sensor seems to unpair itself from the modem every few months.