Review my Yaml

I’m gradually weaning myself off my reliance of Node Red to hopefully write all my automation’s in YAML. What I’m trying to achieve with the below is turn the heating off if nobody’s home on a weekday during the times specified. I’m pretty sure it’ll work? Just trying to get my head round the nesting of the conditions.

- alias: Morning Heating Watch Dog Weekday - OFF
  trigger:
    platform: state
    entity_id: group.people
    to: "away"
  condition:
     condition: and 
     conditions:
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
      - condition: or
        conditions:
         - condition: time 
           after: "07:00:00"  
           before: "12:59:00"
         - condition: time
           after: "13:31:00"
           before: "16:59:00"
         - condition: time 
           after: "17:30:00"
           before: "22:00:00"
  action:
    - service: climate.turn_off
      data:
        entity_id: climate.kitchen, climate.lounge

As always thanks in advance.

  trigger:
    platform: state
    entity_id: group.people
    to: 'not_home'
1 Like

Thanks mf_social, I’m re writing an existing automation for exactly this reason, my heating doesn’t switch off :laughing:.

Appreciated

1 Like

Conditions are automatically considered as AND, so you can lose those two lines and move the remaining condition ones back left - not a big deal, but easier to read.

1 Like

Many thanks, I’ve written others with conditions in sequence was just unsure if this would affect the nesting. Duly noted & altered.