I’ve left my soldering on iron in my office on more than once which is obviously not ideal! Today I’ve added one of my Xiaomi switches and now I can turn the iron on and off with Alexa/Google and Alexa tells me that the iron is still on every 5 minutes as a reminder. It also turns it off if I leave the house and the alarm is set.
What I’d like to do though is monitor the on time and turn it off automatically after 20 mins. I have the code below but there is a problem as the time in the sensor reports as say 13m so the the value_template below won’t work as it’s expecting just a number, not something followed with a ‘m’. Is it possible to tweak the sensor so it only reports minutes?
condition:
condition: and
conditions:
- condition: state
entity_id: switch.soldering_iron
state: 'on'
- condition: template
value_template: '{{ states.sensor.soldering_iron_time_on.attributes.value | float > 20 }}'
action:
service: switch.turn_off
entity_id: switch.soldering_iron
sensor:
- platform: history_stats
name: Soldering Iron Time On
entity_id: switch.soldering_iron
state: 'on'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
Lastly, I’d like to somehow tweak the start time code so it resets every time the soldering iron turns on. The current code is catching the daily total but I can’t figure how to tweak that.
Any help would be appreciated.