Broadlink S3 hub support

Just add something like this:

broadlink_s3_hub:
  module: broadlink_s3_hub
  class: BroadlinkS3Hub
  hub_ip: "192.168.1.209"
  did: "00000000000000000000a043b0d059ac"
  scan_interval: 0.5
  friendly_names:
    - Gang 1 name
    - Gang 2 name
    - Gang 3 name
  entity_ids:
    - light.gang_1
    - light.gang_2
    - light.gang_3
1 Like

thanks, that’s created the 3 switches successfully!

I’m very untechnical but it seems to get stuck in a loop when I switch one light off.

The switching on/off of each gang works but then the polling gets confused if all 3 gangs aren’t the same state. For example if one gang is off and the other 2 are on, then the fact there is only a single Device ID in Broadlink seems to cause an issue because it polls each gang and gets “ON…ON…OFF…ON…ON…OFF” and so the Entity in HA toggles on/off in a loop. Logs below.

Could it be because I’d previously created an Input Boolean linked to one of the gangs?

Don’t worry if this is unfixable, I’ll see if I can do something with automations around looking for the service calls.

I don’t have 2+ gangs switch to test the code, but I made a change on the code that should fix the issue, could you test and let me know if it worked or not?

1 Like

You can update it by HACS by going to:

  1. HACS dashboard
  2. Automations
  3. BroadLink s3 hub
  4. Click on the right bottom 3 vertical dots
  5. Click on update information
  6. Wait a few seconds and an updated button will be shown
  7. Click on the update button and click on the update button in the dialog
  8. Wait for the update to finish and try again with the switches

broadlink_s3_hub:
module: broadlink_s3_hub
class: BroadlinkS3Hub
hub_ip: “192.168.1.13”
did: “00000000000000000000a078b00214re”
scan_interval: 0.5
friendly_names:
- Gang1name
- Gang2name
- Gang3name
- Gang4name
entity_ids:
- light.gang_1
- light.gang_2
- light.gang_3
- light.gang_4

above is my config yet I get an app Daemon compile error, no entities are created neither.
using the 4 gang switch, any help will be appreciated.

I only implemented the hub for a three gang switch; I didn’t realise it four gangs existed can you link your switch here please

If you can handle updating python hub.py set_state method is all that needs to be updated

    def set_state(
        self,
        did: str = None,
        pwr1: bool = None,
        pwr2: bool = None,
        pwr3: bool = None,
        pwr4: bool = None,
    ) -> dict:
        """Set the power state of the device."""
        state = {}
        if did is not None:
            state["did"] = did
        if pwr1 is not None:
            state["pwr1"] = int(bool(pwr1))
        if pwr2 is not None:
            state["pwr2"] = int(bool(pwr2))
        if pwr3 is not None:
            state["pwr3"] = int(bool(pwr3))
        if pwr4 is not None:
            state["pwr4"] = int(bool(pwr4))

        packet = self._encode(2, state)
        response = self.send_packet(0x6A, packet)
        e.check_error(response[0x22:0x24])
        return self._decode(response)

that is the device I’m using

Amazing that has fixed it. So great to have this in HA, what a great community. Thank you!

1 Like

That is unfortunately a button and not a switch; it’s not supported by my code and does not have any state. There was quite a bit of discussion about trying to support a button here Add Support for S3 Hub 0xa59c · Issue #647 · mjg59/python-broadlink · GitHub however due to the way works you are better off setting up a routine in the broad link app to capture button presses.

1 Like

Okay, I’ve activated AppDaemon - it’s working fine
I’ve copied the broadlink folder to \config\appdaemon\apps (latest version)
I’ve copied broadlink_s3_hub.py to \config\appdaemon\apps (latest version)
I’ve modified apps.yaml (I’ve got a 3-gang broadlink switch) in this folder to:

broadlink_s3_hub:
  module: broadlink_s3_hub
  class: BroadlinkS3Hub
  hub_ip: "192.168.68.106"
  did: "00000000000000000000a043b0d08cc1"
  scan_interval: 0.5
  friendly_names:
    - Gang 1 BigLight
    - Gang 2 Lamps
    - Gang 3 TVLights
  entity_ids:
    - light.gang1
    - light.gang2
    - light.gang3

I’ve restarted AppDaemon, and checked the WebUI, and under the State tab BroadlinkS3Hub has an initialize_error. AppDaemon log is as follows:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: AppDaemon
 Python Apps and Dashboard using AppDaemon 4.x for Home Assistant
-----------------------------------------------------------
 Add-on version: 0.8.2
 You are running the latest version of this add-on.
 System: Home Assistant OS 7.6  (aarch64 / raspberrypi3-64)
 Home Assistant Core: 2022.5.4
 Home Assistant Supervisor: 2022.05.1
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] appdaemon.sh: executing... 
[cont-init.d] appdaemon.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[17:01:11] INFO: Starting AppDaemon...
2022-05-15 18:01:16.856012 INFO AppDaemon: AppDaemon Version 4.2.1 starting
2022-05-15 18:01:16.857100 INFO AppDaemon: Python version is 3.9.7
2022-05-15 18:01:16.858458 INFO AppDaemon: Configuration read from: /config/appdaemon/appdaemon.yaml
2022-05-15 18:01:16.859927 INFO AppDaemon: Added log: AppDaemon
2022-05-15 18:01:16.861454 INFO AppDaemon: Added log: Error
2022-05-15 18:01:16.862602 INFO AppDaemon: Added log: Access
2022-05-15 18:01:16.864001 INFO AppDaemon: Added log: Diag
2022-05-15 18:01:16.985572 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2022-05-15 18:01:17.170464 INFO HASS: HASS Plugin Initializing
2022-05-15 18:01:17.171572 INFO HASS: HASS Plugin initialization complete
2022-05-15 18:01:17.174510 INFO AppDaemon: Initializing HTTP
2022-05-15 18:01:17.176947 INFO AppDaemon: Using 'ws' for event stream
2022-05-15 18:01:17.196671 INFO AppDaemon: Starting API
2022-05-15 18:01:17.214050 INFO AppDaemon: Starting Admin Interface
2022-05-15 18:01:17.216172 INFO AppDaemon: Starting Dashboards
2022-05-15 18:01:17.297136 INFO HASS: Connected to Home Assistant 2022.5.4
2022-05-15 18:01:17.383605 INFO AppDaemon: App 'hello_world' added
2022-05-15 18:01:17.393891 INFO AppDaemon: App 'broadlink_s3_hub' added
2022-05-15 18:01:17.399064 INFO AppDaemon: Found 2 total apps
2022-05-15 18:01:17.402775 INFO AppDaemon: Starting Apps with 2 workers and 2 pins
2022-05-15 18:01:17.409234 INFO AppDaemon: Running on port 5050
2022-05-15 18:01:17.721762 INFO HASS: Evaluating startup conditions
2022-05-15 18:01:17.769805 INFO HASS: Startup condition met: hass state=RUNNING
2022-05-15 18:01:17.771745 INFO HASS: All startup conditions met
2022-05-15 18:01:17.845520 INFO AppDaemon: Got initial state from namespace default
2022-05-15 18:01:19.436938 INFO AppDaemon: Scheduler running in realtime
2022-05-15 18:01:19.450035 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2022-05-15 18:01:19.452536 INFO AppDaemon: Adding /config/appdaemon/apps/broadlink to module import path
2022-05-15 18:01:19.523650 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/broadlink_s3_hub.py
2022-05-15 18:01:19.948839 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/hello.py
2022-05-15 18:01:19.956163 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/device.py - ignoring
2022-05-15 18:01:19.963140 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/remote.py - ignoring
2022-05-15 18:01:19.967922 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/alarm.py - ignoring
2022-05-15 18:01:19.973440 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/climate.py - ignoring
2022-05-15 18:01:19.979051 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/light.py - ignoring
2022-05-15 18:01:19.984215 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/helpers.py - ignoring
2022-05-15 18:01:19.989554 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/exceptions.py - ignoring
2022-05-15 18:01:19.995580 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/__init__.py - ignoring
2022-05-15 18:01:20.002163 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/switch.py - ignoring
2022-05-15 18:01:20.007412 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/hub.py - ignoring
2022-05-15 18:01:20.012814 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/const.py - ignoring
2022-05-15 18:01:20.017902 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/sensor.py - ignoring
2022-05-15 18:01:20.023627 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/protocol.py - ignoring
2022-05-15 18:01:20.029240 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink/cover.py - ignoring
2022-05-15 18:01:20.034642 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2022-05-15 18:01:20.044906 INFO AppDaemon: Initializing app broadlink_s3_hub using class BroadlinkS3Hub from module broadlink_s3_hub
2022-05-15 18:01:20.432441 INFO hello_world: Hello from AppDaemon
2022-05-15 18:01:20.437213 INFO hello_world: You are now ready to run Apps!
2022-05-15 18:01:22.267132 WARNING broadlink_s3_hub: ------------------------------------------------------------
2022-05-15 18:01:22.273155 WARNING broadlink_s3_hub: Unexpected error running initialize() for broadlink_s3_hub
2022-05-15 18:01:22.275805 WARNING broadlink_s3_hub: ------------------------------------------------------------
2022-05-15 18:01:22.290749 WARNING broadlink_s3_hub: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/appdaemon/app_management.py", line 165, in initialize_app
    await utils.run_in_executor(self, init)
  File "/usr/lib/python3.9/site-packages/appdaemon/utils.py", line 337, in run_in_executor
    response = future.result()
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/appdaemon/apps/broadlink_s3_hub.py", line 14, in initialize
    self.device.auth()
  File "/config/appdaemon/apps/broadlink/device.py", line 185, in auth
    e.check_error(response[0x22:0x24])
  File "/config/appdaemon/apps/broadlink/exceptions.py", line 152, in check_error
    raise exception(error_code)
broadlink.exceptions.AuthenticationError: [Errno -1] Authentication failed
2022-05-15 18:01:22.292439 WARNING broadlink_s3_hub: ------------------------------------------------------------
2022-05-15 18:01:22.298513 INFO AppDaemon: App initialization complete
2022-05-15 18:06:53.611227 INFO AppDaemon: New client Admin Client connected

Any ideas what I’ve managed to do wrong? I’ve triple-checked the hub IP and DID, they are correct.

EDIT: D’oh! The hub was locked in the Broadlink app, it’s now working! Thanks to all who developed this, great work!

1 Like

In my case. I’m getting an error starting the module. I can say my hub is categorically UNLOCKED in the Broadlink app. Here is my log output:

2022-05-16 22:58:35.470320 INFO AppDaemon: Added log: Error
2022-05-16 22:58:35.470857 INFO AppDaemon: Added log: Access
2022-05-16 22:58:35.472032 INFO AppDaemon: Added log: Diag
2022-05-16 22:58:35.528158 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2022-05-16 22:58:35.633813 INFO HASS: HASS Plugin Initializing
2022-05-16 22:58:35.635175 INFO HASS: HASS Plugin initialization complete
2022-05-16 22:58:35.637084 INFO AppDaemon: Initializing HTTP
2022-05-16 22:58:35.638651 INFO AppDaemon: Using ‘ws’ for event stream
2022-05-16 22:58:35.648674 INFO AppDaemon: Starting API
2022-05-16 22:58:35.656892 INFO AppDaemon: Starting Admin Interface
2022-05-16 22:58:35.658309 INFO AppDaemon: Starting Dashboards
2022-05-16 22:58:35.699897 INFO HASS: Connected to Home Assistant 2022.5.4
2022-05-16 22:58:35.747323 INFO AppDaemon: App ‘hello_world’ added
2022-05-16 22:58:35.751184 INFO AppDaemon: App ‘broadlink_s3_hub’ added
2022-05-16 22:58:35.754378 INFO AppDaemon: Found 2 total apps
2022-05-16 22:58:35.756212 INFO AppDaemon: Starting Apps with 2 workers and 2 pins
2022-05-16 22:58:35.760446 INFO AppDaemon: Running on port 5050
2022-05-16 22:58:35.946554 INFO HASS: Evaluating startup conditions
2022-05-16 22:58:35.973512 INFO HASS: Startup condition met: hass state=RUNNING
2022-05-16 22:58:35.974477 INFO HASS: All startup conditions met
2022-05-16 22:58:36.027473 INFO AppDaemon: Got initial state from namespace default
2022-05-16 22:58:37.320413 INFO AppDaemon: New client Admin Client connected
2022-05-16 22:58:37.776556 INFO AppDaemon: Scheduler running in realtime
2022-05-16 22:58:37.791825 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2022-05-16 22:58:37.793496 INFO AppDaemon: Adding /config/appdaemon/apps/broadlink-s3-hub-app-daemon to module import path
2022-05-16 22:58:37.831390 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/broadlink_s3_hub.py
2022-05-16 22:58:37.849427 WARNING Error: ------------------------------------------------------------
2022-05-16 22:58:37.850737 WARNING Error: Unexpected error loading module: /config/appdaemon/apps/broadlink_s3_hub.py:
2022-05-16 22:58:37.851508 WARNING Error: ------------------------------------------------------------
2022-05-16 22:58:37.857720 WARNING Error: Traceback (most recent call last):
File “/usr/lib/python3.9/site-packages/appdaemon/app_management.py”, line 993, in check_app_updates
await utils.run_in_executor(self, self.read_app, mod[“name”], mod[“reload”])
File “/usr/lib/python3.9/site-packages/appdaemon/utils.py”, line 337, in run_in_executor
response = future.result()
File “/usr/lib/python3.9/concurrent/futures/thread.py”, line 52, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/lib/python3.9/site-packages/appdaemon/app_management.py”, line 784, in read_app
self.modules[module_name] = importlib.import_module(module_name)
File “/usr/lib/python3.9/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1030, in _gcd_import
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “”, line 850, in exec_module
File “”, line 228, in _call_with_frames_removed
File “/config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink_s3_hub.py”, line 2, in
import broadlink
ModuleNotFoundError: No module named ‘broadlink’
2022-05-16 22:58:37.858599 WARNING Error: ------------------------------------------------------------
2022-05-16 22:58:37.860026 WARNING AppDaemon: Removing associated apps:
2022-05-16 22:58:37.860944 WARNING AppDaemon: broadlink_s3_hub
2022-05-16 22:58:37.868254 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/hello.py
2022-05-16 22:58:37.876173 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/helpers.py - ignoring
2022-05-16 22:58:37.879903 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/const.py - ignoring
2022-05-16 22:58:37.883319 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/remote.py - ignoring
2022-05-16 22:58:37.886926 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/exceptions.py - ignoring
2022-05-16 22:58:37.890113 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/alarm.py - ignoring
2022-05-16 22:58:37.893902 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/light.py - ignoring
2022-05-16 22:58:37.897363 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/cover.py - ignoring
2022-05-16 22:58:37.900920 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/climate.py - ignoring
2022-05-16 22:58:37.904568 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/sensor.py - ignoring
2022-05-16 22:58:37.909579 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/init.py - ignoring
2022-05-16 22:58:37.913830 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink_s3_hub.py
2022-05-16 22:58:37.921417 INFO Error: Previous message repeated 1 times
2022-05-16 22:58:37.922768 WARNING Error: Unexpected error loading module: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink_s3_hub.py:
2022-05-16 22:58:37.923895 WARNING Error: ------------------------------------------------------------
2022-05-16 22:58:37.926207 WARNING Error: Traceback (most recent call last):
File “/usr/lib/python3.9/site-packages/appdaemon/app_management.py”, line 993, in check_app_updates
await utils.run_in_executor(self, self.read_app, mod[“name”], mod[“reload”])
File “/usr/lib/python3.9/site-packages/appdaemon/utils.py”, line 337, in run_in_executor
response = future.result()
File “/usr/lib/python3.9/concurrent/futures/thread.py”, line 52, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/lib/python3.9/site-packages/appdaemon/app_management.py”, line 784, in read_app
self.modules[module_name] = importlib.import_module(module_name)
File “/usr/lib/python3.9/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1030, in _gcd_import
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “”, line 850, in exec_module
File “”, line 228, in _call_with_frames_removed
File “/config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink_s3_hub.py”, line 2, in
import broadlink
ModuleNotFoundError: No module named ‘broadlink’
2022-05-16 22:58:37.927436 WARNING Error: ------------------------------------------------------------
2022-05-16 22:58:37.928859 WARNING AppDaemon: Removing associated apps:
2022-05-16 22:58:37.934131 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/device.py - ignoring
2022-05-16 22:58:37.940143 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/hub.py - ignoring
2022-05-16 22:58:37.944537 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/protocol.py - ignoring
2022-05-16 22:58:37.948550 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/switch.py - ignoring
2022-05-16 22:58:37.951564 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2022-05-16 22:58:38.146845 INFO hello_world: Hello from AppDaemon
2022-05-16 22:58:38.149425 INFO hello_world: You are now ready to run Apps!
2022-05-16 22:58:38.153420 INFO AppDaemon: App initialization complete
2022-05-16 22:58:42.320700 INFO AppDaemon: New client Admin Client connected

Any help greatly appreciated.

Please add a subfolder with the name broadlink inside broadlink-s3-hub-app-daemon and copy everything inside broadlink-s3-hub-app-daemon to the broadlink folder and keep only broadlink_s3_hub.py outside that folder and then restart home assistant.

I did that. Sadly getting a new and improved error.

[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing…
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] appdaemon.sh: executing…
[cont-init.d] appdaemon.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[16:50:59] INFO: Starting AppDaemon…
2022-05-18 17:51:01.337168 INFO AppDaemon: AppDaemon Version 4.2.1 starting
2022-05-18 17:51:01.337885 INFO AppDaemon: Python version is 3.9.7
2022-05-18 17:51:01.338643 INFO AppDaemon: Configuration read from: /config/appdaemon/appdaemon.yaml
2022-05-18 17:51:01.339425 INFO AppDaemon: Added log: AppDaemon
2022-05-18 17:51:01.340268 INFO AppDaemon: Added log: Error
2022-05-18 17:51:01.341065 INFO AppDaemon: Added log: Access
2022-05-18 17:51:01.341771 INFO AppDaemon: Added log: Diag
2022-05-18 17:51:01.395462 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2022-05-18 17:51:01.489139 INFO HASS: HASS Plugin Initializing
2022-05-18 17:51:01.489965 INFO HASS: HASS Plugin initialization complete
2022-05-18 17:51:01.491302 INFO AppDaemon: Initializing HTTP
2022-05-18 17:51:01.492479 INFO AppDaemon: Using ‘ws’ for event stream
2022-05-18 17:51:01.502192 INFO AppDaemon: Starting API
2022-05-18 17:51:01.510591 INFO AppDaemon: Starting Admin Interface
2022-05-18 17:51:01.511754 INFO AppDaemon: Starting Dashboards
2022-05-18 17:51:01.552501 INFO HASS: Connected to Home Assistant 2022.5.4
2022-05-18 17:51:01.597675 INFO AppDaemon: App ‘two_gang_switch’ added
2022-05-18 17:51:01.600993 INFO AppDaemon: Found 1 total apps
2022-05-18 17:51:01.602640 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
2022-05-18 17:51:01.605113 INFO AppDaemon: Running on port 5050
2022-05-18 17:51:01.787125 INFO HASS: Evaluating startup conditions
2022-05-18 17:51:01.814752 INFO HASS: Startup condition met: hass state=RUNNING
2022-05-18 17:51:01.815959 INFO HASS: All startup conditions met
2022-05-18 17:51:01.869975 INFO AppDaemon: Got initial state from namespace default
2022-05-18 17:51:03.620885 INFO AppDaemon: Scheduler running in realtime
2022-05-18 17:51:03.629339 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2022-05-18 17:51:03.630435 INFO AppDaemon: Adding /config/appdaemon/apps/broadlink-s3-hub-app-daemon to module import path
2022-05-18 17:51:03.632203 INFO AppDaemon: Adding /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink to module import path
2022-05-18 17:51:03.661704 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/hello.py - ignoring
2022-05-18 17:51:03.664485 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink_s3_hub.py
2022-05-18 17:51:03.781714 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/helpers.py - ignoring
2022-05-18 17:51:03.784388 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/const.py - ignoring
2022-05-18 17:51:03.786655 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/remote.py - ignoring
2022-05-18 17:51:03.789272 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/exceptions.py - ignoring
2022-05-18 17:51:03.792269 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/alarm.py - ignoring
2022-05-18 17:51:03.795444 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/light.py - ignoring
2022-05-18 17:51:03.798536 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/cover.py - ignoring
2022-05-18 17:51:03.801544 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/climate.py - ignoring
2022-05-18 17:51:03.804416 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/sensor.py - ignoring
2022-05-18 17:51:03.807156 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/init.py - ignoring
2022-05-18 17:51:03.810028 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/broadlink_s3_hub.py
2022-05-18 17:51:03.815652 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/device.py - ignoring
2022-05-18 17:51:03.822416 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/hub.py - ignoring
2022-05-18 17:51:03.826962 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/protocol.py - ignoring
2022-05-18 17:51:03.831191 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/switch.py - ignoring
2022-05-18 17:51:03.834060 INFO AppDaemon: Initializing app two_gang_switch using class BroadlinkS3Hub from module broadlink_s3_hub
2022-05-18 17:51:04.736414 INFO AppDaemon: New client Admin Client connected
2022-05-18 17:51:04.971335 INFO two_gang_switch: Create entity with entity_id: ‘light.gang_1’
2022-05-18 17:51:04.973847 WARNING two_gang_switch: two_gang_switch: Entity light.gang_1 not found in namespace default
2022-05-18 17:51:05.018720 WARNING two_gang_switch: ------------------------------------------------------------
2022-05-18 17:51:05.020382 WARNING two_gang_switch: Unexpected error running initialize() for two_gang_switch
2022-05-18 17:51:05.021856 WARNING two_gang_switch: ------------------------------------------------------------
2022-05-18 17:51:05.028795 WARNING two_gang_switch: Traceback (most recent call last):
File “/usr/lib/python3.9/site-packages/appdaemon/app_management.py”, line 165, in initialize_app
await utils.run_in_executor(self, init)
File “/usr/lib/python3.9/site-packages/appdaemon/utils.py”, line 337, in run_in_executor
response = future.result()
File “/usr/lib/python3.9/concurrent/futures/thread.py”, line 52, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/broadlink_s3_hub.py”, line 20, in initialize
self._create_entity(index=i)
File “/config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/broadlink_s3_hub.py”, line 30, in _create_entity
state = self._get_device_state(entity_id=entity_id)
File “/config/appdaemon/apps/broadlink-s3-hub-app-daemon/broadlink/broadlink_s3_hub.py”, line 42, in _get_device_state
pwr = state[“pwr{gang}”.format(gang=gang)]
KeyError: ‘pwr1’
2022-05-18 17:51:05.029746 WARNING two_gang_switch: ------------------------------------------------------------
2022-05-18 17:51:05.032636 INFO AppDaemon: App initialization complete
2022-05-18 17:51:38.420055 INFO AppDaemon: New client Admin Client connected
2022-05-18 17:51:44.275717 INFO AppDaemon: Compiling dashboard ‘Hello’
2022-05-18 17:51:44.662014 INFO AppDaemon: function [get_dashboard] finished in 403 ms
2022-05-18 17:51:44.723971 INFO AppDaemon: Client disconnection from Admin Client
2022-05-18 17:51:45.064087 INFO AppDaemon: New client Hello Panel connected
2022-05-18 17:51:46.565246 INFO AppDaemon: Client disconnection from Hello Panel
2022-05-18 17:51:47.073942 INFO AppDaemon: New client Admin Client connected

Ok. Eventually managed to find the issues. Played around with the DID (which is effectively the device MAC address with a heap of zeros in front). I know there is a link to further up in this thread when this thing was still running in a docker container. I didn’t see explictly which device it should be.
So first up, I had the folder location issue. This is what works for me:
\homeassistant.local\config\appdaemon\apps\broadlink-s3-hub-app-daemon\broadlink ← this where all the py files should be located from alarm.py to switch.py
The broadlink_s3_hub.py should be a level up located in:
\homeassistant.local\config\appdaemon\apps\broadlink-s3-hub-app-daemon
Thanks @mnayef95 for clarrifying this, and obviously the hard work releasing this.
Then in your apps.yaml you should use the IP for your s3 hub and IMPORTANT the DID for your TC3 switch (in my case Office Wall Switch), NOT the DID for your S3 Hub (at least this is the way it is for me).
I now have the interesting challenge of adding another two switches (another 2 gang and a 3 gang).

1 Like

Thank you for the clarifications, regarding the DID yes it should be the DID for the switch, not the hub, and to get it just use the docker container shared by @stevendodd.

To be able to add multiple switches just duplicate the same config in the apps.yaml file and change the DID, something like this:

---
balcony:
  module: broadlink_s3_hub
  class: BroadlinkS3Hub
  hub_ip: "192.168.1.200"
  did: "00000000000000000000000000000001"
  scan_interval: 1
  friendly_names:
    - Balcony Light
  entity_ids:
    - light.balcony_light

bathroom:
  module: broadlink_s3_hub
  class: BroadlinkS3Hub
  hub_ip: "192.168.1.200"
  did: "00000000000000000000000000000002"
  scan_interval: 1
  friendly_names:
    - Shower Light
    - Toilet Light
  entity_ids:
    - light.shower
    - light.toilet

Thanks one observation I have. When I use the actual wall switch HA does not seem to get it’s status back. If you toggle the entity switch in HA it’s fine, however if you press the button on the wall it doesn’t update so if you turned it off at the switch HA thinks it’s on. I have a use case where I want to trigger an automation based by pressing the wall switch. Given I can’t poll it of status seemingly I can’t do this. In intend to do this in Node Red.
Any help greatly appreciated.

It works in the docker image implementation

Ok. So I set scan_interval from 1 to 0.5 and restarted and this seemed to help, but soon stopped working. I restarted the AppDaemon plugin again and it seems stable since. Will keep an eye on it.

So for me. I’m seeing this stop updating from the wallswitch itself about every 24 hours or so. I have the switch on a dashboard and if I press it on the wall it doesn’t update in Lovelace UI. I also am using a NodeRed EventState node for this entity to trigger an automation. This unsurprisingly stops as well.