Automation with time

thanks for that correction - you’re right it should be:

trigger:
  - platform: time_pattern
    alias: check every 20 minutes
    minutes: "/20"

You’ve helped me before in another post @123. Just came here to say… you are NEXT LEVEL GOAT!! :index_pointing_at_the_viewer: :clap: :clap: :clap: :clap:

Hi,
I need an advice with my automation. I have a script which I want to run twice a month (1st and 15th of each month), but but for both days on different time (i.e. 1st day run at 9:00am, 15th day run at 12:30).
here is my code:

  - id: '1712514481790'
    alias: ATM_QNAPOFF
    description: ''
    trigger:
    - platform: time
      at: 09:00:00
    - platform: time
      at: 12:30:00
    condition:
      - condition: template
        value_template: >-
          {{ ( now().day == 1 and now().hour == 12) or ( now().day == 15 and now().hour == 9) }}
    action:
    - service: script.qnap_off
      data: {}
    - service: notify.whatsapp_maros
      data:
        message: 'QNAP device is shutting down'
    mode: restart

The automation wont start. It looks that there is an issue with second time trigger but I can’t figure out…can somone help?

try quoting your time

    - platform: time
      at: '12:30:00'

and your hours are switched between your post and automation :slight_smile:

You can specify multiple times in the trigger:

trigger:
  - platform: time
    at:
      - "09:00"
      - "12:30"
condition:
  - "{{ (now().day,now().hour) in ((1,9),(15,12)) }}"
action:
  - service: script.qnap_off
    data: {}
  - service: notify.whatsapp_maros
    data:
      message: 'QNAP device is shutting down'
mode: restart

Also shortened the condition including the use of shorthand notation.

1 Like