How to save a specific value and use it later?

Hey there,
I try to set up custom automations for a smart thermostat and contact window sensor that are from two different brands. Basically I want Home Assistant to turn down the thermostat’s temperature when my window is open, and that the thermostat goes back to its original temperature state when the window is closed again. I’m not good with scripting but I can work with it once I have a little help.

My thermostat’s entity name is climate.homematic_wohnzimmer and has these values for example:

hvac_modes: auto, heat
min_temp: 5
max_temp: 30
preset_modes:
current_temperature: null
temperature: 20.5
preset_mode: none
model_type: HmIP-Heating-Group
is_group: true
friendly_name: homematic Wohnzimmer
supported_features: 17

When the window opens (entity binary_sensor.terrasse_contact) I want to save the current temperature value in a variable (is that a float number?). Then I want to set the thermostat’s temperature to 5. When the contact sensor closes, I want to receive the saved temperature value and want to set it again to the thermostat’s temperature.

Any help is much appreciated!

There’s a blueprint for that:

It employs a snapshot scene to store/restore the thermostat’s current settings. Either use the blueprint or borrow concepts from its code for your automation.

3 Likes

Another approach is to set away_temp to 5°C (ref), then use a service call to change mode in the automation:

  action:
    - service: climate.set_preset_mode
      entity_id: climate.homematic_wohnzimmer
      data:
        preset_mode: away
3 Likes