Simple Automation not working?

I’m sorry about the dumb question. I’m just getting started with automations and I’ve got an easy one that isn’t working. I have a power monitor that watches the circuit my garage lights are on. I want HA to send an email if those lights stay on for more than 15 minutes. Here’s what I have:

alias: Garage Lights left on
description: ""
trigger:
  - type: power
    platform: device
    device_id: d1be813f1cee43e7d8fe3ff91a6ccbc8
    entity_id: sensor.garage_lights_power
    domain: sensor
    above: 200
    for:
      hours: 0
      minutes: 15
      seconds: 0
condition: []
action:
  - service: notify.send_email_gmail
    data:
      message: Someone forgot to shut off the lights in the garage.
      title: Shut off garage lights
mode: single

I had the lights on for 23 minutes today and the output was over 200 the whole time.

I can manually trigger the automation and it sends me an email. What am I missing?

1 Like

I think you should probably go with a “numeric value” instead of the “type: power” ???

Screenshot 2022-10-14 165250

You are missing data from 7:02 to 7:04 AM.

The counter for 15 minutes defined in the trigger will start again. (Beside, i did not analyze your automation being correct.)

1 Like

I see the missing data but I’m not actually sure what causes it. I was hoping that because there is no value as opposed to a value below 200 then HA would still understand the last good value as above 200. Is there anyway around this?

Start a timer when the power goes above 200 initially.
Put in a 15 min wait
Check if the power is above 200.
If yes send the notification.

If there is no value available during the second power - send notification anyway

7:02 - 6:48 is 14 minutes. Then you have a gap where the sensor lost connection, then it resumes. That lost connection changed the state from > 200 to unavailable which caused your trigger to never fire.

Thank you for the input! This seems like the best way to work around the data drop out.

1 Like