Problem with time triggered automation

I run Home assistant via Docker on my homebuilt NAS.
Goal:
Start mi Xiaomi vacuum cleaner with this conditions fulfilled:

  • Between monday and friday
  • Time between 08:30 AM and 05:00 PM
  • vacuum cleaner has not run today
  • mobile phone is disconnected from WIFI for more than 10 minutes

YAML:

alias: 'Staubsauger aktivieren, wenn nicht zu Hause'
trigger:
  - platform: state
    to: not_home
    for: '00:10:00'
    entity_id: device_tracker.galaxy_s10_von_julian
    from: home
condition:
  - condition: state
    entity_id: sensor.lief_der_staubsauger_schon
    state: '0.0'
  - condition: time
    after: '08:30'
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
    before: '17:00'
action:
  - service: vacuum.start
    entity_id: vacuum.xiaomi_vacuum_cleaner
  - service: notify.telegram
    data:
      message: 'Keiner zu Hause, Staubsauger gurkt los!'
mode: single

Problem:
This works when I leave the house between 08:00 AM and 05:00 PM, but not when I am already out of the house - it must have something to do with the state trigger. What is the correct way to fix this?

I see the issue where you have the trigger set to 10 minutes.

Maybe try creating a Toggle Helper - Then an automation to turn it on when your away for 10 minutes, then turns it off when you return home. Name it “Julian Not Home”

Then you can use that flag as your trigger. If “Julian Not Home” is on & conditions are met, then action?

Yes that is exactly the problem the trigger has to go from something to not_home. If you are already away it won’t trigger.

Add a time trigger for 8am, and add tracker away conditions to solves this.

okay, I hope I understood you correctly. I´ve removed the time trigger from the main automation and created a “help automation”. This looks like this:

alias: Staubsauger Hilfsmerker
trigger:
  - platform: state
    to: not_home
    for: '00:10:00'
    entity_id: device_tracker.galaxy_s10_von_julian
    from: home
condition: []
action:
  - service: input_boolean.turn_on
    entity_id: input_boolean.hilfsmerker_staubsauger
mode: single

With this I trigger the main automation:

alias: 'Staubsauger aktivieren, wenn nicht zu Hause'
trigger:
  - platform: state
    entity_id: input_boolean.hilfsmerker_staubsauger
    to: 'true'
condition:
  - condition: state
    entity_id: sensor.lief_der_staubsauger_schon
    state: '0.0'
  - condition: time
    after: '08:30'
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
    before: '17:00'
action:
  - service: vacuum.start
    entity_id: vacuum.xiaomi_vacuum_cleaner
  - service: notify.telegram
    data:
      message: 'Keiner zu Hause, Staubsauger gurkt los!'
mode: single

Did I understand that correctly? Do I have to create a "reverse automation for resetting the input_boolean?

That’s not going to work either. Setting the input boolean has the same issue as your original automation. Read my post, add the extra conditions and trigger.

1 Like

Nowhere in his post did he suggest you remove the time trigger, nor a single other thing that followed the part of your post I quoted.