Controllerx: Adding lights as dic

Created on 3 Mar 2020  路  3Comments  路  Source: xaviml/controllerx

Question

Hi
I'm trying to assign multiple lights to a single controller.
I know I can group them, but I'd like to avoid that.

Are dictionaries as light: supported?
And if so, how do I define them

Thanks :)

Additional information

  • Devices involved:

    • Model: IKEA 1810 as Controller

    • Lights:

    • Ikea Float Panel

    • Phillips Hue

  • Integration: deconz
  • AppDaemon version: v4.0.2.3
  • ControllerX version: v2.3.1
  • HACS version: v0.22.1
  • Home Assistant Core version: v0.106.4

AppDaemon app configuration

N/A

Logs

N/A

Additional Context

As pr. the documentation, the key can either be string or dictionary. And furthermore, if lights is a dictionary, I should provide a name.
I assume a config like this would be valid:

awesome_controller:
  module: controllerx
  class: E1810Controller
  controller: mah_remote
  integration: deconz
  light: 
    - name: light.greatest
    - name: light.awesomest

I looked at code too, and it seems to be aware of using dics

https://github.com/xaviml/controllerx/blob/1809f2f3b92419676c38bd76ccee337f6dafa951/apps/controllerx/core/type/light_controller.py#L242-L250

But this bit confuses me. Doesn't seem to account for string/dic.

https://github.com/xaviml/controllerx/blob/1809f2f3b92419676c38bd76ccee337f6dafa951/apps/controllerx/core/type/light_controller.py#L74-L76

question

Most helpful comment

Hi @terle,

Thanks for the question. The light attribute does not accept a list, just a dictionary or string. You are adding "-" and that is a list in YAML, this is why it is not working (with your configuration light is a list, not a string or dict). Also, ControllerX does not support that and it is not part of the roadmap since it will need to take care to turn on/off every single light, something that HA manages already pretty well with groups. If you do not want to create a group of lights, which is the recommended way and I do not see a reason for not doing so, you can also do the following:

great_controller:
  module: controllerx
  class: E1810Controller
  controller: mah_remote
  integration: deconz
  light: light.greatest

awesome_controller:
  module: controllerx
  class: E1810Controller
  controller: mah_remote
  integration: deconz
  light: light.awesomest

Since AppDaemon allows create different instance apps, you can create one for one light and one for the other and use the same controller for both. However, if you create a group as easy as:

kitchen_lights:
  name: Kitchen lights
  entities:
    - light.kitchen1
    - light.kitchen2

Then you just need to do:

kitchen_controller:
  module: controllerx
  class: E1810Controller
  controller: mah_remote
  integration: deconz
  light: group.kitchen_lights

I hope this helped :)

All 3 comments

Hi @terle,

Thanks for the question. The light attribute does not accept a list, just a dictionary or string. You are adding "-" and that is a list in YAML, this is why it is not working (with your configuration light is a list, not a string or dict). Also, ControllerX does not support that and it is not part of the roadmap since it will need to take care to turn on/off every single light, something that HA manages already pretty well with groups. If you do not want to create a group of lights, which is the recommended way and I do not see a reason for not doing so, you can also do the following:

great_controller:
  module: controllerx
  class: E1810Controller
  controller: mah_remote
  integration: deconz
  light: light.greatest

awesome_controller:
  module: controllerx
  class: E1810Controller
  controller: mah_remote
  integration: deconz
  light: light.awesomest

Since AppDaemon allows create different instance apps, you can create one for one light and one for the other and use the same controller for both. However, if you create a group as easy as:

kitchen_lights:
  name: Kitchen lights
  entities:
    - light.kitchen1
    - light.kitchen2

Then you just need to do:

kitchen_controller:
  module: controllerx
  class: E1810Controller
  controller: mah_remote
  integration: deconz
  light: group.kitchen_lights

I hope this helped :)

Hi @xaviml
Thank you for the elaborate answer :)
I see now, there's a difference between a list and dic. Thank for making my yaml-fu stronger
And thank you also for making controllerX. You really helped to make my life much eaiser.

No worries, thank you for your appreciation, I know what creating a HA automation is like when it comes to giving functionality to controllers. In the end, everyone would do the same complex automations. I am glad I made your life easier :)

P.S. I edited my answer since there was a typo in the yaml configuration.

Was this page helpful?
0 / 5 - 0 ratings