Hello, I have a following use case: switch on a device if it has been off for 8 hours. I see 3 approaches:
Option 1:
Create a timer for 8 hours and create automation that starts it once the device is switched off.
Create another automation start switches the device on once timer is finished.
Option 2:
Create a single automation with trigger being “device in state ‘off’ for 8 hours” and action “switch on the device”
trigger:
- platform: state
entity_id:
- switch.x
to: "off"
for:
hours: 8
minutes: 0
seconds: 0
action:
- type: turn_on
device_id: ...
entity_id: ...
domain: switch
Option 3:
Same as option 2, but use platform “device” instead of state:
trigger:
- platform: device
type: turned_off
device_id: ...
entity_id: ...
domain: switch
for:
hours: 8
minutes: 0
seconds: 0
Is there any benefit of using the timer approach over the state duration in terms of performance (i.e. HA app performance) or anything else? I suppose both options should be surviving the HA restart too?
And what exactly is the difference between using platform state vs device?