Return previous state thermostat

Hi, can you help me with the automation of the previous state?
I have set the solar panels, if it produces more than 1500W, it will change from the original set temperature to 30 ° C, if the condition is not met, I need the temperature to return to the previous temperature, which was not 30 ° C. Is it real?

- id: '1641466436500'
  alias: Akumulace do podlahy
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.nadvyroba
    above: '1500'
    for:
      hours: 0
      minutes: 0
      seconds: 10
  condition: []
  action:
  - service: climate.set_temperature
    target:
      entity_id: climate.temperature_livin_g_room
    data:
      temperature: 30
  mode: single

Try a python script as a service, see another post
Noob Question to create custom state - #2 by vingerha)

I think it might be easier to copy the state to an input number and save it that way.

service: input_number.set_value
target:
  entity_id: input_number.previous_target_temperature
data:
  value: "{{ state_attr('climate.temperature_livin_g_room', 'temperature') }}"

To restore it:

service: climate.set_temperature
target:
  entity_id: climate.temperature_livin_g_room
data:
  temperature: "{{ states('input_number.previous_target_temperature') }}"

Or you can use dynamically created scenes. However, I don’t think that is a good solution because the scene would not survive a restart of Home Asssiant.

1 Like

Thanks for the advice, unfortunately it probably won’t help. The problem is that the condition is checked often, so in half an hour the temperature is set again and then stays there as the previous value of 30 ° C. :-/
Climate responds to more resources and controls. Couldn’t just pressing the +/- button be identified?
image

You should be able to do something like this

service: climate.set_temperature
target:
  entity_id: climate.temperature_livin_g_room
data:
  temperature: "{{ state_attr('climate.temperature_livin_g_room', 'temperature') | float + 1.0 }}"

to increase the temperature by 1.0 °C. It might even work without | float, as I’d expect the attribute to be a float value already.