Turn device on when off for x time

Hi forum members,

I try do to something simple I believe, but I do not know how to proceed. I have a device that I want switch on when it is not being switched on for a week, by another automation script. Is that possible and how should I do that?

Regards,

Francis

Hi. You could create a timer which starts when the device turns off, and create an automation to turn on again when timer finishes.
You could have the timer reset if the device has being on before the desired period.

ok, so would I do that within HA?

Here’s an easier possibility:

  1. create an automation
  2. go to trigger and click the 3 dots in the upper right corner
  3. select ‘edit as YAML’ and paste the following:
platform: state
entity_id: #put the entity_id here
to: 'off'
for:
 days: 7

(don’t switch back to edit in UI, as this will break the “for:” part)

  1. Add an action below to turn the device on.

more information: