Automation to detect active plug

Hi,

I want to detect if a plug is left active and play a message on alexa. I have pluf and alexa already configured in HA and fully working.

The idea is to trigger an automation when the plug goes on, wait 30 minutes and check if it’s still on then play a message. After the first every 15 minutes play a message until it goes off.

Later on I would like to combine it with blinds status and light status instead of a 15minutes timer.

Can anyone help write the yaml code ?

Thank you,

Simone

The simplest thing for that currently is an alert.

Once you want to add more conditions, base the alert on an input_boolean and use an automation to turn that on and off:

automation:
  - alias: "Track switch state"
    trigger:
      - platform: state
        entity_id: switch.your_switch
    action:
      - service_template: >-
          {{ "input_boolean.turn_on" if is_state('switch.your_switch','on') else "input_boolean.turn_off" }}
        data:
          entity_id: input_boolean.alert_control

input_boolean:
  alert_control:
    name: "Alert control"

alert:
  switch_alarm:
    name: "The switch is still on"
    done_message: "It's turned off now"
    entity_id: input_boolean.alert_control
    state: 'on'
    repeat: 15
    skip_first: true
    notifiers:
      - alexa_notifier_name

NB: I’ve not verified the above, you’ll want to check the integration pages and sanity check since I just wrote them from a quick skim of the docs.

Thank you @Tinkerer!

I’ll test once back home.

Simone