ha-rpi_rf icon indicating copy to clipboard operation
ha-rpi_rf copied to clipboard

Switch service call order not guaranteed?

Open bezenson opened this issue 2 years ago • 3 comments

While we don't know real status of RF devices in some automations I call "switch off" first and then "switch on" (because actually my RF lights controller works in "toggle" mode. But I found that light can be turned on and then turned off. It looks like RF call order is random.

Maybe it is an issue. Or maybe it is something specific, I don't know.

bezenson avatar Dec 19 '22 09:12 bezenson

I don't know the answer offhand but am wondering what delay you place between commands?

markvader avatar Dec 19 '22 10:12 markvader

As your lights work in toggle mode, is the controller not fussy about differentiating between on and off codes, i.e. it accepts either code as on, and either code as off?

markvader avatar Dec 19 '22 10:12 markvader

I'll try to explain. I have a light controller with 3 channels - "A", "B", "C" buttons. And also there is "Off" button which turns off all channels. I've added that buttons as switches into home assistant config where "On" command is A, B or C. And "Off" command is always as "Off" button.

For example in my automation I expect that only "A" channel will be turned on. But while I don't know about status of other channels - first I call "Switch OFF" on all channels (Off button on controller) and then "Switch On" on "A" channel.

And very often I'm catching that situation that light turns on (because "A" turns on) and then very fast turns off (I guess because off action stuck and called after in some reasons).

I also tried to add delay, but this not fixes a problem.

action:
  - service: switch.turn_off
    target:
      entity_id: switch.living_room_light
    data: {}
  - delay:
      seconds: 1
  - service: switch.turn_on
    target:
      entity_id: switch.living_room_light_a
    data: {}

image

bezenson avatar Dec 19 '22 10:12 bezenson