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
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.