ControllerX. Bring full functionality to light and media player controllers

Hi @xaviml.
Thanks for the offer. I had under estimated the requirements when finding out about ControllerX but with the reading I’ve done (great documentation btw) I’m finally caught up and understand the next steps (I’ve only been using HA for about a month now and slowly getting around the IoT protocols.
I’ve got z2m and MQTT configured in HA now and waiting on the CC2531 dongle to be delivered.

This might be a silly question but do I have to unsync my Hue dimmer from the Hue Bridge in order to use reconfigure some button? and I’m assuming I won’t have to flash the dimmer either, will I?

Hi @polow,

Glad to hear that you found the documentation useful, and that you are ditching the Hue Bridge in favour of a local solution like Zigbee2MQTT, you won’t regret :slight_smile:

You will need to pair the controller to the zigbee2mqtt network. You will need to follow these instructions to pair the controller: | Zigbee2MQTT or if you use the Zigbee2MQTT UI, then you will need to click in permit all (join). Then, you will need to reset the controller (instructions here). Once this is done, the controller will be in the zigbee2mqtt network, and not in the HueBridge one.

Regards,
Xavi M.

1 Like

Question… I’ve set a group of IKEA Fyrtur window blinds in a GROUP in deconz. But they end up as “light” domain in HA. When setting a light domain in a cover class appdeamon shows me the finger :stuck_out_tongue:
How can I set a group of covers in controllerx?

The group of window covers is showing up in HA as this: light.allrum_ovre_vaning

allrum_cover:
  module: controllerx
  class: E1766CoverController
  controller: allrum_tradfri_remote
  integration: deconz
  cover: cover.gardiner_allrum_ovre_vaning

@xaviml I managed to make the script fire when pressing the “hue button”! Thanks a lot!!

Additionally, I’ve also added 2 hue lamps and now trying to command them via the same hue dimmer (on/off and dim up an down via the 3 other buttons of the hue dimmer)

I created a group in z2m called Living_Room_lights.

However with this group things stop working

My yaml file is:

switchbot_app:
  module: controllerx
  class: Philips929002398602LightController
  controller: sensor.0x001788010927aa93_action
  integration: z2m
  #switch: switch.switchbot
  light: group.Living_Room_Lights
  merge_mapping:
    "off_press": #toggle
        - service: script.script1

if I only put one lamp such as below then it works

light: light.small_living_room_2

I am doing something wrong / misunderstanding the group function? Thanks!

Note: I unpaired the 2 hue lamps and the dimmer from the hue bridge

Hi @Minglarn,

First of all, I would recommend contacting deconz community for this issue since a group of cover should be translated as a cover entity and not light. However, you could also create a group of covers with Group integration, and then do the following:

allrum_cover:
  module: controllerx
  class: E1766CoverController
  controller: allrum_tradfri_remote
  integration: deconz
  cover: group.my_new_cover_group

where group.my_new_cover_group is the group created with group integration.

Another alternative is to use Cover group integration, and do the same but with a cover group.

Regards,
Xavi M.

Hi @polow,

I believe the problem is the entity group.Living_Room_Lights. Does this entity exist in your Home Assistant? If not, you will need to manually map it with the MQTT Light integration like done in here.

The light parameter from the ControllerX configuration must receive an entity that exists in Home Assistant. You can see all your entities in Home Assistant going to “Configuration > Entities”, and then search for the right entity.

Regards,
Xavi M.

You’re 100% right. That was it!

@xaviml last question so I understand correctly. I still have trouble grasping the functions of key “actions” and “mapping”.

Correct me if I’m wrong in my understanding:

  • “actions”, you list all events that you specifically want ControllerX to take over AND you implicitly exclude all non listed events to be taken over by ControllerX
  • “exclude_actions” you list all events you specifically don’t want ControllerX to take over AND you implicitly include all non listed events to be taken over by ControllerX
  • By default, if the key “actions” is omitted from the config, all events will be taken over by ControllerX
  • “mapping”, you replace the default action of the controller to what you specify
  • “merge_mapping”, you add an action to the default action of the controller
  • if you omit an action from “mapping” or “merge_mapping” it will keeps its default action

Here is where I get lost, if my assumptions are right, then:

  • where is it defined what a default action is, ie after I factory reset my Hue Dimmer switch, how does it know (or does it even know) that the “up” button for example is supposed to send a dim up signal to whatever light it’s been associated with?

  • if I don’t list the “up_press” event in actions in my config then, “up_press” event are implicitly ignored but if i list it in actions then it will dim up the lights I’ve associated it with in the apps.yaml (unless I map that even to something else in the config)

If you could help me understand, that’d be great. Currently I can’t dim up or down the lights with the Hue dimmer i’ve configured with ControllerX and not sure why or what I’m missing.

Hi @polow,

Please, find my answers below.

“actions”, you list all events that you specifically want ControllerX to take over AND you implicitly exclude all non listed events to be taken over by ControllerX

Correct, the available events can be found in the device page, under each integration (e.g. https://xaviml.github.io/controllerx/controllers/E1524_E1810)

“exclude_actions” you list all events you specifically don’t want ControllerX to take over AND you implicitly include all non listed events to be taken over by ControllerX

Correct, exclude_actions cannot be used together with actions, you will get an error.

By default, if the key “actions” is omitted from the config, all events will be taken over by ControllerX

Correct, all the events for that controller and that integration.

“mapping”, you replace the default action of the controller to what you specify

Correct, it “removes” the default mapping and just takes into account the events you specify. The key of the mapping is the event (what you would define in actions or exclude_actions and the value is the action(s) to be taken, which is what in ControllerX is called as action types. You can read more about the mapping and merge_mapping attribute in here.

“merge_mapping”, you add an action to the default action of the controller

It basically overwrites or add the action to the default mapping. If the action exists in the default mapping, then is overwritten, otherwise it gets added.

if you omit an action from “mapping” or “merge_mapping” it will keeps its default action

That is correct.

where is it defined what a default action is, ie after I factory reset my Hue Dimmer switch, how does it know (or does it even know) that the “up” button for example is supposed to send a dim up signal to whatever light it’s been associated with?

Good question, and probably it is not well explained in the documentation, so let me explain this to you. ControllerX has a list of supported devices, but the only thing we define for new devices is a default mapping. So, if you have a controller that is not in the list of supported devices, you can still use it if it is integrated with z2m, deconz or zha (well, zha might not work, but that is a separate topic). When a new device is added to ControllerX, I define a default mapping for that controller. For example in your case for the Philips Hue Dimmer, you can see the default mapping in this page under the Controller types (Light) section:

This is the default mapping for this controller:

Click release "on/off" → Turn on
Hold "on/off" → Color temp up / Right color wheel
Click release 🔆 → Brighten up (1 step)
Hold 🔆→ Brighten up
Click release 🔅 → Dim down (1 step)
Hold 🔅 → Dim down
Click release "hue" → Turn off
Hold "hue" → Color temp down / Left color wheel

This default mapping is defined in ControllerX, and we try to mimic what the controller does by default with the original integration (Tradfri, Hue Bridge, etc). However, if the ControllerX user is not happy with the default mapping, they can change it through configuration (mapping and merge_mapping). If you disagree with the default mapping for a Controller, you can raise your concern in GitHub issues, and we can discuss it. Some of the default mappings are done by intuition and not following 100% what the controller does with the original integration since it might be unknown by me (I do not have all the controllers ControllerX supports).

if I don’t list the “up_press” event in actions in my config then, “up_press” event are implicitly ignored but if i list it in actions then it will dim up the lights I’ve associated it with in the apps.yaml (unless I map that even to something else in the config)

These are different use cases you can do for the Philips929002398602LightController class:

  • If you do not add a mapping or merge_mapping, then the up_press event will bright up your light with 1 step.
  • If you add actions: [up_press], then the up_press will do the same, but the rest of the button won’t do anything since the only action included is up_press.
  • If you add mapping with up_press: toggle, then the up_press event will toggle the light, but the rest of the button won’t do anything since you used mapping and the default mapping gets overwritten.
  • If you add merge_mapping with up_press: toggle, then the up_press event will toggle the light, and the rest of the button will do what the default mapping specifies for this controller.

Hope this clarifies all your questions, and I also recommend you to go over some of the examples to see how different use cases can be configured.

Regards,
Xavi M.

1 Like

@xaviml really appreciate you taking all this time to give me a thorough response.

I do believe there is an issue somewhere, and maybe not with my config for the change of brightness of the lamp.
This is my apps code:

switchbot_app:
  module: controllerx
  class: Philips929002398602LightController
  controller: sensor.0x001788010927aa93_action
  integration: z2m
  manual_steps: 10 # it takes 10 steps to get from min to max brightness
#  mode: single
  light: light.Small_Living_Room_2 # entity being controlled
  actions: # the following actions are being controlled by ControllerX
    - on_press
    - off_press
    - up_press
    - up_press_release
    - up_hold
    - up_hold_release
    - down_press_release
    - down_hold
    - down_hold_release
  mapping: # replace default configuration for the following actions
    off_press: #launch script
        - service: script.script1
    on_press: toggle
    up_press_release: click_brightness_up
    down_press_release: click_brightness_down

It works fine for the on_press and off_press however the [up|down]_press[release|hold] gives me grief when I assign the click_brightness_*

I believe my config is valid because:

  • if I replace click_brightness_* by toggle, the light toggles
  • In the appDaemon logs I have the following:

2021-05-25 19:59:27.465293 WARNING switchbot_app: There is already an action executing for up_press_release. If you want a different behaviour change mode parameter, the default value is single.
2021-05-25 19:59:27.454081 INFO switchbot_app: :video_game: Button event triggered: up_press_release
2021-05-25 19:59:25.943749 INFO switchbot_app: :running_man: Running Predefined (click_brightness_up) now
2021-05-25 19:59:25.932983 INFO switchbot_app: :video_game: Button event triggered: up_press_release
2021-05-25 19:59:23.816234 INFO switchbot_app:

The Warning tells me that the event wasn’t “ack’d” or “received” by the light therefore the second up_press_release caused the Warning (in single Mode) so that there may be something wrong other than my apps.yaml
The MQTT logs show that all events are recorded correctly as well

I have tested with replacing click_brighthness_up with other predefined actions such as
on_min_brightness or toggle_full_brightness and all worked besides click_brighthness_up

Any idea?

Hi @polow,

Is the light turned on when up_press_release is called? Could you also share the zigbee2mqtt logs when the up button is pressed? I see this controller has up_press and up_press_release, and I would like to know what is the order of the calls for those actions when the button is pressed.

I also realized that the up_press_release and the down_press_release were not present in the ControllerX documentation for this controller, so I fixed the typo in the documentation.

Regards,
Xavi M.

Also @polow, it does not make sense to define actions if you then override it with mapping. So, it is the same if you remove all the actions block you have:

switchbot_app:
  module: controllerx
  class: Philips929002398602LightController
  controller: sensor.0x001788010927aa93_action
  integration: z2m
  manual_steps: 10 # it takes 10 steps to get from min to max brightness
#  mode: single
  light: light.Small_Living_Room_2 # entity being controlled
  mapping: # replace default configuration for the following actions
    off_press: #launch script
        - service: script.script1
    on_press: toggle
    up_press_release: click_brightness_up
    down_press_release: click_brightness_down

Hi @xaviml,
Yes the light is on when pressing up I also checked it was either at max or min brightness.

That’s the zigbee2mqtt logs from an up_press

> Zigbee2MQTT:info  2021-05-25 23:25:36: MQTT publish: topic 'zigbee2mqtt/Living_Room_Dimmer', payload '{"action":"up_press","battery":81.5,"linkquality":107}'
> Zigbee2MQTT:info  2021-05-25 23:25:36: MQTT publish: topic 'zigbee2mqtt/Living_Room_Dimmer', payload '{"action":"","battery":81.5,"linkquality":107}'
> Zigbee2MQTT:info  2021-05-25 23:25:36: MQTT publish: topic 'zigbee2mqtt/Living_Room_Dimmer/action', payload 'up_press'
> Zigbee2MQTT:info  2021-05-25 23:25:36: MQTT publish: topic 'zigbee2mqtt/Living_Room_Dimmer', payload '{"action":"up_press_release","battery":81.5,"linkquality":107}'
> Zigbee2MQTT:info  2021-05-25 23:25:36: MQTT publish: topic 'zigbee2mqtt/Living_Room_Dimmer', payload '{"action":"","battery":81.5,"linkquality":107}'
> Zigbee2MQTT:info  2021-05-25 23:25:36: MQTT publish: topic 'zigbee2mqtt/Living_Room_Dimmer/action', payload 'up_press_release'

I also realized that the up_press_release and the down_press_release were not present in the ControllerX documentation for this controller, so I fixed the typo in the documentation.

The up_press and down_press are also missing from your class definition for this controller but I guess it doesn’t really change much since it’s always followed by a *_press_release which is defined

What feels strange as well is that if I didn’t define up_press_release in the mapping, it should default to the predefined actions in the class (ie, Light.CLICK_BRIGHTNESS_*) but it doesn’t which also hints me there might be some bug with the brightness altogether?

I’ve tried to change the apps.yaml with the following but still no change of brightness occurs

mapping
on_press: click_brightness_up

Hi @polow,

This is a very weird bug, indeed. I don’t seem to find what is going on, but I am sure we are mising something…

Could you please try the following configuration and press the on button?

switchbot_app:
  log_level: DEBUG
  module: controllerx
  class: Philips929002398602LightController
  controller: sensor.0x001788010927aa93_action
  integration: z2m
  light: light.Small_Living_Room_2
  mapping:
    on_press: click_brightness_up

Then:

  • Restart AppDaemon addon
  • Turn on the light through Home Assistant
  • Press the on button once AppDaemon is initialized
  • Share the whole AppDaemon logs in here, including the initialization

Finally, do the same, but with on_press_release: click_brightness_up.

I would like check the whole logs in case we missed something.

EDIT: I added the debug level

Regards,
Xavi M.

Hi @xaviml I have sent you the log in a private message

1 Like

After checking logs and trying different things, we realised that the problem was due to the entity name, which is case sensitive, so it should not include the uppercase in this case.

1 Like

Trying to do a merge mapping but it won’t work

switch_controller_on:
  module: controllerx
  class: E1766CoverController
  controller: tradfri_open_close_remote_action
  integration: deconz
  switch: switch.on_off_plug_in_unit_12
  merge_mapping:
    1002:
      - service: switch.turn_on

any ides?
Debug says ; switch.on_off_plug_in_unit_12 is not recognized as a template

Hi @Fifthy ,

You are using E1766CoverController, if you want to use a switch, you should use E1766SwitchController.

Hope that solves the issue.

Regards,
Xavi M.

same issue :frowning:

Could you please share the AppDaemon logs (including initialization)?

Thanks,

Is this enough? Which switch should be turned on here?