I have a bar gauge showing my oil tank level. It is supposed to emulate roughly my watchman gauge which shows 1 to 10. However the bar gauge shows 9 instead of 10 after being filled up. I think this is because anything less than 100% full will show 9, I guess it needs to show a range, so from 1250ltr (full tank) to 1000ltr show 10, 999ltr to 850 ltr show 9 etc.
What have I got wrong below?
- platform: mqtt
name: "Oil Tank Depth"
state_topic: "rtl_433/0/144204529"
value_template: "{{ value_json.depth }}"
unit_of_measurement: cm
- platform: mqtt
name: "Oil Tank Bars"
state_topic: "rtl_433/0/144204529"
value_template: "{{ value_json.depth | int // 14 + (value_json.depth | int % 14 != 0) | int }}"
unit_of_measurement: ' '
oil_tank_bars_remaining:
friendly_name: "Oil Tank Bars Remaining"
value_template: "{{ 10 - states('sensor.oil_tank_bars') | int }}"