Switch turn on for 30 secound at all 30mintes

Hey,

I want to do automation like this.
At 07:00-20:00
At all 30 minutes o’clock (07:00,07:30,08:00 etc…)
I want seitch turn on for 30 seconds and then the switch turn off.

How the automation look like?

- id: '2132377777554'
  alias: Turn on every 30 minutes between 07:00 - 20:00
  trigger:
  - platform: template
    value_template: "{{7 < now().hour < 19 and now().minute in [0,30] or is_state('sensor.time', '20:00')}}"
  action:
  - service: homeassistant.turn_on
    entity_id: switch.your_switch
  - delay: 00:00:30
  - service: homeassistant.turn_off
    entity_id: switch.your_switch

Thanks but if i want its work on sunday-Thursday
And Friday-Saturday work on 17:00-20:00
?

then read this

but adding a condition to the automation something like

  condition:
    condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun

you just select the days you want

well there more than one to skin the cat so

my thinking is
let run it every 30mins
and just check the condition time is after 07:00:00 and before 20:00:00
and am i not home
and its this weekday

so

- id: 33dcd8e2-e87c-4d18-82bc-c7f9b53a1624
  alias: do it between 07:00 20:00
  initial_state: true
  mode: restart
  trigger:
    - platform: time_pattern
      minutes: 30
  condition:
    - condition: time
      after: '07:00:00'
      before: '20:00:00'
    - condition: and
      conditions:
      - condition: state
        entity_id: person.stephan
        state: not_home
      - condition: time
        weekday:
          - mon
          - wed
          - fri
          - sun
  action:
  - service: switch.turn_on
    entity_id: switch.your_switch
  - delay: 00:00:30
  - service: switch.turn_off
    entity_id: switch.your_switch

winging just typing off of head so spacing could be out

There you go

- id: '2132377777554'
  alias: Turn on every 30 minutes between 07:00 - 20:00
  trigger:
  - platform: state
    entity_id: sensor.time
  condition:
  - condition: template
    value_template: "{{now().minute in [0,30]}}"
  - condition: or
    conditions:
    - condition: time
      weekday:
      - sun
      - mon
      - tue
      - wed
      - thu
    - condition: time
      after: "17:00:00"
      before: "20:00:00"
      weekday:
      - fri
      - sat
  action:
  - service: homeassistant.turn_on
    entity_id: switch.your_switch
  - delay: 00:00:30
  - service: homeassistant.turn_off
    entity_id: switch.your_switch

THANK YOU SO MUCH!!!

1 Like