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 }}"
