Still cant get this automation to trigger and pause correctly

I’m still struggling with my first automation.

I’ve been trying to get the following automation working for a couple of weeks now. The actions work fine but I cant get the trigger and timing to work correctly. I’m building this using the UI and not yaml. I’d apricate help if possible so I can both get this working and learn how to approach this type of situation.

I’m trying to auto shut off and then back on a plug in fan. When the fan is plugged in, and in its standby mode, it pulls less than .4 amps. When the fan is running it pulls over .4 amps. When the fan is unplugged and plugged back in it reverts to its standby mode.

I have it plugged into a zwave plug that measure power values.

What I want to happen is if the fan is pulling .4 amps or more for 60 mins then. If the amps drop below .4 before that 60 mins then just watch for the next situation but don’t trigger the actions. If the 60 min limit is hit then Turn the power off on the fan, Wait 15 seconds, then turn the power back on. For testing purposes I have the timing set to 2 minutes right now.

Sounds simple but I’m pulling my hair out trying to get this to work.

alias: Bathroom master fan/heater auto off
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.bathroom_master_heater_amp_threshold
    attribute: upper
    from: ".399"
    for:
      hours: 0
      minutes: 2
      seconds: 0
conditions: []
actions:
  - action: switch.turn_off
    target:
      entity_id: switch.mini_plug_with_power_meter_testing1_2
    data: {}
    alias: "Perform Action: turn master bathroom fan/heater off"
  - delay:
      hours: 0
      minutes: 0
      seconds: 15
  - action: switch.turn_on
    target:
      entity_id: switch.mini_plug_with_power_meter_testing1_2
    data: {}
    alias: "Perform Acation: turn master bathroom fan/heater on"
  - action: notify.clairhomeautomation_gmail_com
    metadata: {}
    data:
      message: The clearmaster bathroom heater/fan was automatically turned off
      target: [email protected]
      title: It was left on beyond its allowed run time
mode: single

Your trigger seems too specific. It will only fire when the value gets to exactly .399 and then changes to another value.

I suspect you’d be better off using a numeric state trigger with above: and below:.

1 Like

That appears to have done the trick. I could have sworn I had one of my attempts using the numeric state. Thanks so much for the help

The issue with the trigger in the original post is that you have specified the attribute upper from a Threshold sensor. That attribute is static, so it will never change to your desired value. Maybe you meant to use a different sensor or maybe the sensor_value attribute from the Threshold sensor?