ControllerX. Bring full functionality to light and media player controllers

Hi,

For the Hue dimmer, the documentation says:

This is the default mapping for this controller:

  • Click “I” → Turn on
  • Hold “I” → Color temp up / Right color wheel
  • Click :high_brightness: → Brighten up (1 step)
  • Hold :high_brightness:→ Brighten up
  • Click :low_brightness: → Dim down (1 step)
  • Hold :low_brightness: → Dim down
  • Click “O” → Turn off
  • Hold “O” → Color temp down / Left color wheel

But then the documentation also says:

Note

For ZHA integration, the hold events just work for the brightness buttons, and they are fired right after the click events. In case of working with z2m and wanting to use the multiclick functionality, then you need to make sure to remove from the device specific (devices.yaml) the multiple_press_timeout option.

Maybe I am a bit daft, but does this mean that ZHA doesn’t support holding the “I” button to change colour temperature?

Hi @valexi,

Yes, that is possible. You can use the mapping or merge_mapping attributes for this. The former overwrites the default mapping, the latter overwrite just the specified actions. You can read more about it in here. You can see which actions your controller fire in here, and you can see some real examples in here. This is an example for this controller for z2m:

example_app:
  module: controllerx
  class: E1810Controller
  controller: sensor.livingroom_controller_action
  integration: z2m
  light: light.livingroom
  merge_mapping:
    arrow_right_click: 
      service: script.my_script
    arrow_left_click:
      service: script.my_script2
      data:
        attr1: my_attribute
        attr2: my_attribute2

With merge_mapping, it overwrites the arrow clicks to call an HA service.

I hope this helps :slight_smile:

Regards,
Xavi M.

1 Like

Hi @MrTopKat,

When listening to the deconz events in Developer Tools, you will see an id attribute. That is what you need to put in the controller field from your configuration in apps.yaml. So if your controller id is tradfri_on_off_switch, then your config should look like:

zolder_panel_controller:
  module: controllerx
  class: E1743Controller
  controller: tradfri_on_off_switch
  integration: deconz
  light: light.panel_werkkamer

You can read more about how to extract the controller attribute in here.

I hope this helps :slight_smile:

Regards,
Xavi M.

1 Like

Hi @bjorn.sivertsen,

I am not 100% sure now. The ZHA integration for this controller changed recently, so maybe you can help me knowing if the message in the Note section is still valid. The problem was that if you listen to the zha_event in Developer Tools and you hold the “I” or “O” button, the device wouldn’t fire any action.

However, this was fixed, so Ii don’t think is valid anymore. If you can try, I will update the docs and remove that part.

You can also try and see if you can change the color_temp for your lights:

example_app:
   module: controllerx
   class: HueDimmerController
   controller: < your controller IEEE >
   integration: zha
   light: light.your_light

Regards,
Xavi M.

@xaviml Great! That’s exactly what I was looking for!

Hi Xavi, I can confirm it is actually working through the ZHA integration. So you can delete the addendum. :slight_smile:

Thanks @bjorn.sivertsen for the confirmation then :slight_smile:

Hello!

I now have a configuration for the MediaPlayerController:

  dachboden_controller_lms:
    module: controllerx
    class: E1744MediaPlayerController
    controller: lautstarkeregler_dachboden
    integration: deconz
    media_player: media_player.dachboden
    volume_steps: 30
    excluded_actions:
      - 1005 # 3 clicks

and another configuration for the triple click:

  dachboden_controller_lautsprecher:
    module: controllerx
    class: CustomSwitchController
    controller: lautstarkeregler_dachboden
    integration: deconz
    switch: switch.leiste_2
    mapping:
      1005: toggle

With merge_mapping this can be done in one configuration?
I didn’t found it in the documentation, only on this page: https://xaviml.github.io/controllerx/start/configuration!
How can I configure the toggle for the switch like in the above example?

Hi @carsten_h,

You can merge both configurations in one. However, you will need to toggle your switch with a call services. Configuration would be:

dachboden_controller_lms:
    module: controllerx
    class: E1744MediaPlayerController
    controller: lautstarkeregler_dachboden
    integration: deconz
    media_player: media_player.dachboden
    volume_steps: 30
    merge_mapping:
      1005:
         service: switch.toggle
         data:
           entity_id: switch.leiste_2

What is happening here is that the device will control your media player, but for the 1005 event, it will call a service to toggle the switch.

Regards,
Xavi M.

That should be no problem.
The configuration change is working fine! Thank you!
Now the configuration is a little bit more understandable!

1 Like

Hi @xaviml ,

Thanks. It is working now.

I see where I was wrong in the configuration (the controller-line).

Keep up to good work (and support),
Guido

1 Like

Hi,

I am having an issue where brightness up or down on button hold with a Ikea E1743 and Philips Hue Colour bulbs no longer works using z2m.

It was working some time ago with a switch that was very rarely used and i added a few more bulbs and another switch this weekend and noticed that the new bulbs woulden’t change brightness on hold, tried the old switch and is was also no longer working.

I have tried adding mappings for default actions and on/off works but brightness still wont change.

  mapping:
    "on": "on"
    "off": "off"
    up_hold: hold_brightness_up
    down_hold: hold_brightness_down

here is what is currently in my apps.yaml

study_controller:
  module: controllerx
  class: E1743Controller
  controller: sensor.study_switch_click
  integration: z2m
  light: light.study_light
    
hall_controller_1:
  module: controllerx
  class: E1743Controller
  controller: sensor.hall_switch_click
  integration: z2m
  light: light.hall_light_1_light
  
hall_controller_2:
  module: controllerx
  class: E1743Controller
  controller: sensor.hall_switch_click
  integration: z2m
  light: light.hall_light_2_light
  
hall_controller_3:
  module: controllerx
  class: E1743Controller
  controller: sensor.hall_switch_click
  integration: z2m
  light: light.hall_light_3_light
  
hall_controller_4:
  module: controllerx
  class: E1743Controller
  controller: sensor.hall_switch_click
  integration: z2m
  light: light.hall_light_4_light

and the z2m log from trying to lower brightness

info  2020-11-11 12:08:36: MQTT publish: topic 'zigbee2mqtt/Study Switch', payload '{"action":"on","battery":74,"click":"on","linkquality":84,"update":{"state":"available"},"update_available":true}'
info  2020-11-11 12:08:36: MQTT publish: topic 'zigbee2mqtt/Study Switch', payload '{"action":"","battery":74,"linkquality":84,"update":{"state":"available"},"update_available":true}'
info  2020-11-11 12:08:36: MQTT publish: topic 'zigbee2mqtt/Study Switch', payload '{"battery":74,"click":"","linkquality":84,"update":{"state":"available"},"update_available":true}'
info  2020-11-11 12:08:36: MQTT publish: topic 'zigbee2mqtt/Study Switch/action', payload 'on'
info  2020-11-11 12:08:36: MQTT publish: topic 'zigbee2mqtt/Study Switch/click', payload 'on'
info  2020-11-11 12:08:36: MQTT publish: topic 'zigbee2mqtt/Study Light', payload '{"brightness":254,"linkquality":87,"state":"ON","update":{"state":"idle"},"update_available":false}'
info  2020-11-11 12:08:39: MQTT publish: topic 'zigbee2mqtt/Study Switch', payload '{"action":"brightness_move_down","action_rate":83,"battery":74,"click":"brightness_down","linkquality":87,"update":{"state":"available"},"update_available":true}'
info  2020-11-11 12:08:39: MQTT publish: topic 'zigbee2mqtt/Study Switch', payload '{"action":"","battery":74,"linkquality":87,"update":{"state":"available"},"update_available":true}'
info  2020-11-11 12:08:39: MQTT publish: topic 'zigbee2mqtt/Study Switch', payload '{"battery":74,"click":"","linkquality":87,"update":{"state":"available"},"update_available":true}'
info  2020-11-11 12:08:39: MQTT publish: topic 'zigbee2mqtt/Study Switch/action', payload 'brightness_move_down'
info  2020-11-11 12:08:39: MQTT publish: topic 'zigbee2mqtt/Study Switch/click', payload 'brightness_down'
info  2020-11-11 12:09:07: MQTT publish: topic 'zigbee2mqtt/Study Switch', payload '{"action":"brightness_stop","battery":74,"click":"brightness_stop","linkquality":87,"update":{"state":"available"},"update_available":true}'
info  2020-11-11 12:09:07: MQTT publish: topic 'zigbee2mqtt/Study Switch', payload '{"action":"","battery":74,"linkquality":87,"update":{"state":"available"},"update_available":true}'
info  2020-11-11 12:09:07: MQTT publish: topic 'zigbee2mqtt/Study Switch', payload '{"battery":74,"click":"","linkquality":87,"update":{"state":"available"},"update_available":true}'
info  2020-11-11 12:09:07: MQTT publish: topic 'zigbee2mqtt/Study Switch/action', payload 'brightness_stop'
info  2020-11-11 12:09:07: MQTT publish: topic 'zigbee2mqtt/Study Switch/click', payload 'brightness_stop'

Has anyone any ideas what’s going wrong?

Hi @TenThirty,

The click sensor is deprecated now in Zigbee2MQTT and will be eventually removed. I just realised that the documentation for this controller does not reflect the real mapping for Z2M integration, so I will change this as soon as I can. The real mapping from code is:

def get_z2m_actions_mapping(self) -> TypeActionsMapping:
        return {
            "on": Light.ON,
            "off": Light.OFF,
            "brightness_move_up": Light.HOLD_BRIGHTNESS_UP,
            "brightness_move_down": Light.HOLD_BRIGHTNESS_DOWN,
            "brightness_stop": Light.RELEASE,
        }

EDIT: I have updated the documentation with these changes.

For your fix, you just need to change _click for _action in all your sensors:

study_controller:
  module: controllerx
  class: E1743Controller
  controller: sensor.study_switch_action
  integration: z2m
  light: light.study_light
    
hall_controller_1:
  module: controllerx
  class: E1743Controller
  controller: sensor.hall_switch_action
  integration: z2m
  light: light.hall_light_1_light
  
hall_controller_2:
  module: controllerx
  class: E1743Controller
  controller: sensor.hall_switch_action
  integration: z2m
  light: light.hall_light_2_light
  
hall_controller_3:
  module: controllerx
  class: E1743Controller
  controller: sensor.hall_switch_action
  integration: z2m
  light: light.hall_light_3_light
  
hall_controller_4:
  module: controllerx
  class: E1743Controller
  controller: sensor.hall_switch_action
  integration: z2m
  light: light.hall_light_4_light

Also, I see you use the same controller for different lights in your hall, my recommendation is to group your lights with Light Group or Group and then reduced your configuration to:

study_controller:
  module: controllerx
  class: E1743Controller
  controller: sensor.study_switch_action
  integration: z2m
  light: light.study_light
    
hall_controller:
  module: controllerx
  class: E1743Controller
  controller: sensor.hall_switch_action
  integration: z2m
  light: light.hall_lights

Hope this helps. Let me know if you have more questions :slight_smile:

Regards,
Xavi M.

Hi @xaviml

Thats all working great now, Thanks :grinning:. The lights were in a group before but in my flailing trying to get them to work i came accross a post of yours from a year ago where you mention groups not working and i was clutching at straws.

Hi @TenThirty,

I am glad you got it working now :slight_smile: Many things have changed in this past year. Now group lights are supported, and I have not received a problem from anyone about it. If you encounter any problem by doing so, let me know and I will help you with anything I can :slight_smile:

Regards,
Xavi M.

Hi,

I tried to do random effect for my living room IKEA lamp with this. It works in template editor, but in your appdaemon app it stops working.

livingroom_controller:
  module: controllerx
  class: E1810Controller
  controller: sensor.0x000d6ffffe54fd83_action
  integration: z2m
  light: light.living_room
  merge_mapping:
    brightness_up_release: 
      service: light.turn_on
      data:
        entity_id: light.living_room
        effect: 'okay'
    brightness_down_release: 
      service: light.turn_on
      data:
        entity_id: light.living_room
        effect: 'okay'
    arrow_right_click:
      service: light.turn_on
      data:
        entity_id: light.living_room
        effect: 'blink'
    arrow_left_click:
      service: light.turn_on
      data:
        entity_id: light.living_room
        effect: "{{ states.light['living_room'].attributes.effect_list[(range(0, (states.light['living_room'].attributes.effect_list | count))|random)] }}"

Hi @valexi,

ControllerX does not support templating yet, it is something that is on my list to implement. However, I will let you know a workaround for this that I hope works for you as it worked for me.

Go to Configuration > Scripts, ad create a new script. In there you can click on Edit as YAML (from the three dots) if you are in the latest version of HA. Copy & change this script:

alias: livingroom_random_effect
sequence:
  - service: light.turn_on
    data:
      entity_id: light.living_room
      effect: >-
        {{ states.light["living_room"].attributes.effect_list[(range(0,
        (states.light["living_room"].attributes.effect_list | count))|random)]
        }}
mode: single

Then, you will need to change your configuration from apps.yaml to:

livingroom_controller:
  module: controllerx
  class: E1810Controller
  controller: sensor.0x000d6ffffe54fd83_action
  integration: z2m
  light: light.living_room
  merge_mapping:
    brightness_up_release: 
      service: light.turn_on
      data:
        entity_id: light.living_room
        effect: 'okay'
    brightness_down_release: 
      service: light.turn_on
      data:
        entity_id: light.living_room
        effect: 'okay'
    arrow_right_click:
      service: light.turn_on
      data:
        entity_id: light.living_room
        effect: 'blink'
    arrow_left_click:
      service: script.livingroom_random_effect

Make sure of the name you give to the script since it will be the name you will need to use in the apps.yaml.

Let me know if you have any questions :slight_smile:

Regards,
Xavi M.

1 Like

Hi @xaviml,

I’m wondering if ControllerX could trigger a wall dimmer lamp switch to which a lamp is plugged-in (Example 45602 Lamp Dimmer Module by Jasco Products) ?

I’ve given a try but no success. I’m guessing the module is not seen as a lamp in HA.

Thanks,
Guy

Hi @guymaurier,

This is possible with ControllerX. You have 2 options:

  • Use the SwitchController directly to the switch.
  • Link the switch as a light in HA and use LightController in ControllerX.

I’m currently using the second options with some fairylights, which are controlled with an IKEA smart outlet. I have the following in the configuration.yaml from HA:

light:
  - platform: switch
    name: livingroom_fairylights
    entity_id: switch.livingroom_fairylights

This exposes an entity called light.livingroom_fairylights, which I can then treat as a light in my apps.yaml configuration.

If you share with us your configuration from apps.yaml, or the controller and the integration you are using, I will be able to help you with the config you need for ControllerX.

Cheers,
Xavi M.

I am on the edge of purchasing the Switchbot Curtain. The curtain isn’t compatible with HA (hope it will). HA does have a Switchbot integration, but it is only for the bot device.

There is an alternative method to connect the curtain to HA which requires another OS installation and uses node to communicate using URL format. In short, HA uses the shell Command to move the curtain. Something along the line of this: http:ip:5000/?id=mac_address

My question is. Is it possible to use the Tradfri E1743 switch to communicate to the curtain using the ControllerX add-on? A manual open/close button of the curtain would be great.

Tradfri E1743 ON/OFF Switch

Switchbot Curtain