How to make an automation of a numeric sensor has a value greater than X for Y time

I have an issue happening with a fridge thermostat being faulty and sometimes it keeps the compressor on even when the temperature is well below the threshold.

I can monitor its power usage. How could I make an automation that if a numerical sensor (power usage) is greater than a specific value for over 1h, then it triggers an action?

I’ve identified the pattern as seeing the fridgre drawing about 150W for over an hour while normally it runs like 150W for 1m every 5m normally.
Power-cycling the fridge typically fixes the issue and it’s much cheaper to do that than getting it fixed properly.

TIA

trigger:
  - platform: numeric_state
    entity_id: sensor.fridge_power
    above: 150
    for:
      hours: 1
action:
...

So easy. Thank you.

Somehow I had totally missed that

Edit: Disregard this post. I was making it way harder than it needed to be. I ended up creating a single automation that just says 'Deep frying…" every time the power draw jumps over 1000W - and it works perfectly and does exactly what I want.

Since your problem is solved and mine seems kind of similar, I thought I might piggy back on this post rather than make a new one. I hope that’s okay?

I have a careless room-mate that sometimes forgets to turn off the deep fryer.

When it’s first turned on, it will consume ~1500 Watts for 7 or 8 minutes while it initially heats up. Once it’s at the right temperature, it will turn on and off as needed to maintain the temperature.

So, I need an automation that notices when it’s been on too long and starts nagging with a voice message. The best way I can think of to do it is to use 3 separate automations. I’m hoping someone else will be able to suggest a better approach?

#1:

  • Trigger: The power to the deep fryer surges >1000W
  • Condition: Automation #2 and Automation #3 both disabled
  • Action: Enable #2
  • Action: Wait 30 minutes then Enable #3
  • This one should only perform it’s action blocks when the deep fryer is first turned on. After it’s been run once, the ‘and’ condition will fail because #2 was enabled the first time. After 30 minutes, it also enables #3 to perform the voice nagging.

#2: (initially disabled)

  • Trigger: The power to the deep fryer stays at 0W for 25 minutes
  • Action: Disable #3
  • Action: Disable #2
  • This resets everything and disables the nag and itself ready for the next deep fryer usage

#3: (initially disabled)

  • Trigger: The power to the deep fryer surges >1000W
  • Action: Speak
  • This one notifies Alexa to periodically remind occupants that the deep fryer is still on

I haven’t built these yet because I’m hoping there’s a better way to accomplish this. I’m also not even sure if my approach would work because I don’t know if I can enable/disable automations from an automation - or if I can check for their ‘disabled’ status from a condition block.

Also - I don’t have a careless room-mate. It’s me. I’m the one that forgets to turn off the deep fryer. :man_facepalming: Thanks in advance.

why don’t you let the thermostat of your fryer do its job?

You must have misunderstood something.

The thermostat is doing its job - turning on and off as necessary to keep the oil hot.

This automation causes Home Assistant to “speak” through a nearby Amazon Echo every time that the thermostat turns the heating element on (which is about once every 3-5 minutes while the deep fryer is turned on)

There is no timer or auto-off on the deep fryer - so this is intended to remind me to turn it off when I’m done using it - and it’s been working really well.

1 Like