ControllerX. Bring full functionality to light and media player controllers

Hi @duceduc,

ControllerX acts as a middle service between your remote and entities from HA. It helps you write easier controller-based automations, so it is pretty flexoble in general. I see at least 3 differents options for the question you have:

  • Have your Switchbot curtain integrated as a Cover entity via Cover Template or Command Line Cover. Then you can use the E1743CoverController from ControllerX
  • Have your Switchbot curtain integrated as Switch entity via Switch Template or Command Line Switch. Then you can use the E1743SwitchController from ControllerX
  • Use Controller from ControllerX and call the shell command service from the app.yaml

The last one will not require add any custom integration, but if I were you, I would go for the 1st option. This way you will be able to add this entity in your lovelace dashboard and it will be recognized as a cover/curtain.

Hope this helps :slight_smile:

Regards,
Xavi M.

1 Like

@xaviml Thanks it works now.

But the correct code for calling script is :wink::

   arrow_right_click:
       service: script.turn_on
       data:
         entity_id: script.livingroom_random_effect
   arrow_left_click:
       service: script.turn_on
       data:
         entity_id: script.livingroom_random_effect
1 Like

Can the Aqara WXCJKG11LM be used for switch controls too?

Hi @Danzal,

Yes, it can be used for switches as well. You can leverage SwitchController class for this. For example:


example_app:
  module: controllerx
  class: SwitchController
  controller: sensor.your_controller_action
  integration: z2m
  switch: switch.my_switch
  mapping:
    button_1_single: "on"
    button_2_single: "off"

So by using the SwitchController, you need to define your own mapping with the mapping attribute. In this case, I am making the left button to turn on and the right to turn off the switch.

Regards,
Xavi M.

1 Like

Thanks! Your a legend!

1 Like

Hi @xaviml

I was wondering if there was any plans to add z2m integration for the E1766 controller?
I have a couple of Furtyr blinds that uses that controller, and cant seem to get it working on my system. Or do you know of a way to actually make the controller work with z2m?

Wessller

Hi @wessller,

I normally add myself the integration for the controllers I have. For the controllers I don’t have, I trust to the community on their integration. Adding a new support for a controller is easy, I just need the model of the controller and the mapping of the fired actions. If you have the E1766 integrated with Zigbee2MQTT, you can fill this form with the needed information.

Regards,
Xavi M.

v4.2.0 is now released :partying_face:

downloads
This minor change does not contain any breaking changes.
Note: Remember to restart the AppDaemon addon/server after updating to a new version.

:video_game: New devices

  • WXKG11LM - add light controller support for ZHA [ #141 ] @ilarrain
  • WXKG02LM - add switch controller [ #161 ]
  • SNZB-01 - add light controller support for ZHA [ #170 ]
  • MLI-404011 - add light controller support for z2m [ #176 ]

:hammer: Fixes

  • Fix deCONZ mapping for WXKG12LM 1006 -> 1007 [ #184 ]

:wrench: Refactor

  • Internal refactor of how classes are reused, so the next features will be easier to integrate. [ #181 ]
2 Likes

:exploding_head: :exploding_head: I do love this integration…top work @xaviml

1 Like

Thank you @Danzal, I appreciate your comment :slight_smile:

Phantastic extension. There is just one question I have. I want to program the “long press Off”-button of my Hue Dimmer as a “go to sleep”-button.

Let’s say I long press the “O”-button I want to execute multiple things:

  • Turn the light dark immidiately
  • Turn off the TV
  • Turn of the light completely off after 10 seconds

How to archive this? As soon as I define multiple actions the extension won’t execute them anymore:


hue_dimmer_wohnzimmer:
  module: controllerx
  class: HueDimmerController
  controller: dimmer_switch
  integration: deconz
  light: light.wohnzimmer
  action_delay:
    "off": 10
  merge_mapping:
    1000: on_full_brightness
    4001:
      - on_min_brightness
      - service: script.turn_off_tv
      - "off"

Any suggestions?

Hi. I have created a switch entity for the curtain and will be using the Ikea E1743 on/on button. Is this all I need to setup? It has been awhile since I add device to ControllerX. I just need to restart appdeamon for new device to take affect?

living_room_curtains:
  module: controllerx
  class: SwitchController
  controller: sensor.my_controller_action
  integration: z2m
  switch: switch.lr_curtains
  mapping:
    button_1_single: "on"
    button_2_single: "off"

Normally you only have to edit the config-file. The changes take effect immediately.

Ok. I am confuse as to what goes in the mapping section. I understand the right side, but the left side where do I find that info?

living_room_curtains:
  module: controllerx
  class: E1743SwitchController
  controller: sensor.cr_curtains_action
  integration: z2m
  switch: switch.cr_curtains
  mapping:
    button_1_single: "on"
    button_2_single: "off"

switch:

  - platform: template
    switches:
     cr_curtains:
       friendly_name: 'Computer Room Curtains'
       value_template: "{{ is_state('cover.cr_curtains', 'open') }}"
       turn_on:
         service: cover.open_cover
         data:
           entity_id: cover.cr_curtains
       turn_off:
         service: cover.close_cover
         data:
           entity_id: cover.cr_curtains

I think I got it. You get the values from this page depending on your device and integration used. So for me it would be this. For the on off values, make sure to wrap in quotes or it will be read as boolean.

  mapping:
    "on": "on"
    "off": "off"

@xaviml great job. You must have put a lot of work into this project. Great job!
I managed to set it up with E1810 Ikea controller (basic scenario).
Having some troubles with multiple and fast clicks.

My light bulb is ikea with white temperatures (cold, neutral, warm)
Below is my config.

Couple of questions:

  • is there some setting to speed up the color and brightness change when I hold the button?
  • how can I make 3 quick clicks go 3 levels down/up. Now after 3 quick clicks, there is delay and then only one level goes down/up. I tried to play with action_delta but no lock.
  • can I define mutliple actions for a button in mappings? (example of 1002$2 mapping below)

With the below settings, I can make the multiple_clicks actions triggered but I must click rather slow… and its difficult to make it working every time.

livingroom_controller:
  module: controllerx
  class: E1810Controller
  controller: tradfri_remote_control
  integration: deconz
  light: light.color_temperature_light_3
  multiple_click_delay: 1000 # 500 default
  action_delta: 10
  merge_mapping:
'#'    1002$2:                      # toggle
'#'      - "on"
'#'      - set_half_color_temp
'#'      - set_half_brightness
    4002$2: set_half_color_temp    # click_arrow_left
    5002$2: on_full_color_temp   # click_arrow_right
    3002$2: on_min_brightness    # down
    2002$2: on_full_brightness   # up

Hi @viertausend,

There are 2 things to know here:

  • First, ControllerX does not allow to add a list of predefined actions (like on_min_brightness and "off"), but it allows to add a list of services. This because predefined actions are executed to the same entity, so it does not make sense to turn off a light and change its brightness.
  • Second, deCONZ sends a periodic event (4001) when the “O” is pressed. This is a known deCONZ problem which has not been overcome yet. For this I recommend using action_delta. This attribute allows ControllerX to not execute any repeated action under the X configured milliseconds.

I know this would seem complicated, but the only way of achieving this is splitting the configuration:

hue_dimmer_wohnzimmer_min_brightness:
  module: controllerx
  class: HueDimmerController
  controller: dimmer_switch
  integration: deconz
  light: light.wohnzimmer
  action_delta: 1000 # increase this time if the hold actions are executed periodically
  merge_mapping:
    1002: on_full_brightness # Recommend to use X002 actions and not X000 for clicks, read the note in here: https://xaviml.github.io/controllerx/controllers/hue-dimmer-switch
    4001: on_min_brightness

hue_dimmer_wohnzimmer_tv_off:
  module: controllerx
  class: HueDimmerController
  controller: dimmer_switch
  integration: deconz
  light: light.wohnzimmer
  action_delta: 1000 # increase this time if the hold actions are executed periodically
  mapping: # Note we use now the `mapping` attribute
    4001:
      service: script.turn_off_tv

hue_dimmer_wohnzimmer_light_off:
  module: controllerx
  class: HueDimmerController
  controller: dimmer_switch
  integration: deconz
  light: light.wohnzimmer
  action_delay:
    4001: 10 # Execute 4001 event after 10 seconds
  action_delta: 1000 # increase this time if the hold actions are executed periodically
  mapping: # Note we use now the `mapping` attribute
    4001: "off"

Now, when holding the button, the hue_dimmer_wohnzimmer_min_brightness and hue_dimmer_wohnzimmer_tv_off will be triggered, so light will be dimmed and TV will turn off. It will also register a trigger to turn off the light in 10 seconds.

I hope this helps :slight_smile:

Regards,
Xavi M.

Hi @duceduc,

You are correct, the left side is a device-specific and integration configuration, so it depends on the device and the integration you are using on the device. What goes in the right are predefined actions or Service calls. So just to clarify:

So if you are using the SwitchController, the available actions (found in the custom mapping page) are:

  • open
  • close
  • stop
  • toggle_open
  • toggle_close

So using “on” and “off” in the right side will not work as expected since those actions don’t exist. So configuration would look like:

living_room_curtains:
  module: controllerx
  class: SwitchController
  controller: sensor.cr_curtains_action
  integration: z2m
  switch: switch.cr_curtains
  mapping:
    "on": open # when "on" fired perform "open" action
    "off": close # when "off" fired perform "close" action

However, the default mapping for E1743SwitchController is already doing this and more. It also allows you to hold-release to open/close and stop by pressing any button it’s opening or closing. If you want such behavior, the configuration should be:

living_room_curtains:
  module: controllerx
  class: E1743SwitchController
  controller: sensor.cr_curtains_action
  integration: z2m
  switch: switch.cr_curtains

Let me know if you have any more questions :slight_smile:

Regards,
Xavi M.

1 Like

Hi @duzybako,

Thanks for the appreciation and welcome to the community forum :slight_smile:

-is there some setting to speed up the color and brightness change when I hold the button?
-how can I make 3 quick clicks go 3 levels down/up. Now after 3 quick clicks, there is delay and then only one level goes down/up. I tried to play with action_delta but no lock.

You can use manual_steps to define the steps done when pressing the button. So manual_steps: 2 means that you will go from minimum to half in one click, and from half to the maximum in the second one. The higher the number, the more steps and the more time it will take to go from min to max. You can also play with the delay attribute (350 by default) to change the frequency that ControllerX calls HA to change the brightness/color_temp, the higher the slower it will be, but I don’t recommend lowering this more than ~200.

Regarding the delay you see when pressing is because you have the multi-click activated for the presses. You have also configured multiple_click_delay: 1000, meaning that it waits a whole second to identify if that was a single click or a double one.

can I define mutliple actions for a button in mappings? (example of 1002$2 mapping below)

No, it is not possible to define multiple predefined actions in a list, just call services. For this, you will need to split your configurations.

The following configuration does what I think you want to achieve:

livingroom_controller:
  module: controllerx
  class: E1810Controller
  controller: tradfri_remote_control
  integration: deconz
  light: light.color_temperature_light_3
  manual_steps: 2
  merge_mapping:
    1002$2: set_half_color_temp # setting the light to half temp or brightness already turns the light on.
    4002$2: set_half_color_temp    # click_arrow_left
    5002$2: on_full_color_temp   # click_arrow_right
    3002$2: on_min_brightness    # down
    2002$2: on_full_brightness   # up

livingroom_controller_half_brightness:
  module: controllerx
  class: E1810Controller
  controller: tradfri_remote_control
  integration: deconz
  light: light.color_temperature_light_3
  mapping:
    1002$2: set_half_brightness

I would leave the multiple_click_delay to the default (500) since you are using deCONZ and it is faster than other integrations. So, unless you have the conbee II and the controller far away, you don’t need to change this setting, but if you have a slow network, then you an change this value to be higher. The higher the multiple_click_delay the more time you need to wait to see the action be performed when clicking since the multiple_click_delay is the time that ControllerX is waiting to receive another action from the controller to know how many times the button was clicked. Remember that this is done within ControllerX and it is not natively working from your controller.

Let me know if you have any questions :slight_smile:

Regards,
Xavi M.

I am wondering what people were doing before controllerx. It seems to be so convenient and somehow I have trouble understanding how such functionality is missing from/more difficult to achieve with homeassistant alone.

Thanks, @xaviml!

1 Like

Thanks @chbndrhnns!

This is exactly the same question I wondered myself when I started the project. I had to create a very long YAML automation with a python script to achieve something that with ControllerX is 6 lines of YAML. Hopefully, we will get a functionality like ControllerX in Home Assistant one day. I would love to have an image of my controller in the UI and with few clicks be able to set the behaviour for the click (or hold, release, etc.) action of each button.

Regards,
Xavi M.

1 Like