Automation no running on tue nor thu

Hi,

I have an automation to attempt to start vacuuming every 15 min on tue, thu, sat and sun provided neither my wife nor I are home and provided vacuuming did not start in the last 10 hours (so basically today) and that the house is in normal mode (as opposed to holidays for instance)
Vacuuming starts on sat and sun, but does not on tue nor thu.
Here is the code. Any idea why it would not run on tue nor thu?

- alias: Start Vacuuming
  trigger:
    - platform: time
      minutes: '/15'
      seconds: 0
  condition:
    - condition: time
      after: '09:00'
      before: '15:00'
      weekday:
        - tue
        - thu
        - sat
        - sun
    - condition: template
      value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.start_vacuuming.attributes.last_triggered) | int > 36000)}}'
    - condition: state
      entity_id: 'input_boolean.normal'
      state: "on"
    - condition: state
      entity_id: device_tracker.zevsmpjl_div_iphone
      state: not_home
    - condition: state
      entity_id: device_tracker.zevsmpjl_lolo_iphone
      state: not_home
  action:
    - service: vacuum.turn_on
      data:
        entity_id: vacuum.mi_robot_vacuum
    - service: notify.gmaillolo
      data_template:
        message: 'Mi Robot Started Vacuuming...'

Does this help?

Thanks @Partybug for looking into it. Unfortunately it doesn’t help. Like I said the automation works well on Sat and Sun so it would mean the other conditions and the trigger are fine. I just can’t understand why it doesn’t get triggered on Tuesday or Thursday

Just an idea, put your conditions in a script and use the service logbook.log to show if the conditions return true.
Something like:

automation:
  - alias: Start Vacuuming Debug
    trigger:
      - platform: time
        minutes: '/15'
        seconds: 1
    action:
      service: homeassistant.turn_on
      entity_id: script.vacuuming_debug

script:
  vacuuming_debug:
    sequence:
      - condition: time
        after: '09:00'
        before: '15:00'
        weekday:
          - tue
          - thu
          - sat
          - sun
      - service: logbook.log
        data_template:
          name: Vac_Debug
          message: time condition passed
      - condition: template
        value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.start_vacuuming.attributes.last_triggered) | int > 36000)}}'
      - service: logbook.log
        data_template:
          name: Vac_Debug
          message: template condition passed
      - condition: state
        entity_id: 'input_boolean.normal'
        state: "on"
      - service: logbook.log
        data_template:
          name: Vac_Debug
          message: input boolean condition passed
      - ....

I assume something with the states.automation.start_vacuuming.attributes.last_triggered template.

Thanks @VDRainer I’ll try that tonight.
I just tested my last_triggered condition in the Templates tab of the Dev tools and it returns true.

I actually found out today why it didn’t work. On Tues and Thurs I’m at work, and I’ve set up a zone for this.
I’ve not set up a zone for Sat and Sun.
So on Sat and Sun the condition state: not_home was true, but not on tues/thurs.
I’ve changed the condition into

    - condition: template
      value_template: "{{ states.device_tracker.zevsmpjl_div_iphone.state != 'home'}}"

I guess I expected not_home to be true if the status was different than home and this isn’t really made clear on Automation and Conditions pages

1 Like