Timer-Based Automation Randomly Stopped Working

I have an automation that triggers after 15m of me not using my PC.
It then sets it to Hibernation, but only does so after checking if I was not using my PC for 30m (to put it simply. It’s a little more complicated than that).

It just stopped working; It only triggered once, the condition of not using my PC for 30m wasn’t met and then it didn’t trigger again despite the sensor showing my PC as not in use the entire night.

Here’s an excerpt of the automation from YAML mode from the UI:

Trigger:

platform: state
entity_id:
  - input_boolean.am_pc
to: "off"
for:
  hours: 0
  minutes: 15
  seconds: 0

Action:

condition: state
entity_id: input_boolean.am_pc
state: "off"
for:
  hours: 0
  minutes: 30
  seconds: 0

service: button.press
metadata: {}
data: {}
target:
  entity_id: button.ars_computer_computer_ruhezustand

Use the full yaml mode instead.
Formatting matters.

Also post the history of the input boolean

That is never going to work.

It triggers when the input boolean has been off for 15 minutes but the condition wont allow actions unless it has been off for 30 minutes. So the automation stops and nothing happens.

1 Like
- id: '1719842756841'
  alias: '(Anwesenheit) (Discord) nicht am PC: (zwischen 15 und 5 Uhr: Discord: offline
    &) PC nach x Minuten in den Ruhezustand versetzen'
  description: 'Bug: Ich hatte den LastActive Sensor Report Intervall in HASS.Agent
    auf 5m gestellt und es hatte gespamtriggert.'
  trigger:
  - platform: state
    entity_id:
    - input_boolean.am_pc
    to: 'off'
    for:
      hours: 0
      minutes: 15
      seconds: 0
  condition: []
  action:
  - alias: je nach Temperatur nach einer bestimmten Dauer an Inaktivität (zwischen
      15 & 5 Uhr Discord offline &) Pc in den Ruhezustand versetzen
    choose:
    - conditions:
      - condition: state
        entity_id: input_boolean.am_pc
        state: 'off'
        for:
          hours: 0
          minutes: 30
          seconds: 0
      - condition: state
        entity_id: timer.es_ist_heute_heiss_2
        state: idle
      sequence:
      - alias: 'falls es zwischen 15 und 5 Uhr ist, Discord: offline (fixt das Problem,
          dass man durch Ruhezustand auf abwesend statt offline gestellt wird. da
          ich nicht weiß, ob mein Discord Script von HASS Agent als PC Eingabe gesehen
          wird, pack ich es hier rein)'
        if:
        - condition: time
          after: '15:00:00'
          before: 05:00:00
        then:
        - service: button.press
          metadata: {}
          data: {}
          target:
            entity_id: button.ars_computer_discord_offline
        - delay:
            hours: 0
            minutes: 0
            seconds: 10
            milliseconds: 0
      - service: button.press
        metadata: {}
        data: {}
        target:
          entity_id: button.ars_computer_computer_ruhezustand
      - service: input_text.set_value
        metadata: {}
        data:
          value: Offline
        target:
          entity_id: input_text.discord_online_status
        alias: 'Variable: Discord Online Status="Offline"'
      alias: nicht heiß? nach 30m (falls 15-5 Uhr Discord:offline &) PC in den Ruhezustand
        versetzen
    - conditions:
      - condition: state
        entity_id: input_boolean.am_pc
        state: 'off'
        for:
          hours: 0
          minutes: 15
          seconds: 0
      - condition: state
        entity_id: timer.es_ist_heute_heiss_2
        state: active
      sequence:
      - alias: 'falls es zwischen 15 und 5 Uhr ist, Discord: offline'
        if:
        - condition: time
          after: '15:00:00'
          before: 05:00:00
        then:
        - service: button.press
          metadata: {}
          data: {}
          target:
            entity_id: button.ars_computer_discord_offline
        - delay:
            hours: 0
            minutes: 0
            seconds: 10
            milliseconds: 0
      - service: button.press
        metadata: {}
        data: {}
        target:
          entity_id: button.ars_computer_computer_ruhezustand
      - service: input_text.set_value
        metadata: {}
        data:
          value: Offline
        target:
          entity_id: input_text.discord_online_status
        alias: 'Variable: Discord Online Status="Offline"'
      alias: 'heiß? nach 15m (falls zwischen 15 und 23 Uhr: Discord: offline &) PC
        in den Ruhezustand versetzen'

Oh, so I only got the impression it used to work because the part of the full automation that worked didn’t have that 30m timer as a condition.

Yes, your second option in the choose should work but not the first

1 Like

I suppose to fix this I just add a PC not used for 30m–trigger and then both the 15m scenario as well as the 30m scenario should work fine?

Believe so

1 Like

Hi Arsalan,

Or just add another trigger that triggers at 30 minutes.

That is exactly what he said

1 Like

oops.