Netatmo Schedule overwrites Window open automation

Hey guys,

i got some netatmo radiator valves and played around a bit. I set up an automation which turns off the valve or better the valve will be turned into frost guard mode (7 degree) when a window in the same room is open.
When the window is shut again the valve will go to the same schedule it was before. This is a part from my automation.

alias: Fenster - Heizung
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.fenstersensor_schlafzimmer
    from: 'off'
    to: 'on'
    id: offonschlaf
  - platform: state
    entity_id: binary_sensor.fenstersensor_schlafzimmer
    from: 'on'
    to: 'off'
    id: onoffschlaf
condition: []
action:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ trigger.id == ''offonschlaf'' }}'
        sequence:
          - service: climate.turn_off
            target:
              entity_id: climate.netatmo_schlafzimmer
      - conditions:
          - condition: template
            value_template: '{{ trigger.id == ''onoffschlaf'' }}'
        sequence:
          - service: climate.turn_on
            target:
              entity_id: climate.netatmo_schlafzimmer
    default: []
mode: single

The automation works but when a window is open between two schedule mode (for example night and morning scene in the netatmo app) the new temperature will overwrite the automation and eventually the valve will start heating even if the window is open.

What is the best way to prevent this? I absolutely have no idea how to start here.

Ok i got it. If anyone faces the problems you need to trigger the automation at everytime the schedule will change. Everytime the window (sensor) is open it will turn off the heating. Workes for me.

It is very simple but i had to think about it a bit and i thought more complicated than it was.

alias: Fenster Test
description: ''
trigger:
  - platform: time
    at: '06:30'
  - platform: time
    at: '09:00'
  - platform: time
    at: '16:30'
  - platform: time
    at: '22:30'
  - platform: time
    at: '08:30'
  - platform: time
    at: '23:00'
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.fenstersensor_schlafzimmer
            state: ''
        sequence:
          - service: climate.turn_off
            target:
              entity_id: climate.netatmo_schlafzimmer
    default: []
mode: single