Help make my soldering iron a bit smarter

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: and
        - condition: state
          entity_id: switch.soldering_iron
          state: 'on'
        - condition: template
          value_template: '{{ states.sensor.soldering_iron_time_on.attributes.value | float > 20 }}'
      service: switch.turn_off
      entity_id: switch.soldering_iron 

  - 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.

1 Like
  - platform: state
    entity_id: switch.soldering_iron
    to: 'on'
      minutes: 20
    service: switch.turn_off
    entity_id: switch.soldering_iron 

Ha! Thanks for that. I actually wanted to get a bit smarter if possible so I have a time stored for how long it was on. I also wanted to use the history_stats sensor to get Alexa to tell me how long it’s been on for if I can get the sensor only reporting minutes (without the m).

P.S My cat door solenoids melted down after an hour of being locked so back to the drawing board! :roll_eyes:

When you set it down it drops it’s temp, when you leave it for a while it drops it further, when you leave it even longer it powers down. When you pick it back up it heats back up to 300C in about 10 seconds.