Turn heating on where window sensor is 'off'

Hello Guys,

I’m not new to HA but can not get it work…

I want to turn on my heating when comming home, but only in those rooms where my window sensor is off (closed).

My scripts:

  set_bad_temp_home:
    sequence:
      - service: climate.set_temperature
        data_template:
          entity_id: climate.oeq1686946
          temperature: 21.5

  set_kuche_temp_home:
    sequence:
      - service: climate.set_temperature
        data_template:
          entity_id: climate.oeq1685747
          temperature: 21.5

  set_wohnzimmer_temp_home:
    sequence:
      - service: climate.set_temperature
        data_template:
          entity_id: climate.oeq1684915
          temperature: 21.5

My automation for this:

 - alias: 'Heizung_home_on'
   initial_state: True
   trigger:
     platform: state
     entity_id: group.devices
     from: 'not_home'
     to: 'home'
   condition:
     condition: and
     conditions:
       - condition: state
         entity_id: input_boolean.heizung
         state: 'on'
       - condition: numeric_state
         entity_id: sensor.yweather_temperature
         below: '15'
   action:
    - service: script.turn_on
      data_template:
        entity_id: >
          {% if is_state('binary_sensor.oeq1376840_state', 'off') %}
            script.set_bad_temp_home
          {% endif %}
    - service: script.turn_on
      data_template:
        entity_id: >
          {% if is_state('binary_sensor.oeq1027067_state', 'off') %}
            script.set_kuche_temp_home
          {% endif %}
    - service: script.turn_on
      data_template:
        entity_id: >
          {% if is_state('binary_sensor.oeq1375758_state', 'off') %}
            script.set_wohnzimmer_temp_home
          {% endif %}

My Error HA gave me:

Error while executing automation automation.heizung_home_on. Invalid data for call_service at pos 1: Entity ID is an invalid entity id for dictionary value @ data['entity_id']

Triggering the scripts manually works fine.
Any ideas ? Every help is very appreciated.
Thanks!

Got it working.

Maybe someone have the same problem.
Here is the soloution:

Scripts:

set_bad_temp_closed:
    sequence:
      - service: climate.set_temperature
        data_template:
          entity_id: climate.oeq1686946
          temperature: 21.5

  set_kuche_temp_closed:
    sequence:
      - service: climate.set_temperature
        data_template:
          entity_id: climate.oeq1685747
          temperature: 21.5

  set_wohnzimmer_temp_closed:
    sequence:
      - service: climate.set_temperature
        data_template:
          entity_id: climate.oeq1684915
          temperature: 21.5

  set_bad_temp_open:
    sequence:
      - service: climate.set_temperature
        data_template:
          entity_id: climate.oeq1686946
          temperature: 5

  set_kuche_temp_open:
    sequence:
      - service: climate.set_temperature
        data_template:
          entity_id: climate.oeq1685747
          temperature: 5
		  
  set_wohnzimmer_temp_open:
    sequence:
      - service: climate.set_temperature
        data_template:
          entity_id: climate.oeq1684915
          temperature: 5

Automation:

 - alias: 'Heizung_home_on'
   initial_state: True
   trigger:
     platform: state
     entity_id: group.devices
     from: 'not_home'
     to: 'home'
   condition:
     condition: and
     conditions:
       - condition: state
         entity_id: input_boolean.heizung
         state: 'on'
       - condition: numeric_state
         entity_id: sensor.yweather_temperature
         below: '15'
   action:
    - service: script.turn_on
      data_template:
        entity_id: >
          {% if is_state("binary_sensor.oeq1376840_state", "off") %}
            script.set_bad_temp_closed
          {% else %}
             script.set_bad_temp_open
          {% endif %}
    - service: script.turn_on
      data_template:
        entity_id: >
          {% if is_state("binary_sensor.oeq1027067_state", "off") %}
            script.set_kuche_temp_closed
          {% else %}
            script.set_kuche_temp_open
          {% endif %}
    - service: script.turn_on
      data_template:
        entity_id: >
          {% if is_state("binary_sensor.oeq1375758_state", "off") %}
            script.set_wohnzimmer_temp_closed
          {% else %}
            script.set_wohnzimmer_temp_open
          {% endif %}