Heater with time, window and temperature sensor | need help

Being very new to home assistant I’m currently having a hard time debugging this first automation (although we’ve tried many variations of it).

it should:

  • turn on when temp<17 + window is closed + it is day

  • turn off when>17

  • when the window is opened

  • and in the night

Is it even doable at all without highly complicated code?

I use this automation to turn the heater on

alias: 2Bad Heizung an
description:
trigger:
  - platform: numeric_state
    entity_id: sensor.ewelink_th01_236e1e23_temperature
    attribute: unit_of_measurement
    below: '17'
condition:
  - condition: time
    after: '00:08:00'
    before: '00:24:00'
  - condition: and
    conditions:
      - type: is_not_open
        condition: device
        device_id: da222d5a141aa0a0909285521eee2fe3
        entity_id: binary_sensor.badezimmer_fenster_sensor_ias_zone
        domain: binary_sensor
action:
  - type: turn_on
    device_id: 4783eb087bb931b59630f41407f4669a
    entity_id: switch.pow2_nr1
    domain: switch
mode: single

and this to turn it off

alias: 2Bad Heizung aus
description:
trigger:
  - platform: time
    at: '00:24:00'
  - type: opened
    platform: device
    device_id: da222d5a141aa0a0909285521eee2fe3
    entity_id: binary_sensor.badezimmer_fenster_sensor_ias_zone
    domain: binary_sensor
  - platform: numeric_state
    entity_id: sensor.ewelink_th01_236e1e23_temperature
    attribute: unit_of_measurement
    above: '17'
condition: []
action:
  - type: turn_off
    device_id: 4783eb087bb931b59630f41407f4669a
    entity_id: switch.pow2_nr1
    domain: switch
mode: single