I use Wake on Lan to detect if my PC is switched on or off. Everything works so far and I can switch off a power plug when I shut down the PC.
However, I would like the power plug to be switched off when the PC is already switched off at 8:00 p.m. I tried this, but it doesn’t work:
alias: "Steckdose aus: Büro Matthias wenn PC aus"
description: ""
trigger:
- platform: state
entity_id:
- switch.pc_buro_matthias
condition:
- condition: time
after: "20:00:00"
- condition: state
entity_id: switch.pc_buro_matthias
state: "off"
action:
- service: switch.turn_off
data: {}
target:
entity_id: switch.steckdose_schlafzimmer
mode: single
I think the problem is because the state of the PC doesn’t change, so nothing is triggered.
Can you help me, please?
alias: Disconnect power to PC after 20::0
description: ""
trigger:
- platform: time
at: "20:00:00"
id: eight
- platform: state
entity_id:
- binary_sensor.pc_ping
to: "off"
from: "on"
id: pc-off
for:
hours: 0
minutes: 10
seconds: 0
condition: null
action:
- choose:
- conditions:
- condition: trigger
id: eight
- condition: state
entity_id: binary_sensor.pc_ping
state: "off"
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.pc_power
- conditions:
- condition: trigger
id: pc-off
- condition: time
after: "20:00:00"
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.pc_power
mode: single
Note that when PC is turned off after 20:00, it will switch the power off 10 minutes after the ping goes down (so the PC is allowed to power down gracefully, before cutting the power)