Yeah, so the template should be
- service_template: >
{% if is_state('binary_sensor.door_window_sensor_158d0001fd55d5' , 'on') %}
rest_command.set_climate_to_on
{% else %}
script.climate_panasonic_off
{% endif %}
(note that a binary sensor can only be on or off, so there was no need for the additional elif)
Then script:
climate_panasonic_off:
sequence:
- service: climate.set_operation_mode
entity_id: climate.panasonic_aircon
data:
operation_mode: 'off'
Hope this helps 