Agree there is a few ways to go about this, depending on the payload & or type the is being sent, or if a HA Automation is used even, no mention of it in the OP?
Pretty vague description, no code, no logs, I know little about how to talk in your esp world so I'll describe how I think your description speaks in my own words.
If I take a wild guess, the above description was using using the climate.control, that updates state & transmits IR, I guess is that sending some kind of 'command' payload? or on a 'control topic' like I feel HA getting a command and then returning the command.
It would be better to report the 'state' rather than control.
"HA to set the device as on or off without HA doing"
This is what I feel the issue is, to word it your giving HA a command, so HA returns the command.
But I feel like you want to be reporting the .state, then HA will update its state. not send the command.
Can you send a like a lambda? or however you do it in your esp world to be like:
- platform: gpio
pin: GPIO5
name: "Gregs Dumb AC Physical Button"
on_press:
- lambda: |-
// Toggle the climate mode directly, no IR sent
if (id(gregdumbac).mode == climate::CLIMATE_MODE_OFF) {
id(gregdumbac).mode = climate::CLIMATE_MODE_COOL; // or your default mode
} else {
id(gregdumbac).mode = climate::CLIMATE_MODE_OFF;
}
id(gregdumbac).publish_state(); // tells HA the new state, no IR```