Same hare, waiting for the support to be able to add this on the whole house
Current workaround I have is to create routines in Alexa to turn the switches on/off and then trigger these via home assistant for anyone interested. I’m also looking forward to direct integration to HA.
Which ones did you go for? Only option I’ve seen is Aqara at £40+ each
I’m wondering if it’s a case of broadlink not allowing home assistant integration or not enough people using home assistant Cares for this? Who’s usually the ones making the integrations happen? I’ve got 3 switches now and I’m missing out on some really useful automations.
I’m EU based, bought something off of AliExpress, there’s many types there. Specifically bought these which are great. They look good, they have an on/off led, the switch is very nice to press and they do not required a neutral wire. Pairing was a breeze as well.
Steven, thanks for your work on this, it looks like a really good start. Will you be building this to be an add-on that can be installed?
Great work.
I’ve created a pull request for my branch to be merged into the Broadlink python libraries. One of the maintainers for those libraries is engaged and is pleased with the contribution, luckily he is also a maintainer of the broadlink integration with HA, which uses those libraries. I believe a fully fledged integration with the S3 hub will be implemented in due course.
In the meantime if you’re happy setting up a Docker container running the API that I created above, it all seems to work pretty well with no noticeable delays.
Here are the steps involved in setting it up:
Download and deploy docker image: stevendodd/s3-rest-api or follow steps 1 to 4 below.
- Check out my branch from GitHub to your local machine https://github.com/stevendodd/python-broadlink/tree/Add_S3_REST_API
- Run
python3
import broadlink
device = broadlink.hello('192.168.1.99')
device.auth()
Where the IP address is the IP address of your S3 hub. If you get an unsupported device error you may need to add your device ID to ./broadlink/__init__.py
SUPPORTED_TYPES = {
s3: {
0xa64d:("S3", "Broadlink"),
},
-
Run
>>> device.get_state("00000000000000000000a043b0d06963")
where the input parameter is your device ID of any sub device which you can find in the board link app or via>>> device.get_subdevices()
you should get something similar to this:{'pwr1': 0, 'pwr2': 0, 'plugmode': 0, 'hb_timeout': 180, 'lb_online1': 1}
in my case this is an LC1 light switch with two gangs. If you have other sub devices I would be interested in seeing the output… -
Create a Docker image
docker build -t stevendodd/s3-rest-api .
-
Deploy the Docker S3 rest API image and test the GET methods in a browser
http://127.0.0.1:5000/?hub=192.168.1.99
http://127.0.0.1:5000/00000000000000000000a043b0d0783a/1
- Update HA configuration.yaml to use your new API.
switch:
- platform: rest
resource: http://192.168.1.162:8124/00000000000000000000a043b0d0783a/1
body_on: '{"active": "true"}'
body_off: '{"active": "false"}'
is_on_template: "{{ value_json.is_active }}"
Hi there!
I tried it and I got this:
import broadlink
device = broadlink.hello(‘192.168.0.76’)
device.auth()
Traceback (most recent call last):
File “”, line 1, in
File “/Users/sdimitrov/Documents/Private/python-broadlink/broadlink/device.py”, line 185, in auth
e.check_error(response[0x22:0x24])
File “/Users/sdimitrov/Documents/Private/python-broadlink/broadlink/exceptions.py”, line 152, in check_error
raise exception(error_code)
broadlink.exceptions.AuthenticationError: [Errno -1] Authentication failed
What am I missing?
Hey there. It seems that the device lock was breaking the auth(). I disabled the locking and now I go through the authentication, but now I cannot move forward. Here is an example:
> >>> import broadlink
>
> >>> device1 = broadlink.hello('192.168.0.76')
>
> >>> device1.auth()
>
> True
>
> >>> device1
>
> broadlink.device.Device(('192.168.0.76', 80), mac=b'\xa0C\xb0L\xd1,', devtype=42396, timeout=10, name='Smart Hub', model='', manufacturer='', is_locked=False)
>
> >>> device1.get_subdevices()
>
> Traceback (most recent call last):
>
> File "<stdin>", line 1, in <module>
>
> AttributeError: 'Device' object has no attribute 'get_subdevices'
Not sure if it helps. But I have two s3 hubs - one with 8 devices and one with 5. This is me trying to connect to one of the hubs.
I tried with two branches from this repo:
- Add_S3_REST_API
- Add_Support_for_S3_Hub_0xa59c
Both are showing the same error so not sure what I am missing.
Are you sure you using the right code base, do you have python-broadlink installed via pip?
Is there is there any way you can can test with the docker image? Perhaps you could download docker desktop and run it from there
Maybe I am doing something stupid.
Here is the docker instance:
Here is when I try to get the hub info:
Not sure if this helps but i tried your other approach inside the docker instance:
I got the same issue as with without the docker instance.
Thank you with your help so far!
From Postman try http://127.0.0.1:5000/?hub=192.168.0.76
If that doesn’t work please do try to download the image from Docker hub, did you need to update the device ID is that why you are building the image from scratch?
Don’t forget to map the local port number to the container port number
Great news! now it seems to show some data
This is with the alternative Docker Hub.
This is when I try the logic to see a specific DID:
And this is how I am starting & stopping the switches:
This is how I see the motion sensors:
Let me know if I am missing something.
Three questions arise now:
- I have two hubs, does this mean I need two instances in Docker or not?
- How I can set a sensor for the motion tools?
- Due to the nature of my work I cannot leave my PC working all the time. Is there a way to have this working directly in HA? I have Home Assistant Blue.
PS. I feel like I am spamming a lot. If you want I can take this via PM.
Well done,
You can reinitialise the hub at any time to connect to either hub, however yes in order for home assistant to be able to be able to query both hubs you would need two docker containers running at all times. Until the HA maintainers integrate my code which could potentially take a while why don’t you look at running docker on a low powered raspberry pi.
In order to read the motion sensor data you just need to parse the json response and check if there is any detection or tampering statuses set to 1
You can help me a bit if you like. Could you tell me what each of the the the sub devices you have are. If you have anything other than light switches or the motion sensor that you have shared above could you also please send a get status response
These are all my devices:
Essentially I have only 1,2-gang TC3-EU switches, a couple of motion sensors, and door sensors. Everything is from the S3 Broadlink series (but I don’t think that something else can connect to that hub anyway)
I guess you already know what the switches give you as an information. Here is the motion sensor:
The pir_detected is by default 0, but changes to 1 once it detects a movement.
This is the door sensor information:
doorsensor_status changes to 1 once a door is opened.
Let me know if this is enough or you need something else.
I have updated the main image to include your device ID and there is also an example Home assistant sensor on the readme page https://hub.docker.com/repository/docker/stevendodd/s3-rest-api
sensor:
- platform: rest
name: Light
resource: http://192.168.1.162:8124/00000000000000000000a043b0d0783a
value_template: '{{ value_json }}'
json_attributes:
- pwr1
- pwr2
The code has been merged into the main library - potentially will be supported in home assistant in the next release