Showing two Units of Measurement on one line

Hello,
I am using a LPG Tank % Level Gauge with Hall Effect device to report % left in tank using the following config:

# LPG 1410L Tank Level Monitor
  - platform: adc
    pin: GPIO36
    # raw: true
    name: "LPG Tank Level"
    update_interval: 10s

# Additional LPG Tank Variables
    unit_of_measurement: "%"
    accuracy_decimals: 1
    filters:
    - multiply: 100

Resulting in this Lovelace card:
image

Ha! It’s just coincidence that the Tank Level % & Outside Temp are the same numbers - I also have a Dallas DS18B20 sensor on this ESP32 node.

I would like the card to show as follows:

‘LPG Tank Volume / Level 319 L / 22.6 %’

Is it possible to achieve this in the .yaml code?

I look forward to reading your suggestions.

Thanks,
Steve

That’s possible with a custom frontend row: https://github.com/thomasloven/lovelace-template-entity-row
Once installed (preferably using HACS), you can add some custom yaml in the card:

...
- type: custom:template-entity-row
    entity: sensor.one_sensor
    state: LPG Tank Volume / {{ states('sensor.foo') }} L / {{ states('sensor.bar') }} %
...

I hope that gets you a start :slight_smile:.

Edit: I see this is in the ESPHome topic, yet I’d still suggest to have your ESPHome device send the individual unprocessed sensors over to HA, and have the custom view there.

2 Likes

You can also calculate the litres from the % sensor via a template

1 Like

If you create a text sensor in esphome and by using lambda the features .state

id(my_sensor).state
1 Like

@stevenma Yep simple it is all in your pin

# LPG 1410L Tank Level Monitor
  - platform: adc
    pin: GPIO36 #check your pin is correct
    # raw: true
    name: "LPG Tank Level"
    update_interval: 10s

If you are unsure just post your full code and I will have a look.

you have 2 sensors yea one for LPG and one for Temp. Temp will be on pin 36 what is your LPG sensor on?

1 Like

OK, firstly many thanks to each of you for coming back to me so promptly with your suggested solutions - but - I’m still struggling after a couple of hours! Please assume novice level knowledge / expertise!

I have searched in HACS but can’t see ‘lovelace-template-entity-row’ (or thomasloven) or how to achieve the install / integration from there.

I have also tried downloading from the Github Raw button to a file in Windows File Manager. Would I need to install Samba to transfer the file to my Raspberry Pi HA installation?

I’m now trying to install the custom frontend row from here:

Following the instructions here: Lovelace Plugins · thomasloven/hass-config Wiki · GitHub
it seems that:

git clone https://github.com/thomasloven/template-entity-row

is the best way but I cannot see where to run the git command from. There is a git button with options: git init, git commit, git push & git stash. Should I be using one of those?

I have file editor and have created a folder called www.

Any further assistance you can offer will be helpful please.

Many thanks,
Steve

Thanks Blacky,

Here is my code less the WiFi particulars:

esphome:
  name: esp-test
  platform: ESP32
  board: esp32doit-devkit-v1

dallas:
  - pin: GPIO22
    update_interval: 10s

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "xxxx"

wifi:
  ssid: "BTHomeHub2-4R2S"
  password: "xxxx"

  manual_ip:
    static_ip: 192.168.1.70
    gateway: 192.168.1.254
    subnet: 255.255.255.0
    dns1: 8.8.8.8
    dns2: 8.8.4.4

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-Test Fallback Hotspot"
    password: "xxxx"

# WiFi Signal Level
sensor:
  - platform: wifi_signal
    name: "WiFi Signal Sensor"
    update_interval: 60s

# LPG 1410L Tank Level Monitor
  - platform: adc
    pin: GPIO36
    # raw: true
    name: "LPG Tank Level"
    update_interval: 10s

# Additional LPG Tank Variables
    unit_of_measurement: "%"
    accuracy_decimals: 1
    filters:
    - multiply: 100

# Outside Temperature
  - platform: dallas
    address: 0xcf0000047c79a128
    name: "Outside Temperature"

captive_portal:

Wrt HACS, make sure you’re searching for frontend, not integrations. It’s called “template-entity-card”.

con I see your logs… only need to see data

really need to see your logs though to set calibration and check things. What sensor are you using for LPG

esphome:
  name: esp-test
  platform: ESP32
  board: esp32doit-devkit-v1

dallas:
  - pin: GPIO22

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "xxxx"

wifi:
  ssid: "BTHomeHub2-4R2S"
  password: "xxxx"

  manual_ip:
    static_ip: 192.168.1.70
    gateway: 192.168.1.254
    subnet: 255.255.255.0
    dns1: 8.8.8.8
    dns2: 8.8.4.4

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-Test Fallback Hotspot"
    password: "xxxx"

# WiFi Signal Level
sensor:
  - platform: wifi_signal
    name: "WiFi Signal Sensor"
    update_interval: 60s

# LPG 1410L Tank Level Monitor

  - platform: adc
    pin: GPIO36
    name: "LPG Tank Level"
    update_interval: 10s
    unit_of_measurement: "%"
    icon: "mdi:gas-cylinder"
    accuracy_decimals: 0
    attenuation: 11db
    filters:
###    - multiply: 0.00095238 # 3.9/4095, for attenuation 11db
    - median:
        window_size: 60
        send_every: 60
        send_first_at: 6
    - calibrate_linear:
          - 0.56 -> 0.0 
          - 2.89 -> 100.0 
    - lambda: |
        if (x < 0.0) return 0.0;
        else if (x > 100.0) return (x);
        else return (x);

# Outside Temperature
  - platform: dallas
    address: 0xcf0000047c79a128
    name: "Outside Temperature"

captive_portal:

OK, I think I’ve cracked it:
image
I used this approach:
https://github.com/thomasloven/lovelace-template-entity-row

@Blacky

I am using a Rochester 5v Hall Effect gauge which responds to the magnet on a float inside the tank. The gauge replaces the existing one and is non-invasive otherwise it wouldn’t be possible to replace a faulty gauge without emptying the tank. I use a level shifter resistor network to drop the voltage to 3.3v Of course it won’t be super accurate but it doesn’t need to be - I just need to know when we’re getting very low and plan, in due course, to try to better calibrate then measure daily / weekly etc. usage.

Thank you for the responses, in particular use of the attenuation factor - I need to better understand that and will research further when I get in to the calibration phase.

Thanks again for your responses, it’s much appreciated as I wouldn’t have got here without your help.

Regards,
Steve

No problem.

Thanks for the update