ControllerX. Bring full functionality to light and media player controllers

Hi @sebul0n,

I see a mistake that I did not see last time, sorry. The thing is that you are using E1743Controller which is a device controller, so the mapping attribute will be ignore. If you want to use the mapping attribute, you wither need to use CustomLightController, CustomMediaPlayerController or CallServiceController. These three are Custom Controllers and they do take a mapping attribute where the key is the button event (depending on the integration) from the controller that you have(this one in your case) and the value will depend on the class that you use. In case of CallServiceController you can put a service as you did in the configuration you sent.

If you want to learn more about Custom Controllers I recommend you to take a look to this section of the documentation: https://xaviml.github.io/controllerx/others/custom-controllers

I also recommend you to take a look to the Real Examples section from the documentation. You will be able to see in here some real use cases on how you can use ControllerX.

If you still do not see how to configure your controller to your liking, let me know of your use case and I will help you out.

Regards,
Xavi M.

Hi Everyone,

i am a pretty new user to HA (so sorry for dumb questions), and i am trying to get my zigbee2mqtt/TRADFRI setup to work.
so what iā€™ve done so far is installed: Appdaemon 4, HACS, controllerX, Zigbee2mqtt and mosquitto.
i can see the actions of my TRADFRI in the zigbee2mqtt logs, and i also see the TRADFRI in the ā€œdevicesā€ section.

iā€™ve tried adding config like this to the /config/appdaemon/apps/apps.yaml:
iā€™ve used this page to find the contoller:

livingroom_controller:
  module: controllerx
  class: E1810Controller
  controller: sensor.0x14b457fffed434d5_action
  integration: z2m
  light: light.livingroom
  actions:
    - toggle
    - brightness_up_click
    - brightness_down_click

but i am stuck now, how can i get a working item on my lovelace dashboard for this controller?
i googled and searched this topic, but i think i am missing some knowledge/information.
can someone help me, or point me too some good documentation that i can use to make it work?

Regards
Ferry

Hi @blankf welcome to the community!

Firstly, does the controller do what you expect it to do?

If I understand correctly, it sounds like you want to replicate the controllerā€™s actions in lovelace?
Typically, in HA, we donā€™t add controllers to the UI, but instead use the services directly to achieve the same thing as the controller does. ControllerX is just a super convenient method for integrating controllers.
You can place a card with the entity that will allow you to toggle and adjust brightness. Using different cards, you can make the UI look like anything you want.
For example, something like this using vertical and horizontal stacks with entities:


OR something similar using a stack of custom:slider-entity-row
image

Let me know if Iā€™ve misunderstoodā€¦

Hi @sreknob Thank you for the quick response, and thanks happy that i joined so far!

Yes, the TRADFRI controller does what it supposed to do, turn on my lights or dim them. ( 2x e27 ikea lights )

i am indeed trying to bypass the controller and control the lights themselfs.( so basicly what the controller does for me )

this is what i got from the zigbee2mqtt logs

zigbee2mqtt:info  2020-04-01 23:28:13: MQTT publish: topic 'zigbee2mqtt/woonkamer/action', payload 'toggle'
zigbee2mqtt:info  2020-04-01 23:28:13: MQTT publish: topic 'zigbee2mqtt/woonkamer', payload '{"battery":87,"linkquality":68,"update_available":true,"action":"toggle"}'
zigbee2mqtt:info  2020-04-01 23:28:13: MQTT publish: topic 'zigbee2mqtt/woonkamer', payload '{"battery":87,"linkquality":68,"update_available":true,"action":""}'
zigbee2mqtt:info  2020-04-01 23:28:13: MQTT publish: topic 'zigbee2mqtt/woonkamer', payload '{"battery":74,"linkquality":68,"update_available":true}'
zigbee2mqtt:info  2020-04-01 23:28:16: MQTT publish: topic 'zigbee2mqtt/woonkamer/action', payload 'toggle'
zigbee2mqtt:info  2020-04-01 23:28:16: MQTT publish: topic 'zigbee2mqtt/woonkamer', payload '{"battery":74,"linkquality":68,"update_available":true,"action":"toggle"}'
zigbee2mqtt:info  2020-04-01 23:28:16: MQTT publish: topic 'zigbee2mqtt/woonkamer', payload '{"battery":74,"linkquality":68,"update_available":true,"action":""}'

i am already playing around with some other cards within lovelace and that seems to work.
but somehow i am unable to figure out how i get those lights to ā€œtoggleā€
and for sure i am missing something.

Many cards will just toggle with the taps.
Otherwise, set a card to call service light.toggle with service data entity_id: light.livingroom

easiest way is a button card:

type: button
tap_action:
  action: toggle
hold_action:
  action: more-info
show_icon: true
show_name: true
state_color: true
entity: light.livingroom

Wow, I am feeling so dumb right now, I didnā€™t pair the bulbs but only the remote.

So now I have the bulbs in zigbee2mqtt and can toggle them through Lovelace, now I only have to figure out how to group them and use the remote to turn them on/off for the rest of the family that are not using Lovelace just yet.

Thanks!

z2m works fine, services through Developer Tools work fine ; error 400 in appdaemon!
get error 400 in log_level ā€œinfoā€ mode, but no detail in debug or trace ; any clue?
btw, whereā€™s the log file?

    fall:
      service: light.turn_on
      data:
        entity_id: light.ampoule_martin_plafond_light
        transition: 60
        color_name: WHITE
        brightness_pct: 10

@dede34fr - have you tried without the transition attribute in the service call?
I wonder if your light is reporting that it doesnā€™t support transition or if controllerx is stripping the transition and improperly formatting the JSON.

Thanks @xaviml, I think I got exactly what I needed now!=)

1 Like

Hi @dede34fr,

I observe that in the first configuration you sent (the following) there is a mistake.

cube_bedroom:
  module: controllerx
  class: CallServiceController
  controller: sensor.cube_chambre_martin_action
  integration: z2m
  mapping:
    fall:
      service: light.turn_on
      data:
        entity_id: light.ampoule_martin_plafond_light
        brightness_pct: 10
        color_temp: white
    flip90:
      service: light.turn_on
      data:
        entity_id: light.ampoule_martin_plafond_light
        brightness_pct: 40
        color_temp: orange
    flip180:
      service: light.turn_on
      data:
        entity_id: light.ampoule_martin_plafond_light
        brightness_pct: 100
        color_temp: white
    rotate_left:
      service: light.turn_on
      data:
        entity_id: light.ampoule_martin_plafond_light
        brightness_step_pct: -25
    rotate_right:
      service: light.turn_on
      data:
        entity_id: light.ampoule_martin_plafond_light
        brightness_step_pct: +25
    shake:
      service: light.turn_on
      data:
        entity_id: light.ampoule_martin_plafond_light
        brightness_pct: 80
        color_temp: red
    slide:
      service: light.turn_on
      data:
        entity_id: light.ampoule_martin_plafond_light
        brightness_pct: 80
        color_temp: white
    tap:
      service: light.toggle
      data:
        entity_id: light.ampoule_martin_plafond_light

The problem in here is that color_temp is expecting an integer. You can check the documentation in here. I saw that you change the color_temp to color_name, so I guess you realized of the mistake. I just tried your configuration with one of my controllers and with a color lightbulb that supports transition and it worked. However, the transition can only be done in one of the parameters , in this case is the colour. This is how z2m works. We will need more details to help you out since I could not reproduce the error. The problem is in the call to HA service from AppDaemon, but as @sreknob says maybe is problem of the lightbulb you are using.

Let us know if you can help you further.

Hi xaviml, when I look at the Developer Tools / States, here are the attributes for that Zemismart RGBW zigbee 3.0 downlight:
Zemismart 4.5 inch downlight

min_mireds: 153
max_mireds: 500
brightness: 255
color_temp: 164
hs_color:
  - 0
  - 0
rgb_color:
  - 255
  - 255
  - 255
xy_color:
  - 0.323
  - 0.329
state: 'ON'
color:
  x: 0.323
  'y': 0.329
friendly_name: ampoule_martin_plafond_light
supported_features: 59

In that case, is it possible to use color_name? transition?
Tks

Hi @dede34fr,

This light according to the supported_features (which is a bitfield flags), it supports:

  • Brightness
  • Color temperature
  • Flash
  • Color
  • Transition

As I said in my previous comment, your last configuration worked with a colour lightbulb from IKEA. But it just transition the colour, but not the brightness. I did not received any 400 Bad request on AppDaemon. What is strange is that it works from Developer Tools and not from ControllerX since what the code does is a straight forward HA call service, the same as you do from Developer Tools.

Let me know if you find out which was the problem :slight_smile:

Hi

Iā€™ve been playing with the configuration over the last few days, and it still has some random behavior that itā€™s not clear. This is what I did.

  1. I added a second Hue dimmer switch, identical to the first one. Got recognized at the first try and worked. Surprisingly, the response time of this was is better than the first. No idea why.

  2. I added a Ikea E1810 controller. Perfect from the beginning.
    ā€¦
    Now after some days of not using them I have had issues again. The HUE ones turns a light red the first time i push them, and the command semms not to be recognized. Later presses, the led is green and works. The ikea 1810 was not recognized on the zigbee network, i had to do a repairing again. After doing it, it worked again perfectly.

Iā€™ll keep trying the devices and fine tunning the configuration. Thanks again for the help.

Regards

v2.4.4 is now released :partying_face:

This minor change does not contain breaking changes.

:pencil2: Features

  • Add action_delay attribute to the base controller to control when the action will be called (#59)
  • Add excluded_actions attribute to complement actions (#63)
  • Add add_transition attribute to add a transition to light call services.

:wrench: Refactor

  • Add human-friendly readable logs (#62 )

:hammer: Fixes

  • Restrict entities to their domains (light and media players)
2 Likes

@rodolfo it sounds zigbee network relatedā€¦

@xaviml looking forward to trying the new features!!! Thank you!

Hi, Just found this and it looks great!! thank you!

one question, I noticed that when I set up my E1810Controller through deconz when the light turns on its always at its lowest brightness, is it possible to set it so it turns on at its last brightness setting?

Iā€™ve also got 2 E1743Controllers that Iā€™d like to have the same.

thanks for any helpā€¦

Thanks a lot for work on ControllerX. I wanna start with your great automation.

I really your AppDaemon and this one here:

Is there a chance to use them together?
Does ControllerX loves :bulb: AutoMoLi?

Hey, @xaviml do you plan to add this switch to your app - https://www.banggood.com/Original-Aqara-OPPLE-Wireless-International-Version-Smart-Switch-Work-With-Apple-HomeKit-Xiaomi-Eco-System-p-1588700.html?rmmds=search&ID=6280216&cur_warehouse=CN

Hi @Rdoull,

Thank you for trying ControllerX :slight_smile: Interesting that it turns on the light always to the lowest value. Does this happen when you press the middle button? Could you maybe tell me which light you are using? I might have it and I can try to reproduce this error.

However, ControllerX just acts as a middle layer between the controller and Home Assistant services. So when toggleling it calls light.toggle service, so you can reproduce the same on Home Assistant. I will add more logging in the next release to also show the attributes that are used to call the HA service. This way, you will be able to test the service call and see if the same behaviour happens from the Developer Tools tab.

Hi @JamieMe,

Thank for the appreciation :slightly_smiling_face: I know of Automoli and I also think it is a really cool project, however, I have not seen a use for it yet. If I understand correctly, Automoli allows to bind sensors with lights and configure them in a smart manner. I do not see why it would not work together with ControllerX. Have you tried to run them together? If so, have you experience any unexpected behaviour? Let me know, so I can help you better.