Group switch delay


I was wondering if there is a way to set a delay to set the state of all switches:


The problem is since I’m using broadlink component, when I toggle it, HA send all packets too fast and most lights does not switch on/off but are toggled on the UI. I think that if it could delay for 1 second all commands it might work!

It would be better if HA could first check if the current switched is toggled differently then the group command and only update the ones that need.

If there is no way on doing that, I might just disable the group switch and add a scene to turn on and off all lights of current group.


1 Like

Did you find a solution for this ? I am facing the same problem with RFLink


Yes, another user from this community helped on changing the Broadlink component to have delay after the package is sent.

Now the commands are sent a bit slowly but not missing a single relay!


Is it possible you share with me, what he has changed ? Perhaps I can do the same with the RFlink

Yes! No problem.

He changed this line on Broadlink original component (

def _send_packet(call):
    packets ='packet', [])
    for packet in packets:
        for retry in range(DEFAULT_RETRY):
                payload = b64decode(packet)
                yield from hass.async_add_job(
                    broadlink_device.send_data, payload)
            except (socket.timeout, ValueError):
                    yield from hass.async_add_job(
                except socket.timeout:
                    if retry == DEFAULT_RETRY-1:
                        _LOGGER.error("Failed to send packet to device")

Line122: time.sleep(0.8)

Now after the package is sent, the script stops for 0.8 seconds.

Problem solved!


1 Like

Hi. Thank you for sharing that piece of gem, it really drove my nuts.

I’m trying to do a pull request, but I’m not sure if I’m allowed due to their CLA:

I need permission from the original writer of the code.

The pull request is here:

So please, would you, or the other one from the community, allow we do share your work, so everone can benefit?

Thanks in advance and best regards

1 Like

Anyone can sign the CLA as per these instructions:

The review of your PR suggests, though, that the code doesn’t work. You need to run a tool named tox locally and make sure all tests pass before the code will be merged to the main branch.

I recommend creating a virtual environment and doing the tests in there so you don’t clutter the rest of your environment.

It worked, but I’ve fixed the linter errors.

Still, I’m not sure if I can sign the CLA, because neither A nor B or C are really applicable here.
So maybe Schneider can give us permission

Hello @Mik13!

Thanks for your interest and time to make this component better.

Fortunately, I gave up on using RF relays to control my lightning and appliances: now I have all of them removed and installed Sonoffs with Tasmota firmware.

I am not sure if this fix (time.sleep(0.8)) still works with today’s Broadlink component, since there were updates to the core component. Either way, I do believe this could help a lot of people that still uses these RF relays.

If you can register yourself as a CLA contribuitor, maybe you can suggest this great code to be available as a native component on HA: Broadlink IR Climate Component.

Also, have you seen this GitHub? This guy coded an incredible Broadlink RF code generator to use with relays and RF devices: Random Broadlink RM Code Generator

Have a great day!


1 Like