ControllerX. Bring full functionality to light and media player controllers

That worked, thanks!!

Hi, I have been using the integration and its perfect.
I am using the 4 button IKEA controller (it doesnā€™t have the middle on/off button).

I am trying to map a 2 click action and 3 click action to toggle the individual lights.
The issue is that i donā€™t know how to define which button should be listen to for the double click (as there is no middle button).

This is what i have:

lounge_lights_4button:
  module: controllerx
  class: E2002Z2MLightController
  integration: z2m
  controller: sensor.lounge_remote_4button_action
  light: Lounge Lights
  merge_mapping:
    toggle$2:
      service: light.toggle
      data:
        entity_id: light.lounge_lamp_1
    toggle$3:
      service: light.toggle
      data:
        entity_id: light.lounge_lamp_2

Double and Triple clicks do nothing. All other features work ok (on/off, temperature, brightness)
How can i define which button should be listened to?

Thank you!

@xaviml
With addon-appdaemon V 0.15.2 the addon has been moved into a different folder outside the HA config folder. Hence the ControllerX config file is not accessable anymore under /config/appdaemon/apps/apps.yaml.

Do you have any advise how to deal with it and can tell us the implication for the ControllerX Project? Not sure if her in the comminity or on github discussion forum is the right place to talk about it.

Good source for those having issues because they missed to consider the braking change of path to secrets.yaml in appdaemon.yaml.

Thanks in advance!

I reported a bug for this one;
https://github.com/xaviml/controllerx/issues/875

I can not fix this issue

I am getting this with appdeamon:

s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
Log level is set to INFO
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-appdaemon: starting
s6-rc: info: service init-appdaemon successfully started
s6-rc: info: service appdaemon: starting
s6-rc: info: service appdaemon successfully started
s6-rc: info: service legacy-services: starting
[13:52:57] INFO: Starting AppDaemon...
s6-rc: info: service legacy-services successfully started
ERROR Error loading secrets file: /config/secrets.yaml
Traceback (most recent call last):
  File "/usr/bin/appdaemon", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/appdaemon/__main__.py", line 417, in main
    admain.main()
  File "/usr/lib/python3.11/site-packages/appdaemon/__main__.py", line 276, in main
    if "appdaemon" not in config:
       ^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable
[13:52:58] INFO: Service AppDaemon exited with code 1 (by signal 0)
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service appdaemon: stopping
s6-rc: info: service appdaemon successfully stopped
s6-rc: info: service init-appdaemon: stopping
s6-rc: info: service init-appdaemon successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service base-addon-log-level: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service base-addon-log-level successfully stopped
s6-rc: info: service base-addon-banner: stopping
s6-rc: info: service base-addon-banner successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

How to add the new config folder within Studio code server:

basically just add via File / Open Folder or File / Add Folder to Workspace
the folder /addon_configs/
After that you can find your apps.yaml :slight_smile:

Additional background and advise for developer of custom solutions:

1 Like

Hey everyone!

Iā€™m trying to integrate my Xiaomi Aqara E1 wireless remote switches (WXKG16LM and WXKG17LM) with ControllerX. So far itā€™s going pretty well, but I cannot get the hold action to work. Iā€™ve included a snippet from my apps.yaml below.

switch_light:
  module: controllerx
  class: WXKG17LMZ2MLightController
  integration:
    name: z2m
    listen_to: mqtt
  controller: "Switch friendly name"
  light:
    name: "Light friendly name"
    mode: mqtt
  mapping:
    single_left: toggle
    hold_left:
      action: hold
      attribute: brightness
      direction: toggle
      mode: stop

The single_left action is working just fine, turning the light on and off. However, the hold_left action only seems to increase the brightness of the light. Once it hits full brightness, pressing and holding the same button again does absolutely nothing (or so it seems, at least).

Below is a snippet of the code I added to controllerx/cx_devices/aqara.py to integrate my switches.

class WXKG17LMZ2MLightController(Z2MLightController):
    def get_z2m_actions_mapping(self) -> DefaultActionsMapping:
        return {
            "single_both": Z2MLight.TOGGLE,
            "single_left": Z2MLight.TOGGLE,
            "double_left": Z2MLight.CLICK_BRIGHTNESS_UP,
            "hold_left": Z2MLight.HOLD_BRIGHTNESS_TOGGLE,
            "single_right": Z2MLight.TOGGLE,
            "double_right": Z2MLight.CLICK_BRIGHTNESS_UP,
            "hold_right": Z2MLight.HOLD_BRIGHTNESS_TOGGLE
        }

Does anybody see what Iā€™m doing wrong?

Hi,

I am struggling to get ControllerX to work. Iā€™ve installed it recently like a week ago. I am able to edit the yaml files in the new location. I tried everything I could think off but no results and no idea where and what to look for in logs etc.

Any help is much appreciated!

What I see in Appdeamon under Events - MQTT is all traffic being sent. (so looks good I assume)

These are my yaml files:

secrets: /homeassistant/secrets.yaml
appdaemon:
  latitude: 52.379189
  longitude: 4.899431
  elevation: 2
  time_zone: Europe/Amsterdam
  plugins:
    HASS:
      type: hass
    MQTT:
      type: mqtt
      namespace: mqtt # This is important
      client_host: 192.168.2.2 #
      client_user: addons #
      client_password: !secret mqtt_pw
http:
  url: http://127.0.0.1:5050
admin:
api:
hadashboard:
# keuken_controller:
#   module: controllerx
#   class: Philips929002398602Z2MLightController
#   controller: New Hue Dimmer
#   integration:
#     name: z2m
#     listen_to: mqtt
#     action_key: action
#   light:
#     name: Keuken Spot 1
#     mode: mqtt

example_app:
  module: controllerx
  class: Philips929002398602LightController
  integration: z2m
  controller: sensor.new_hue_dimmer_action
  light: light.keuken_spot_1

Can you check your directory structure - if you navigate to the root directory, do you have the addon_configs folder like this:

and then an xxxx_appdaemon folder within that one? Then within that one you should have your appdaemon.yaml file that you posted above, as well as an apps folder? Inside the apps folder, you should have your apps.yaml file as well as a controllerx folder?

I think I miss the ControllerX folder. All others I can find.
image

I have found it here:

Can I just copy over all files to the new directory? What happens when an update is pushed?

Update Iā€™ve copied the whole directory ControllerX into the apps folders and now it works! Thanks so much!

Still the questions how updates will be handled in the future?

OK, so when I updated to the latest version from an older version of AppDaemon, I ā€˜thinkā€™ all of those folders must have moved, as I still have the same appdaemon folder as you in my config folder, but that appdaemon folder in that location is empty.

It might be worth taking a backup of your appdaemon and controllerx files and settings, and then uninstalling both, and reinstalling, to see if they install with the correct folder structure, rather than just manually moving them, so as to avoid potential issues with further updates.

I actually did that but the files were installed in the old location unfortunately.
Iā€™il give it another try though

I have E1810 on z2m, I only want to use the brightness up/down buttons to dim the light. The other buttons I have assigned for different switches:

tvroom_licht:
  module: controllerx
  class:  E1810Controller     
  integration: z2m
  controller: sensor.0x000d6ffffe343d9c_action 
  light: light.0x680ae2fffe3f7f03_light 
  actions:
    - brightness_up_click
    - brightness_down_click

But there is no brightness high/low action. Any suggestions?

Iā€™ve also bought an Aqara E1 aka WXKG17LM which seems not officially supported (yet).

Did you make any progress?

For ZHA the eventsā€¦

@Doublet I think youā€™re best off using the mapping or merge_mapping functions to do this and take only the functions that you want to assign.

Edit: after re-reading your post, it looks like you want the up/down to also control on/off for the light? In that case, I would replace the hold actions on_full_brightness and "off" and also use smooth_power_on: true so that the first up click turns on at minimum brightness.

Something like:

tvroom_licht:
  module: controllerx
  class:  E1810Controller
  integration: z2m
  controller: sensor.0x000d6ffffe343d9c_action
  light: light.0x680ae2fffe3f7f03_light
  smooth_power_on: true
  mapping:
    2001: on_full_brightness
    2002: click_brightness_up
    3001: "off"
    3002: click_brightness_down

Thanks, still no luck, will keep on trying

Have you tried removing your other configurations? Use only one config for a given controller at a time and then add them back in to see what works and what doesnā€™t.

Hello all,
I was trying to use ControllerX instead of manually programming each buttonā€¦ but now I have spent WAY more time trying to get it to work than actually setting up an integration for each button press.
However I have sent so much time that I donā€™t want to uninstall, I am stubborn.

I have apps.yaml (inside a0d7b954_addons) as

---
hello_world:
  module: hello
  class: HelloWorld

coffeestation_controller:
  module: controllerx
  class: E1810Controller
  controller: sensor.coffee_remote_action
  integration: z2m
  light: light.coffee_station

AppDaemon log looks ok:

2023-12-27 14:41:58.413882 INFO AppDaemon: App 'hello_world' added
2023-12-27 14:41:58.418869 INFO AppDaemon: App 'coffeestation_controller' added
2023-12-27 14:41:58.421630 INFO AppDaemon: Found 2 active apps
2023-12-27 14:41:58.422670 INFO AppDaemon: Found 0 inactive apps
2023-12-27 14:41:58.424147 INFO AppDaemon: Found 0 global libraries
2023-12-27 14:41:58.425360 INFO AppDaemon: Starting Apps with 2 workers and 2 pins
2023-12-27 14:41:58.429949 INFO AppDaemon: Running on port 5050
2023-12-27 14:41:58.558536 INFO HASS: Evaluating startup conditions
2023-12-27 14:41:58.586447 INFO HASS: Startup condition met: hass state=RUNNING
2023-12-27 14:41:58.587260 INFO HASS: All startup conditions met
2023-12-27 14:41:58.660180 INFO AppDaemon: Got initial state from namespace default
2023-12-27 14:42:00.441267 INFO AppDaemon: Scheduler running in realtime
2023-12-27 14:42:00.447235 INFO AppDaemon: Adding /config/apps to module import path
2023-12-27 14:42:00.450721 INFO AppDaemon: Loading App Module: /config/apps/hello.py
2023-12-27 14:42:00.540523 INFO AppDaemon: Loading app hello_world using class HelloWorld from module hello
2023-12-27 14:42:00.544854 INFO AppDaemon: Calling initialize() for hello_world
2023-12-27 14:42:00.733881 INFO hello_world: Hello from AppDaemon
2023-12-27 14:42:00.738053 INFO hello_world: You are now ready to run Apps!
2023-12-27 14:42:00.741358 INFO AppDaemon: App initialization complete
2023-12-27 14:42:01.692925 INFO AppDaemon: New client Admin Client connected

When going on the webUI of AppDaemon v4.4.2 I can see

My remote and my lights are working (zigbee2mqtt and showing as devices in mqtt integration, I can turn them on/off with toggle)

Now whatā€™s the next step? Clicking the remote buttons donā€™t change anything on the lights. I tried adding this to the config but still nothing.

  actions:
    - "on"
    - "off"

Any help really appreciated