Merge switching Central Heating on/off when Door is open/closed?

Hi,

I have an automation with a sensor who detect if the door is opened, and in that case it will turn off the heating, then turn on when the door is closed.
Also, I have another automation controlled my central heating, on fixed time it increases the temperature and when the lights going off, between 22:00 and 02:00, the temperature goes down to a fixed temperature, till next morning.

Both automations work well, but I want to merge these two in to one automation.
I’m interested to know if that is possible ?
I’m wondering also if the 2 “conditions:” parts of the central heating automation easily can be merged to one ?

alias: Thermostaat aan/uit
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.tuindeur_contact
    attribute: contact
    for: '00:15:00'
condition: []
action:
  - service: >-
      climate.turn_{{ "on" if states("binary_sensor.tuindeur_contact") == "off"
      else "off" }}
    target:
      entity_id: climate.kamerthermostaat
mode: single
alias: Centrale Verwarming
description: ''
trigger:
  - platform: time
    at:
      - '07:00:00'
      - '09:00:00'
      - '11:00:00'
      - '13:00:00'
      - '15:00:00'
      - '02:00:00'
  - platform: state
    entity_id: light.kast_lightstrip
    from: 'on'
    to: 'off'
condition: []
action:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ now().hour in [7, 9, 11, 13, 15] }}'
        sequence:
          - service: climate.set_temperature
            target:
              entity_id: climate.kamerthermostaat
            data:
              temperature: '{{ {7:21.1, 9:21.4, 11:21.7, 13:22.0, 15:22.3}[now().hour] }}'
      - conditions:
          - condition: time
            after: '22:00:00'
            before: '02:00:01'
        sequence:
          - service: climate.set_temperature
            target:
              entity_id: climate.kamerthermostaat
            data:
              temperature: 20.8
    default: []
mode: single

Thank you.

It’s possible to make arbitrarily-complex automations, but why? These two do separate jobs and look like they’d be more logically left as two automations.

1 Like