I built a scale to monitor propane tanks but i have two different size bottles, so i made two different sensors:
- platform: template
sensors:
propane_large:
friendly_name: "Propane Green"
unit_of_measurement: 'gal'
value_template: >-
{% set w = states('sensor.propane') | float %}
{{ ((w - 23.3) / 4.25) | round(2) }}
- platform: template
sensors:
propane_bu:
friendly_name: "Propane Blue"
unit_of_measurement: 'gal'
value_template: >-
{% set w = states('sensor.propane') | float %}
{{ ((w - 16.6) / 4.25) | round(2) }}
I want to display one or the other in Lovelace depending on which is currently on the scale, but i am lost at this point.
For posterity or whatever, here’s what i ended up doing. (The tanks are color coded as i expect different tare weights to come along if i fail to allow for them. I have red and yellow paint ready in case.):
#/config/template_sensors.yaml
# Propane
- platform: template
sensors:
propane_gn:
friendly_name: "Propane Green"
unit_of_measurement: 'gal'
value_template: >-
{% set w = states('sensor.propane') | float %}
{{ ((w - 23.3) / 4.25) | round(2) }}
- platform: template
sensors:
propane_bu:
friendly_name: "Propane Blue"
unit_of_measurement: 'gal'
value_template: >-
{% set w = states('sensor.propane') | float %}
{{ ((w - 16.6) / 4.25) | round(2) }}
# Select propane tank on scale
- platform: template
sensors:
propane_display:
friendly_name: "Propane Tank"
unit_of_measurement: 'gal'
value_template: >-
{% if is_state('input_select.tank_on_scale', 'Propane Green') %}
{{ states('sensor.propane_gn') }}
{% elif is_state('input_select.tank_on_scale', 'Propane Blue') %}
{{ states('sensor.propane_bu') }}
{% else %}
Unknown Tank
{% endif %}
#/config/input_select.yaml
propane_tank:
name: Propane Select
options:
- Propane Green
- Propane Blue
initial: Propane Blue
icon: mdi:gas-cylinder
Lovelace selection:
type: custom:select-list-card
entity: input_select.propane_tank
icon: mdi:gas-cylinder
truncate: false
show_toggle: false
scroll_to_selected: true
max_options: 2
Lovelace display:
type: entity
entity: sensor.propane_display
This stuff is not noob friendly. I mean i was proud myself for building this thing from a thrift shop scale and a ESP8266 but then Home Assistant kicked my butt and told me i am stupid. I’m still not entirely clear what i’ve done but it works.
Next i think i’ll see abt RFID tags on the tanks instead of paint, so they can select automatically…