ControllerX. Bring full functionality to light and media player controllers

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

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