HA automation

code doesn’t works:

- id: '1595725268224'
  alias: Включение света в маленьком аквариуме
  description: ''
  trigger:
  - device_id: d6612380b1bd4b74857c8dd6fd173111
    domain: switch
    entity_id: switch.33808108bcddc2a8e5e0_2
    platform: device
    type: turned_on
  condition:
  - after: '06:00:00'
    before: '10:00:00'
    condition: time
  - after: '17:00:00'
    before: '21:00:00'
    condition: time
  action: []
  mode: single

another question - how to switch on/off two or three switches by one event (at same time)

It has no action. What is it supposed to do?

Also, the condition is incorrect. Multiple conditions are, by default, logically ANDed. For your two time periods you want them logically ORed. The documentation explains how to indicate a logical OR.

- id: '1595725268222'
  alias: Компрессор маленьком аквариуме вкл
  description: ''
  trigger:
    - at: '08:00:00'
      platform: time
    - at: '15:00:00'
      platform: time
  action: 
    - service: switch.turn_on
      entity_id: switch.33808108bcddc2a8e5e0_3
  mode: single
- id: '1595725268223'
  alias: Компрессор маленьком аквариуме выкл
  description: ''
  trigger:
    - at: '12:00:00'
      platform: time
    - at: '18:00:00'
      platform: time
  action: 
    - service: switch.turn_off
      entity_id: switch.33808108bcddc2a8e5e0_3
  mode: single

have changed my code.
One more question has been left - can I put several devices to switch on/off at same time?

Yes.

  action: 
    - service: switch.turn_on
      entity_id: >
        - switch.first
        - switch.second
        - switch.third
        - switch.etc

also have same question about several time intervals that I’d like to set for turn_on/turn_off, is it right:

trigger:
    - at: '12:00:00'
      platform: time
    - at: '18:00:00'
      platform: time

how i can to write it?

Yes, that’s the correct format and how the documentation explains it: Multiple Triggers

123 Taras - thank you.

1 Like