Newbie Help required please

Hi ,
I am trying to make a kind of fuel guage,
So i have a senssor that tells me when something is running
i want a way of initialising that sensor at a certain value (Ie the actual running hours of the engine)
so i have a real time running hours,
i also want a way to have a kind of trip meter , that i can reset , that i can use to calculate the fuel usage
so everyone time i fill up i can reset the hours on the trip meter , i i deally i could then have that in a list of previous hours to fuel usage etc so i can do a rough calcualtion on how much fuel i have left and the total cost

i have parts of it working like this

sensor engine_run_time:

  • platform: history_stats
    name: engine_run_time
    entity_id: binary_sensor.engine_state
    state: ‘on’
    type: time
    start: ‘{{ 0 }}’
    #start: ‘{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}’
    end: ‘{{ now() }}’

But do not know how i can set the initial value to say 550 hours
or reset when i refill the tank.

I hope this is understandable , i have tried a few different things , but just cant seem to get it

Thankyou for any help in advance

Please paste your yaml as preformatted text (</> in the toolbar). Indentations are quite important and we won’t be able to see them otherwise.

This sounds a lot like what people use for energy meters that reset every day so you get the amount per day.

I’m not sure of the best way to do that, but I have done the following in the past:

  • Have two entities that increases every minute the device is on
  • Have one of those two get reset to zero every night.
  • Have another sensor that gets set to the value of the second sensor right before it resets

That gives you total and the daily amounts.

I use this to track the number of minutes per day my heat pump is heating the house or generating hot water:


(Left: the sensors that count up every minute it is on and are reset at midnight. Right: the sensor that is set to the final value right before it resets each night.)
-David

Hi Simon, I can’t help you with your OP but I have another useful tip for you: How to help us help you - or How to ask a good question → Title