I’m running a portable gas fire that is fuelled by liquid bottled gas. Currently I have to weigh the bottle and compare with the tare weight to see how much gas is left in the bottle. I have an idea how long the bottle will last vs the fire being turned on - a bottle generally lasts 4 weeks with current outside temperatures. What I plan to do is put a thermometer in a safe location on the fire that will reach a threshold when the fire is turned on which should give me a rough estimate on how long the fire has run and give me a warning to order a new bottle - which has a three day or more delivery time. I suspect I’d need to use the history sensor for this but I’m not sure how to go about it it programmatically. I have a lot of experience writing automations by hand but am struggling to get my head around using the history sensor.
Figured it out :
sensor:
- platform: template
sensors:
fire_is_running:
friendly_name: "fire is running"
value_template: "{{ states('sensor.fire_temperature')| float > 22 }}"
gas_low:
friendly_name: "Gas is low"
value_template: "{{ states('sensor.fire_running_for')| float > 60 }}"
- platform: history_stats
name: fire_running_for
entity_id: sensor.fire_is_running
state: "True"
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
duration:
days: 60
alert:
firemonitor:
name: gas is low
entity_id: sensor.gas_low
state: true
message: fire has been running for {{ states('sensor.fire_running_for') }} hours
repeat: 30
data:
priority: 1
skip_first: false
notifiers:
- HAnotification