Help with this AUTO for Climate NEST

Hi,

  • I need this auto, when windows are open, and the NESt if is ON ( heating), else turn off or reduce the tem, in this example is reduce to 18ºC.

  • I need other auto, if the windows is closed else resume for the last temp programed in the NESt , is possible?

- id: '1581282368116'
  alias: Nest Open Widnows
  description: ''
  trigger:
  - minutes: /3
    platform: time_pattern
  condition:
  - condition: state
    entity_id: climate.hallway_thermostat
    state: heat
  - condition: state
    entity_id: binary_sensor.ventana_despax
    state: 'on'
  - condition: state
    entity_id: binary_sensor.ventana_cocina
    state: 'on'
  action:
  - data:
      temperature: 18
    entity_id: climate.hallway_thermostat
    service: climate.set_temperature