#update entity state without triggering anything

1 messages · Page 1 of 1 (latest)

rancid flame
#

is there a way to change a device or entity item state without it triggering anything

Case - I have a dumb aircon unit that HA controls with IR. the aircon also has buttons to turn on/off on the unit itself. currently with the IR esp32 box in the unit recevies the button press it tells HA the unit turned on or off, but then HA sends back "send IR code" and the unit triggers again. the same IR for on and off
So when the button is pressed on the unit, its turns on, HA gets "its on", but then HA sends a "turn on" IR back, but since its on, it turns off

maiden trail
#

Do you have an automation that's doing that?

rancid flame
#

currently esphome esp32c6 using IR and for the button pressing calls the ha api.. thats the only way i know how.. but looking for another way that just tells HA to set the device as on or off without HA doing the climate stuff auto sending IR codes to set the climate to on or off

mossy sphinx
odd rune
#

If I understand I think if you include an IF statement in the automation that checks existing state of the device and if already ON does nothing send the STOP command.

strong pasture
#

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```
rancid flame
#

thanks for that snippet.. im going to try that.
Currently my code to HA is

auto call = id(${ac_climate_id}).make_call();
call.set_mode(mode);
call.set_target_temperature(temp);
call.set_fan_mode(fan_mode);
call.set_swing_mode(swing_mode);
call.perform();

hoping publish_state() rather than perform is a better choice

rancid flame
#

@strong pasture perfect, thank you!