Add tank percentage to Mopeka Integration

Currently, the Mopeka propane tank level sensor only shows the level in inches of propane. The native app also shows percentage. Feature request to add percentage to the HA Mopeka integration.

This would be very helpful, I tried to write a template sensor with no luck.

The ESPHome integration for these sensors includes level-to-percentage conversions for 20, 30, and 40 lb vertical tanks:

esphome/components/mopeka_pro_check/sensor.py

Converted from mm to inches, a standard 20 lb (5 gal) vertical tank goes from 1.5 in (empty) to 10.0 in (full). So a suitable conversion template would be something like this:

      - name: Tank 1 Percentage
        state: "{{ ((states('sensor.tank_1_tank_level') | float(1.5) - 1.5) * 11.77) | round(0) }}"
        unit_of_measurement: "%"
        icon: mdi:propane-tank

Works fine for me so far - the value matches what I see in the Mopeka smartphone app.

2 Likes

Is it possible to get a copy of the full template. Fighting with this for days and just canā€™t seem to get if correct. Thanks MikeyM

In my configuration.yaml, just replace sensor.propane_tank_level with the proper entity.

template:
  - sensor:
      - name: "Propane Percentage"
        state: "{{ ((states('sensor.propane_tank_level') | float(1.5) - 1.5) * 11.77) | round(0) }}"
        unit_of_measurement: "%"
        icon: mdi:propane-tank

Thank you! Worked perfectly. The problem I had was the formatting of the template. Thanks again!

For a 100lb tank, values in inches.

template:
  - sensor:
        gas_level_percent:
          friendly_name: Gas Level Percent
          value_template: "{{ ((states('sensor.gas_tank_level') | float(2.0) - 2.0) * 2.7) | round(0) }}"
          unit_of_measurement: "%"

Does anyone know the empty / full levels for a 500 gal tank, or 320 gal? I suppose I can calibrate against analog gauge before / after tank is filled (e.g., going from 25% full to 80 % full).

Would be useful if someone could figure out a more generic volume calculation, based on tank dimensions, like the Mopeka app does.

But meanwhile the above template YAML should work for me, after calibration to my analog gauge readings; thanks much.

I canā€™t seem to get this to work in my config.yaml

Replace ā€˜sensor.propane_tank_levelā€™ with the proper entity (the name you use) and use ā€œinchesā€ in mopeka integration unit of measurement.

And for those in the metric hemisphere, this worked to match my Mopeka app with a 9kg propane tank.

- platform: template
  sensors:
    propane_percentage:
      friendly_name: "Propane Percentage"
      unique_id: propane_percentage
      value_template: "{{ ((states('sensor.pro_check_3c2e_tank_level') | float(1.5) - 1.5) * 0.22) | round(0) }}"
      unit_of_measurement: "%"

I made a template and put it in my configuration.yaml file, but I canā€™t for the life of me figure out how to use that value in a lovelace card. Could you post how you did that?

It turns out the latest HA update (2023.9.0) makes it available natively.

So I failed the intelligence test ā€¦

I pasted the above in configuration.yanly with my own tank entity ā€¦ but getting an error below.

Any ideas please as I am using the latest 2023.9.1

Donā€™t put it in configuration.yaml. Put it in your sensors.yaml file if you have one. The code you pasted does not tell HA itā€™s a sensor if you put it in configuration.yaml. If you want to put it there, youā€™d have to preface it with sensor like so.

# Example configuration.yaml entry
sensor:
  - platform: template
1 Like

Can you elaborate? Iā€™m still seeing the native integration sensor in mm.

Thank you so much for the assistance !
I put the ammended configuration.yaml entry in and it works great,

I also have a 9kg tank ā€¦ but my reading in HASS are different to the Mopeka app ā€¦ Iā€™ll try and do some further digging.

Thank you again !

Jason

Youā€™re welcome. Just tweak this value to match the app

* 0.22)
1 Like

Just magnificent @xbmcnut !!!

You have made this a great weekend for me !

All is working perfectly !

Thank you again for your super fast and kind help !

Jason

Iā€™m trying to get this working on a 100lb ASME horizontal mount tank. Any tips?