Smarter Hot Glue Gun

Hot glue guns are the best thing ever I reckon.

I made mine a bit smarter with a ESPHome-ified smart plug with power monitoring.

I can get a bit distracted when using them. I tend to be multi-tasking (wiring, configuring etc), and then forget about it.

New initial features which didn’t exist in my current one include:

  1. On/off switch (via smart plug button)
  2. Auto off after x minutes (safety, implemented at firmware/ESPHome level)
  3. Announcements on my Google home:
    a. You’ve plugged it in, but haven’t actually turned it on yet to heat it (because forgot!)
    b. It’s hot and ready to use (infer from power usage signature)
    c. It’s about to auto turn-off (haven’t implemented extension method yet)
    d. It just turned off

I like these ‘nag alerts’ for this use case.
I recently upgraded to this one after watching this vid:

https://www.aliexpress.com/item/1005002631138294.html?spm=a2g0o.order_list.0.0.12ea1802FlWPuW

The main challenge was analysing the Power draw patterns and figuring out how to categorise them. It wasn’t super hard after a little head scratching and some prompting thoughts.

Note HA doesn’t quite line up the two time axis below.

ESPHome config excerpts:


binary_sensor:
# Button on the front is pressed and then toggle relay
  - platform: gpio
    device_class: power
    pin:
      number: GPIO03
      inverted: True
    name: ${friendly_name} Button # Name to make button visible in HA
    on_press:
      - switch.toggle: relay
  
  - platform: template
    id: hot_glue_gun_is_heating
    name: "Hot Glue Gun Heating"
    #If the smart switch is switched on AND it's drawing power, then the hot glue gun must be heating up.
    lambda: |-
      if ( (id(relay).state) && (id(wattage).state > 0)) {
        return true;
      } else {
        return false;
      }   
    
  - platform: template
    id: hot_glue_gun_is_ready
    name: "Is Hot Glue Gun Is Ready"
    #If the smart switch is switched on AND it's NOT drawing power, then the hot glue gun must be in target temperature and just idling.
    lambda: |-
      if ((id(wattage).state == 0) && (id(relay).state)) {
        return true;
      } else {
        return false;
      }
    filters:
      - delayed_on: 5s    #Delay on fixed some nuance in this logic in transitions. Don't really get it. I think this condition is met for an instance when the switch first turns on.
      - delayed_off: 30s  #The 30sec delay off smooths out the sensor by bridging/ignoring the intermediate spikes. Don't know how to describe that better.
      
    
text_sensor:
  - platform: template
    id: hot_glue_gun_state_name
    name: "Hot Glue Gun State Name"
    lambda: |-
      if (id(hot_glue_gun_is_ready).state) {
        return {"Ready"};
      } else if (id(hot_glue_gun_is_heating).state) {
        return {"Heating"};
      } else if (id(relay).state == false ) {
        return {"Power Is Off"};
      } else {
        return {};
      }   
    update_interval: 5s
    
switch:
# Relay itself
  - platform: gpio
    name: ${friendly_name}
    pin: GPIO14
    id: relay
    restore_mode: ALWAYS_OFF #Always off on boot.
    on_turn_on: # Action when relay is turned on
      - script.execute: led_power_on
      - script.stop: auto_off_timer # Stop any existing count down timers
      - script.execute: auto_off_timer # Start new timer to turn of power to glue gun after some time.
    on_turn_off: # Action when relay is turned off
      - script.execute: led_relay_off

script:
  - id: auto_off_timer # Turn of power to glue gun after some time.
    then:
      - delay: 20min
      - switch.turn_off: relay

Home Assistant automations:


######################################
#Hot Glue Gun
######################################

- id: '125632525'
  alias: Glue gun is online
  trigger:
  - platform: state
    entity_id:
      - switch.brilliant_smartplug_7
    from: 'unavailable'
    to: 'off'
  action:
  - service: rest_command.assistant_broadcast
    data:
      command: Hot glue gun is online. Don't forget to turn it on

- id: '12263652'
  alias: Glue gun is heating up now
  trigger:
  - platform: state
    entity_id:
      -  sensor.hot_glue_gun_state_name
    to: 'Heating'
  action:
  - service: rest_command.assistant_broadcast
    data:
      command: Hot glue gun is heating up now. I'll let you know when it's ready.
      
- id: '1621225335'
  alias: Glue Gun Is Ready
  trigger:
  - platform: state
    entity_id:
      -  sensor.hot_glue_gun_state_name
    from: 'Heating'
    to: 'Ready'
  action:
  - service: rest_command.assistant_broadcast
    data:
      command: Hot glue gun is ready after {{relative_time(states.automation.glue_gun_is_heating_up_now.attributes.last_triggered)}}  
  - delay: 00:2:00
  - service: rest_command.assistant_broadcast
    data:
      command: Reminder. Hot glue gun has been ready for 2 minutes.
      
- id: '16154235'
  alias: Glue gun has been on for a while
  trigger:
  - platform: state
    entity_id:
      - switch.brilliant_smartplug_7
    to: 'on'
    for:
      minutes: 15
  action:
  - service: rest_command.assistant_broadcast
    data:
      command: Hot glue gun has been on for 15 minutes. It will turn off in 5 minutes.
      
      
- id: '12236525'
  alias: Glue gun has just turned off
  trigger:
  - platform: state
    entity_id:
      - switch.brilliant_smartplug_7
    from: 'on'
    to: 'off'
  action:
  - service: rest_command.assistant_broadcast
    data:
      command: Hot glue gun just turned off.

I use this smart plug, but they are sadly no longer readily ESPHome flashable.

Edit 2022-06-02:

  • Fixed logic deficiencies based on @antonio-fiol 's feedback on Discord thread (thanks).
  • Better boundary condition handling, auto_off logic, and time to heat calculation.
3 Likes