I have created an automation that sleeps my PC after 20 minutes (latest windows update seems to have broken the functionality).
I have the following working as wanted, but I want to be able to perform a different trigger if the wait for trigger gets to the end of the 15mins without firing. I made the continue on timeout false in the test, which means that the automation doesnt fire, which is good but it does this by stopping the automation. I want to be able to run two different outcomes based on whether timeout completes or not. I see there is wait.trigger
and wait.remaining
as a wait variable, but I am unsure on the syntax of being able to use that detail. I have tried using a choose action with a template of wait_template: {{ wait.remaining == '0' }}
or {{ wait.trigger == 'none' }}
but I must have the syntax wrong, or just completely misunderstood it.
My automation code is below which is what I want to modify to be able to run two actions based on if the trigger fires or not. (the reason for the first choose case is that when the PC resumes I have a script that restarts the idle timer, this is to give the script enough time to run to stop the PC sleeping straight away):
alias: Sleep PC
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.hulk_system_idle_time
above: '1200'
condition: []
action:
- delay: '00:01:20'
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.hulk_system_idle_time
below: '150'
sequence: []
- conditions:
- condition: numeric_state
entity_id: sensor.hulk_system_idle_time
above: '1200'
sequence:
- wait_for_trigger:
- platform: numeric_state
entity_id: sensor.hulk_cpu_usage
below: '5'
for: '00:00:10'
timeout: '15'
- service: script.sleep_pc
data: {}
default: []
mode: single