Control light and switch entities with 433MHZ remote controller paired with Broadlink RM4 Pro

I’m fairly new with HomeAssistant. I’ve got myself a Sonoff RM433R2 remote controller and Broadlink RM4 Pro.
The integration of the RM4 is done, it learned the buttons on the remote, which is listed in the .storage/broadlink_remote_xyz_codes file.
Now what is the way for controlling entities? Like on pressing first button on the remote turns off light.xy, or switch.xy?

Two alternatives:

1. Use remote.send_command.

Try this first to make sure the codes are working. In the UI it looks like…

Device and command names are the ones you defined during the learning process.

2. Define a switch for each light in configuration.yaml

  - platform: broadlink
    mac: a043b05517ac
    switches:
      - name: spotlights
        command_on: scCUBH6eBgAKCAoJCgkKCAoJCSwKCQosCgkJCQoJCQkKLAkKCS0JCQoJCQoJCQktCQkJLQoJCQkKCQktCQkJCgktCS0JCQktCQkKCQkJCgkKCQkKCS0JCQkJCS0JCgkKCQkJCgksCQoJLAoJCgkJCgksCQoJCQkKCS0JCgkJCQoJLAosCQoJCgksCQoJCQkKCS0JCQkKCQABYgkKCQkKCQkJCgkJLAoJCS0JCgkJCQoJCQktCQkKLQkJCQoJCQkKCSwKCQktCQoJCQkKCSwKCQkKCC4JLAoJCS0JCQkKCQkJCgkKCQkJLQkKCAoJLQkKCQkJCgkKCC0JCgksCQsICgkKCC0JCgkJCQoJLQkKCAoJCgksCS0JCQkLCSwJCgkJCQoJLAkKCQoIAAFjCQoJCQkKCQkJCgksCQoJLQkKCQkJCgkJCS0JCQkuCQkJCgkJCQoJLAkKCS0JCgkKCAoJLAkKCQkJLgksCgkJLAoJCQoJCQkKCQoJCQktCQoICgktCQoJCQkKCQkJLQkKCSwJCgkKCQkJLQkJCQoJCgktCQkJCgkKCC0JLQkJCQsILQkJCgkJCgksCQoJCQkAAWMJCgkJCQkKCQkKCSwJCgktCQkKCQkKCQkJLQkJCS4JCQkKCQoICgktCAoJLQkKCQkJCwgsCQoJCQkuCSwJCgktCQkJCQoJCQoJCgkJCS0JCQkKCS0JCgkJCQoJCQktCQkJLQkKCQoJCQktCQkJCgkKCC4JCQ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CQoJCQkKCS0JCgkJCQoJLAktCQkJCwgtCQoJCQkKCC0JCgkKCAABYwkKCQkKCQktCQkJCgkJCS0JCgkJCQoJCQktCQoJLQkJCQoJCggKCS0JCQktCQoJCQkKCQoILQkKCS0JLQkJCS0JCQkKCQkJCgkKCQoILQkKCQkJLQkKCQoICgkKCC0JCgksCQsICgkKCSwJCgkJCQoJLQkKCQkJCgksCS0JCQkKCiwJCgkJCQoJLAkKCQoJAAFiCQoJCQoJCS0JCQkKCQkJLQoJCQkJCgkKCC0JCg==

Although you can’t edit the broadlink file in .storage, you can copy/paste the codes. The broadlink platform doesn’t allow you to assign icons or friendly names - you can do this with customize:

switch.spotlights:
  icon: mdi:track-light
  friendly_name: Spotlights

All in the docs (if you dig a bit):

Thanks for your reply.
I assume this configuration would work if the Spotlights would have an already existing remote.
What I would like to achieve is that I have several Tuya lights, and sometimes I’d need to control them with the 433mhz remote throught HA (not every family member would like to use HA UI).
What is still missing for me is that where do I set my light entity to toggle if I press the first physical button on the remote.
My assumption regarding the process is like when I press the pyhsical button, broadlink RM4 Pro receives the button press signal and controls the light entity through HA.
Is that achievable? Thanks.

Following this, because I always thought the Broadlink can only receive codes in ‘learn mode’, not in normal operation.

Me too. My understanding is that toggle buttons on remote controls actually send two different commands on alternate presses. There’s nothing coming back.

There’s an explanation based on IR codes here, but as far as I know RF works the same way.

Edit: Have I understood the situation correctly? You have Tuya lights which can be controlled by HA, and you have bought a Sonoff remote for use by members of the family who don’t like using HA dashboards. I have no experience with Tuya or Sonoff, but I’m not sure where the Broadlink comes in. Doesn’t the Sonoff integrate with HA itself? Broadlinks are usually used to replace remotes in situations where the lights etc. don’t have integrations of their own. In this case I would expect the Tuya entities to reflect the state of the lights automatically.

Since the Sonoff remote is 433mhz remote, my plan is that I’ll use broadlink as a command receiver from the remote, that would trigger for example an event which toggles the light.
For that reason as far as I understand I cannot think of a Sonoff integration. If the remote would be like a zigbee remote that would be different with the integration(something I also have, using automation as remote button click trigger toggles light entity state)

I think you want a Sonoff RFBridge flashed with Tasmota. That is how I use my 433Mhz remotes.

Correct. Local Tuya to know the status of the lights, 433 Mhz remote + Sonoff RfBridge to switch them on/of (and to brighten/dim them). That is what I have in my son’s bedroom.

I thought Sonoff rf bridge and broadlink serves the same purpose, both should be able to send and receive rf signals.
I assume you are suggesting rf bridge because of the already existing ha integration?

See my post earlier