markvader / ha-rpi_rf

Home Assistant Raspberry Pi GPIO RF Integration
Apache License 2.0
31 stars 5 forks source link

Switch service call order not guaranteed? #66

Open bezenson opened 1 year ago

bezenson commented 1 year ago

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.

markvader commented 1 year ago

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

markvader commented 1 year ago

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?

bezenson commented 1 year ago

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