Hello, from my OBD I am getting fuel tank volume in %. How do I create sensor that shows remaining time to empty based average consumption in last 10 minutes? Lets say the sensor is called sensor.obd_fuel_level and it shows something like 18.12345%
I understand I need to create differential sensor with change in last 10 minutes, I can do that. But how then I calculate remaining time from volume and speed of change? Can it be all combined into definition of differential sensor or do I need to create yet another sensor with formula?
the formula would be time_to_empty = 10 * volumet / (volumet-10min - volumet)
THE ANSWER:
sensor obd_tank_diff:
- platform: derivative
source: sensor.obd_fuel_level
unit: "%/min"
name: OBD Fuel tank change per minute
round: 2
unit_time: min
time_window: "00:10:00"
template:
- sensor:
- name: OBD Time to empty tank
unit_of_measurement: "min"
state: >
{% set obdfl = states('sensor.obd_fuel_level') | float %}
{% set obdflspd = states('sensor.obd_fuel_tank_change_per_minute') | float %}
{{ (obdfl / obdflspd) | round(1, default=0) }}
Thanks for advice. As I said, I am yaml amateur. I develop software for 30 years yet the yaml construction of templates is a great secret for me…
It really drives me crazy. Why this statement {% (states('sensor.obd_fuel_level')) %} produces error “TemplateSyntaxError: tag name expected” and not number?