New Broadlink SP2/SP3/SP3S controller

Broadlink SP2/SP3/SP3S control addon

Hi

I can’t put links below, because forum doesn’t allow new user to include more than two links. Clever :wink:

I have a historical misfortune of owning a bunch of different Broadlink WiFi connected remote controlled switches and been somewhat frustrated with the software support. Broadlink eControl app is a terrible thing and open source has traditionally been quite unreliable mainly because those devices are somewhat flaky and has to be addressed accordingly when communicated with.

I recently started to look into hass.io and it’s really promising. However, not surprisingly, support for Broadlink is very basic and switch operations very often time out etc. I didn’t want to start mending the issue inside Hassio but rather started to put together more generic solution that could also be used for Hassio. The following is what I came up with:

  • A low level communications library that can be used in discovering those devices and sending raw packets to them.

    • Available at (just find rinne/node-broadlink-core in github or node-broadlink-core in npm)
  • A standalone hub application that will maintain connections to local devices.

    • Offers WebSocket that can be connected and device status is constantly updated through the socket to arbitrary number of clients.
    • Offers simple REST API for switching a switch on or off.
    • Offers simple REST API for polling device status (This should not be used. Use WebSocket instead.)
    • Offers a Web front end for directly controlling the devices. This is not so refined, but can be used. It also has a debug log option, so that it can be used in checking out what the WebSocket actually communicates. (There is also documentation for that though.)
    • Available at /rinne/node-broadlink-wifi-switch-hub in github
    • No need to preconfigure individual switches.
    • Discovers devices either by broadcasting or probing list of IP addresses.
    • Polls devices and device statuses.
    • Automatically detects changes in device addresses etc.
    • Supports SP2, SP3, and SP3S devices. I don’t have others so I can’t do those. If I’ll get some of those later, I’ll see what I can do.
    • All detected devices will be assigned a permanent uid that is based on the MAC address of the device, so it will never change even if the device is factory reset etc.
    • Reports also energy consumption for SP3S devices.
    • Is not able to configure devices. Devices must still be connected to WiFi using eControl etc. Also device name must be configured that way. Probably I’ll add configuration of name at some point.
  • A Hassio Addon wrapping the Broadlink Switch Hub

    • Available at /rinne/broadlink-wifi-switch-hub-hassio-addon in github
    • Installs nicely under Hassio.
    • Accepts configuration via normal addon configuration instead of command line options.
    • Offers full capabilities of the Broadlink Switch Hub with exception of discovering devices with broadcast.
    • Configuration must include a list of IP addresses from which the addon tries to find Broadlink devices.

OK, what is missing then?

I’d really like to see someone to accept the task of creating an integration to Hassio so that Broadlink Hub could be used as a source for switches and energy meters. It is a good idea to allow multiple hubs if there are several independent networks hosting their own hubs. Also I think the same approach might apply also for other types of switch devices.

I propose a following configuration style, that would allow using the hub either as addon or as standalone installation somewhere outside Home Assistant and also allow multiple hubs.

switch_hub:
  - type: broadlink
    url: http://user1:password1@local-broadlink-wifi-switch-hub-hassio-addon:8525
  - type: broadlink
    url: https://user2:[email protected]:8526

The configuration above would define two hubs. The first is running as an addon inside Hassio host (the host name would probably lose “local-” if the addon would be added to canonical store). The other would be remote installation living somewhere behind TLS proxy. Following endpoints can be therefore derived from the
configuration:

  • ws://user1:password1@local-broadlink-wifi-switch-hub-hassio-addon:8525/status
  • xxxx://user1:password1@local-broadlink-wifi-switch-hub-hassio-addon:8525/power?uid=xxx&power=yyy
  • wss://user2:[email protected]:8526/status
  • xxxxs://user2:[email protected]:8526/power?uid=xxx&power=yyy
  • xxxx above is actually http, but I can’t add more links to the post.

Now WebSocket connections should be opened and monitored for devices and device statuses. New switches are added to the dashboard and can be assigned to the areas by the user, device names can be overridden (like in Telldus) etc. They can be controlled as any other switch.

I assume this would actually be quite small effort, but I just didn’t want to dig into it, because my Python skills and my familiarity with Home Assistant core leaves so much to be desired. If someone is willing to accept the challenge, feel free to contact me. I will help in any way I can.

1 Like

Broadlink SP2/SP3/SP3S already working on Home Assistant, with this new hack what change?

Hi

It doesn’t work very well. Devices routinely are hanging and state changes don’t get through, log is clogged with messages like:

2020-03-18 11:41:18 WARNING (MainThread) [homeassistant.components.switch] Updating broadlink switch took longer than the scheduled update interval 0:00:30

Also the current integration is very basic. It doesn’t allow designating areas or overriding device names. Also it does not discover devices by itself. Full configuration of ip-addresses, macs, device models etc. must be hardcoded into the configuration.

So basically everything is changed.

yes is hardcoded especially if you have a lot of Broadlink sensor like me, is true! Also a lot of warning, if can be integrated in a new way with this hack is very interesting. But why not included also RM pro - Rm mini and S1 and A1 hardware , they are very popular and reduce the update interval is a cool idea!
this is the hack right?

Of course other device types can (and probably will) be included, but since I don’t have any of those, I couldn’t do it. I will get a couple of additional switch types in a few weeks and will probably add support for them, but there is no reason not to integrate to HA meanwhile.

There is also couple of additional reasons not to have the support directly in the core.

  • Running it independently might make it possible to use broadcast discovery
  • Multiple instances may be running in multiple local subnets.
  • Someone (like me) might like to control Broadcast stuff directly without HA.

Can you help with the integration? I don’t have time for it. I will however maintain the addon and components under it also in the future.

hi, i would like to try, but there is no add-on release in the github right? or i miss anything?

1 Like

Any hick-ups about the configuration etc. I’ll gladly help.

How use it? How install it on hassio , is very poor of information readme file

Hi. Since it’s not in any of the addon repos, it must be installed manually.

  1. Install ssh addon
  2. Log in
  3. cd /addons
  4. https://github.com/rinne/broadlink-wifi-switch-hub-hassio-addon.git
  5. Go to your Home Assistant and select Supervisor from the side bar.
  6. Select add on store.
  7. You should see section Local addons, under which you should see Broadlink WiFi Switch Hub
  8. If you don’t see the addon, press refresh symbol in the top right corner of the page.
  9. Select Broadlink WiFi Switch Hub addon
  10. Press INSTALL
  11. Modify addon settings to:
name: Some Name Of Your Choice
user: select-username
password: something-secret
password_hash: null
device_ips:
   - ip-of-your-broadlink-device
   - ip-of-another-broadlink-device
device_timeout: 500
update_interval: 5000
debug: true
  1. If instead of the plaintext password, you’d like to add the password as base64 or hex encoded hash (e.g. sha256), you can do it, but you have to set config value password_hash to sha256. Any other hash algirithm supported by node.js will do to.
  2. Enable also network access to port 8525 from the host (below addon settings).
  3. Start the addon.
  4. Log in to your addon’s web interface http://your-ha-host-name-or-ip:8525/ using the user and password you set in the config.

And the important stuff, what comes from the WebSocket once you open it, is documented in https://github.com/rinne/node-broadlink-wifi-switch-hub

Did you get it to work? If you already got the addon cloned, please pull the newest version of the addon to your HA and rebuild the addon.

cd /addons/broadlink-wifi-switch-hub-hassio-addon
git pull

I have downloaded but haven’t installed , give network‘s access to all broadlink of mine , using a beta Not a secure thing. Broadlink Hub is interessing for me in lan use, and working with HA or Node red as integration, I don’t like to be hacked for some beta test , sorry but this is a very risk , better you ask certification for official hassio plug in , after this I feel very happy to help you.

I added also interface /home-assistant-config to the addon web front. It simply returns a YAML format switch-section for Home Assistant config, including all Broadlink switches discovered. This is by no means any kind of permanent solution for anything, but may offer some added value while the actual integration remains pending.

OK. I ended up doing it myself even though exposing myself to python was not entirely a pleasant experience.

I must say, I’m quite impressed with results though. All my Broadlink switches (more than 30) are now visible in Hassio as configurable devices via integration config entry. There is no more need to configure each device into configuration.yaml or list MAC addresses etc.

See https://github.com/rinne/broadlink-hub-hassio-addon and https://github.com/rinne/broadlink-hub-hass-component for details.

Although I did what you said in the plugins in the new installation, it is not selected.

at the same time, will you have a study for tc2 switches, the only part i can not do is solve this place. I can’t add rm3 pro and tc2. I’m sure many people like me have problems.
I wish you continued work.

Hi

There is somewhat more complete set of instructions in the README file of https://github.com/rinne/broadlink-hub-hassio-addon and https://github.com/rinne/broadlink-hub-hass-component repositories.

I’ll probably look into currently unsupported switch devices like tc2 when I get my hands on some of them. I’m not too interested about rm3 though.

Did anyone (except I) got the addon and component working.

As far as I have followed, there is no custom addons section based on the description.
I follow it tight, I look forward to hope for the tc2s. there are a lot of people who can’t work stably.