ControllerX. Bring full functionality to light and media player controllers

Hi @iverona ,

That is correct. The time constraints is a feature from AppDaemon, and something that works well for ControllerX to control timings. For now, there is no other way to setup different behaviours in different times without creating a config per time constraint.

However, you could create a config with YAML anchors to not repeat common configuration.

Regards,
Xavi M.

1 Like

Hi @xaviml ,

Thanks for creating and sharing this great add on!

I wanted to get into Home Assistant and AppDaemon programming, but just started to scratch the surface.
As first touch I thought I could use ControllerX, set up my Ikea 1743 switch and then dive a bit into the ControllerX code. But I failed with setting up my light already. Damn!

I always get an error:

INFO light_kitchen_cupboard_underlight: ļæ½ ControllerX v4.23.0
WARNING light_kitchen_cupboard_underlight: light_kitchen_cupboard_underlight: Entity binary_sensor.gf_kitchen_cupboard-underlight_switch not found in namespace default

Here is what I did:

appdaemon/apps/apps.yaml:

light_kitchen_cupboard_underlight:
  module: controllerx
  class: E1743Controller
  controller: binary_sensor.gf_kitchen_cupboard-underlight_switch
  # also tried following:
  # controller: binary_sensor.gf_kitchen_cupboard-underlight_switch_action
  integration: z2m
  light: light.gf_kitchen_cupboard-underlight

zigbee2mqtt/devices.yaml:

...
'0x84ba20fffea45b03':
  friendly_name: gf_kitchen_cupboard-underlight_switch
...
'0x00124b0022640d82':
  friendly_name: light.gf_kitchen_cupboard-underlight
  homeassistant:
    switch:
      type: light
      object_id: light_blub
    light_blub:
      name: GF Kitchen Cupboard Light
      value_template: null
      state_value_template: '{{ value_json.state }}'

Strangely there are only two attributes listed in the developer tools:

Where I have clearly listed the action in the Z2M device exposes page:

First of all: ControllerX is such a great integration which solves so many issues I had with multiple BluePrints / Automations to get the Controller up and running smoothly!

I am currently struggeling with a Friends of Hue controller aka PTM215X (in my case it is a PTM 215Z), because they classical scenario how the Hue App would offer, Button 1+2 for switching on/off Light A and Button 3+4 for the same of Light B.
According to my understanding the light definition can be only be a single light device or a light group, but you canā€™t specify 2 lights which are linked separately to 1+2 and 3+4, correct?

Has anyone solved suche a scenario by Custom mapping?

Hi @EspWhaleSong ,

I see your controller is a type binary_sensor, and if you have the E1743 device integrated with Zigbee2MQTT you should have a sensor called sensor.gf_kitchen_cupboard-underlight_switch_action in Home Assistant. That is the sensor you should be using for this controller. You can read here how to extract the controller attribute for Zigbee2MQTT: How to extract the controller parameter - ControllerX.

A binary_sensor only exposes on and off, and the E1743 device has more than 2 actions: E1743 - ControllerX

Regards,
Xavi M.

Hi @Bastian007,

If you want to control more than 1 light with the same controller, you have 2 options:

  • Create 2 configurations and use actions or mapping key.
  • Create 1 configuration and control the other light with services. However, this limits you to just use HA services and you will not be able to use hold actions for the second light.

So, I would personally go for option number one. This is an example of what you can do with the PTM215X controller:

light_1:
  module: controllerx
  class: PTM215XLightController
  integration: z2m
  controller: sensor.my_controller_action
  light: light.light_1
  mapping:
    press_1: toggle
    press_2: hold_brightness_toggle
    release_2: release

light_2:
  module: controllerx
  class: PTM215XLightController
  integration: z2m
  controller: sensor.my_controller_action
  light: light.light_2
  mapping:
    press_3: toggle
    press_4: hold_brightness_toggle
    release_4: release

Both configurations do the same, but the first is for light_1 with 1+2, and the second one is for light_2 with 3+4. Note that I am assuming that press_X is also triggered when buttons are held.

Regards,
Xavi M.

1 Like

Hi @xaviml ,

thanks for chiming in!

I am sure you are right. I had a discussion on the M2Z discord with Rene Tode about it. He guided me through all the steps, till we concluded itā€™s HAā€™s bug or problem it doesnā€™t create the sensor called sensor.gf_kitchen_cupboard-underlight_switch_action.

As I want to get a bit deeper into HA I have downloaded the source of HA, created the VSC development container, but fail at the dependencies in the momentā€¦ Maybe I can find an issue.

Hi @EspWhaleSong ,

Id you do not have the sensor entity, I would say it is a problem from Zigbee2MQTT. Do you have the latest addon?

I would recommend you to start clean with that device, and if you cannot integrate, then you can inegrate it in ControllerX with the MQTT plugin. You can read more about it in the Zigbee2MQTT section here: Integrations - ControllerX

Regards,
Xavi M.

Was my initial thought as well, to be Z2Mā€™s fault. But after the discussion I think itā€™s a HA problem as well.

Adding a new device to Z2M shows in the logs. It sends the MQTT messages and HAā€™s MQTT integration (core integration) should create the sensors for it.

I just upgraded everything to the latest (HA and all add-ons) versions, deleted the Ikea E1743 from Z2M and HA and restarted HA Core. After this I added the E1743 again. Still no _action sensorā€¦

Anyway, I tried to follow your recommendation and set it up with MQTT directly instead. This is my apps.yaml, which works for the office switch_module, but not for the kitchen LED driver. More details later:

light_kitchen_cupboard_underlight:
  module: controllerx
  class: E1743Controller
  controller: gf_kitchen_cupboard-underlight_switch
  integration:
    name: z2m
    listen_to: mqtt
    action_key: action
  light: light.gf_kitchen_cupboard-underlight
  # light: light.uf_office_light_switch

I tried to set up the light with my ZigBee Gledopto GD-CZ-006 LED strip controller, but couldnā€™t get it to work.

In Z2M devices.yaml I have configured the controller as light:

'0x00124b0022640d82':
  friendly_name: gf_kitchen_cupboard-underlight
  homeassistant:
    switch:
      type: light
      object_id: light
    light:
      name: GF Kitchen Cupboard Underlight
      value_template: null
      state_value_template: '{{ value_json.state }}'

But when I configure AppDaemon with it, it doesnā€™t react on button presses. I added a log line in the LightController:

async def call_light_service(self, service: str, **attributes: Any) -> None:
             self.log(
                f"LightController.call_light_service({service})",
                level="WARNING",
                ascii_encode=False,
            )

I can see, the button press reaches the LightController as I find this in the log:

2022-10-11 16:46:46.091509 INFO light_kitchen_cupboard_underlight: ļæ½ ControllerX v4.23.0
2022-10-11 16:46:46.101936 WARNING light_kitchen_cupboard_underlight: E1743 normal setup
2022-10-11 16:46:46.110154 INFO AppDaemon: App initialization complete
2022-10-11 16:46:52.309171 INFO AppDaemon: New client Heating Settings Dashboard connected
2022-10-11 16:46:57.521330 INFO light_kitchen_cupboard_underlight: ļæ½ Button event triggered: `on`
2022-10-11 16:46:57.523470 INFO light_kitchen_cupboard_underlight: ļæ½ Running `Predefined (on)` now
2022-10-11 16:46:57.525359 WARNING light_kitchen_cupboard_underlight: LightController.call_light_service(light/turn_on)
2022-10-11 16:46:57.527328 INFO light_kitchen_cupboard_underlight: 
ļæ½ Service: light.turn_on
  - entity_id: light.gf_kitchen_cupboard-underlight
2022-10-11 16:46:57.536208 WARNING HASS: Error calling Home Assistant service default/light/turn_on
2022-10-11 16:46:57.536924 WARNING HASS: Code: 400, error: 400: Bad Request

But obviously it creates an error.

When I set it up with a TuYa TuYa TS0001_switch_module, which is converted to a light as well:

'0xa4c13823592ecc0c':
  friendly_name: switch_module.uf_office_light
  homeassistant:
    switch:
      type: light
      object_id: light
    light:
      name: UF Office Light Switch
      value_template: null
      state_value_template: '{{ value_json.state }}'

I can switch on/off the light with my E1743 without errorsā€¦

2022-10-11 16:44:52.304429 INFO light_kitchen_cupboard_underlight: ļæ½ ControllerX v4.23.0
2022-10-11 16:44:52.315251 WARNING light_kitchen_cupboard_underlight: E1743 normal setup
2022-10-11 16:44:52.323353 INFO AppDaemon: App initialization complete
2022-10-11 16:44:59.558926 INFO light_kitchen_cupboard_underlight: ļæ½ Button event triggered: `on`
2022-10-11 16:44:59.561353 INFO light_kitchen_cupboard_underlight: ļæ½ Running `Predefined (on)` now
2022-10-11 16:44:59.563126 WARNING light_kitchen_cupboard_underlight: LightController.call_light_service(light/turn_on)
2022-10-11 16:44:59.565121 INFO light_kitchen_cupboard_underlight: 
ļæ½ Service: light.turn_on
  - entity_id: light.uf_office_light_switch

Comparing them in Z2M they both expose the state on/off. And also in the Developer Tools ā†’ States they both have a State on & off.

What might be an indicator: I also added a log statement into the Ikea E1743Controller.get_z2m_actions_mapping(ā€¦) and E1743Z2MLightController.get_z2m_actions_mapping(ā€¦) functions. It uses the E1743Controller.get_z2m_actions_mapping(ā€¦) with my AD configurationā€¦

Do you have any recommendation, what I could check to get it up and running?

Thanks in advance!

Best,
Andreas

Hi @EspWhaleSong ,

So you are saying that you can see in the logs it is executing the service, but the lifght is not turning on?

Does the light work with Home Assistant? Could you try sending the Service from ā€œDeveloper Toolsā€ in Home assistant?

It seems that ControllerX is reacting to the controller changes, so it seems to be a problem from the light itself.

Regards,
Xavi M.

I canā€™t find this in the HACS store and when I copy the GitHub repository link into HACS custom repositories I get the following error. Not sure if itā€™s an issue with HACS or the repo:

<Integration xaviml/controllerx> Repository structure for v4.24.0 is not compliant

@xaviml

Hi, excellent work with the controllerx!

Is there any plan or scope to be able to add to the configuration the ability to lookahead and not turn off a light when dimming? Would be an awesome addition if not already supported. I couldnā€™t see any reference to this in the docs though.

I have a feeling this could be related to how Zigbee2MQTT is setup. There are 2 options in Home Assistant Integration section in Z2M settings: Home Assistant legacy entity attributes and Home Assistant legacy triggers. I believe these 2 are enabled by default. When I first installed Z2M (a week ago), there were enable and I was able to see button presses in Logbook of the device. I donā€™t remember if there was an ā€œactionā€ sensor, but it makes sense right? Otherwise how the logbook would have been filled? Iā€™ve turned off both of these and the logbook entries stopped coming. But everything works in standard automations.

I just came to this topic as Iā€™ve been using ControllerX with ZHA and now wanted to switch to Z2M, but also missing those sensors. I was only using 3 controllers this way, so I guess I will find another way to achieve my automations. For some reason, Iā€™m unable to explain, I donā€™t want to connect AppDaemon directly to MQTT. But if @xaviml could look into it and make it work in a standard AppDaemon < ā€“ > HA integration, it would be a way back.

Thank you, Xavi, to look into it or at least comment on this situation.

Regards,
Martin

For anyone looking the answer to this. It was resolved here.

1 Like

Hi @adamch ,

I have recently answer this question here, but it in summary, you can use min_brightness attribute to change the default value of 1 as minimum brightness:

livingroom_controller:
  module: controllerx
  class: E1810Controller
  controller: sensor.livingroom_controller_action
  integration: z2m
  light: light.bedroom
  min_brightness: 20

Most of the lights should not turn off with brightness 1, but some lights do, as it is in your case, so you can change the minimum brightness to something higher for the light to not turn off.

Regards,
Xavi M.

Hi @xaviml

A new remote control not very expensive and interesting:
https://www.leroymerlin.fr/produits/electricite-domotique/domotique-et-objets-connectes/domotique/accessoires-de-gestion-de-lumiere/telecommande-pour-ampoules-connectees-rgb-ctt-zigbee-lexman-enki-82473188.html?src=clk

class: LightController or Controller does not work, I have to use E1810Controller.

Here is what I got in z2m (ok also in zha), it would be great to integrate this model.

lexman_01:
  module: controllerx
  class:  E1810Controller # LightController Controller
  controller: sensor.lexman_01_action
  integration: z2m
      # name: z2m
      # listen_to: mqtt
  light: light.livingroom
  merge_mapping:
    scene_1:
      service: input_select.select_option
      entity_id: input_select.lexman_1
      data:
        option: light_1
    scene_2:
      service: input_select.select_option
      entity_id: input_select.lexman_1
      data:
        option: light_2
    scene_3:
      service: input_select.select_option
      entity_id: input_select.lexman_1
      data:
        option: light_3
    scene_4:
      service: input_select.select_option
      entity_id: input_select.lexman_1
      data:
        option: light_4


lexman_01_light_1:
  module: controllerx
  class: E1810Controller
  controller: sensor.lexman_01_action
  integration: z2m
  light: light.cuisine_lampe_de_table
  constrain_input_select: input_select.lexman_1,light_1
  excluded_actions: [scene_1, scene_2, scene_3, scene_4]
  mapping:
    "on": "on"
    "off": "off"
    brightness_step_up: hold_brightness_up
    brightness_step_down: hold_brightness_down
    brightness_stop: release

    # color_hue_step_up: hold_color_up
    # color_hue_step_down: hold_color_down

    # color_hue_step_up: hold_white_value_up
    # color_hue_step_down: hold_white_value_down

    color_hue_step_up: hold_colortemp_up
    color_hue_step_down: hold_colortemp_down

    color_saturation_step_up: hold_colortemp_up
    color_saturation_step_down: hold_colortemp_down
    color_stop: release

Hi @Canaletto ,

LightController or Controller does not work, I have to use E1810Controller .

If you use LightController, you would need to use mapping, not merge_mapping. The second one only works when there is a default mapping.

Do you have a link of this device on Zigbee2MQTT documentation? I will create ā€œNew deviceā€ request in GitHub to add this device in the coming release.

Regards,
Xavi M.

https://www.zigbee2mqtt.io/devices/HR-C99C-Z-C045.html

Hi @xaviml

ControllerX made my Symfonisk e1744 usable! I have a question - is it possible to increase the sensitivity? Today, it takes a couple spins for each brightness level on my Wiz bulbs, is it possible to reduce it to a quarter spin or less to make it feel more responsive?

UPDATE: found the automatic_steps: feature, works like a charm.

office_controller:
  module: controllerx
  class: E1744LightController
  controller: "Office Light Dial"
  integration:
    name: z2m
    listen_to: mqtt
  automatic_steps: 5
  light:
    name: light.office_tracklight
    color_mode: auto
1 Like

i am already running a nspanel witj apss.yaml, how can i add controllerx to this yaml file?

nspanel-1:
  module: nspanel-lovelace-ui
  class: NsPanelLovelaceUIManager
  config:
    panelRecvTopic: "tele/tasmota_nspanel/RESULT"
    panelSendTopic: "cmnd/tasmota_nspanel/CustomSend"
    model: eu
    sleepTimeout: 30
    sleepBrightness:
      - time: "7:00:00"
        value: 10
      - time: "23:00:00"
        value: 0
    locale: "nl_NL"
    screensaver:
      entity: weather.buienradar
      weatherOverrideForecast4:
        entity: sensor.temp_buiten_temperature
        name: Actueel Buiten
        icon: thermometer
      alternativeLayout: True      
      
      
    cards:
      - type: cardEntities
        title: -LAMPEN SCHAKELAARS-
   
etc etc

Do you know if this button from Lidl Silvercrest is supported?