Remember last state of hvac_mode after turning off

I have an automation that turns off the HVAC based on some trigger.
If trigger occurs > set the hvac_mode to ‘off’.

I am currently in a season when I switch between cooling the house during the day and heating it at night so the hvac_mode is set to ‘heat_cool’. This will change in a few weeks and it will always be on ‘cool’ but I don’t want to keep messing with the automation and want to make it dynamic so that it works in all scenarios.

I am now trying to configure the second automation to turn the HVAC back to it’s last state before I turned it off.
i.e:

  • if it was set to ‘cool’ and the automation turned it off, when I turn it back on it needs to go back to ‘cool’.
  • if it was set to ‘heat_cool’ and it was turned off, it needs to turn back on to ‘heat_cool’.

I’m assuming I have to create a helper that holds the last state of the HVAC?
What would that helper be? An input_select dropdown?

You can use the scene.create service for this. Just build an automation which will call the service when ever there is a change in the hvac_mode. And then you can call the scene.turn_on service with the scene_id of above scene to revert back the hvac system to its orginial state. Check this