Plug OFF when device is OFF for a time

Hi guys,

I would like to check if the state of a device was off for the past 5 minutes, and if so, turn off a smart plug where this is connected.
This condition, i want to be check only between 00:01 AM and 08:00 AM

Reason is that i have a device that in OFF mode has 40w consumption. In this case, i want to switch the plug OFF, if device is not used

Is the device integrated itself to HA or just through the smart plug? If it’s the first, that’s a very simple automation.

If not, then you need a way to reliably know when the device is off, maybe by the power consumption (if it is always higher when the device is on).

If it’s the first case, the automation would be simple, as I said:

Trigger: entity that has the device status changed to off for 5 minutes
Condition: before 8:00:00 (to be clear, this means from midnight until 8:00:00).
Action: turn off the plug.

All of this can be done through the graphical interface in the automation editor.

1 Like

Great ! Works.
Both devices were added in HA, and automatization is quite simple as you said.

I will post it bellow, maybe is helpful for others:

alias: xxx
description: xxx
triggers:
  - device_id: xxx
    domain: media_player
    entity_id: yyy
    type: turned_off
    trigger: device
    for:
      hours: 0
      minutes: 5
      seconds: 0
conditions:
  - condition: time
    before: "07:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
actions:
  - type: turn_off
    device_id: zzz
    entity_id: vvv
    domain: switch
mode: single