Help with conditional logic for thermostat control

I am really not sure how to properly describe what i want so i will try my best here.

I have a HA generic thermostat entity (heater + smart plug) which works as it should. But now i want to make a hadrware controller for it with ESPHome.

So far i have managed to display the current temperature, target temperature and climate entity state - On (heat or idle) or Off. I can set the target temperature with a rotary encoder.
So far so good.
I want to use the push state of the rotary encoder to toggle the climate entity On or Off, but the issue here is that there is no climate.toggle service.
So I need to call different homeassistant.service, based on the state ot the climate entity. If it’s off - i need to call homeassistant.service->climate.turn_on or homeassistant.service->climate.turn_off if climate entity state is heat or idle.

How can i acheive this in ESPHome?
Is there a service_template alternative for ESPHome, where i use a simple if statement to choose which service to call ?

According to the Docs, the climate component service calls available to you vary, depending on which climate platform you are using. What is your climate component linked to? A thermostat? Some sort of plug in heater? Whatever switch you use in HA to turn on/off the heater thats what you make the service call to from esphome.

Heres what i dont get. You said the encoder sets the target temperature. If the target temp is higher than the current temp, the heater should already kick on because this is the most basic function of the climate component already

The idea was to toggle the heat mode between Off and Heat with the input. But ultimately i made the button available to HA and there i have the simple if logic to call the appropriate service.

I want to have the option to turn off the heater completely, regardless of temperature. I don’t want to have to scroll to like 10C to turn it somewhat off and then fiddle again to set it to 22 when i want it on, but a simple press.

So forwarding the button push to HA was the easiest way to do this, and i don’t worry too much for some sort of backup if HA goes down, because this thing is controlling a virtual thermostat after all :slight_smile: