Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with changing light color #2

Closed
lorek123 opened this issue Dec 1, 2019 · 12 comments
Closed

Issue with changing light color #2

lorek123 opened this issue Dec 1, 2019 · 12 comments

Comments

@lorek123
Copy link

lorek123 commented Dec 1, 2019

I'm connecting LED1624G9 and E1524/E1810 via Zigbee2mqtt 1.70. Toggling light and switching brightness works ok, but when I'm trying to change color it fails:

2019-12-01 13:39:00.355232 WARNING AppDaemon: ------------------------------------------------------------
2019-12-01 13:39:00.359574 WARNING AppDaemon: ------------------------------------------------------------
2019-12-01 13:39:00.359790 WARNING AppDaemon: Unexpected error in worker for App smallroom_light:
2019-12-01 13:39:00.360030 WARNING AppDaemon: Worker Ags: {'name': 'smallroom_light', 'id': UUID('2e48a534-872d-4309-adb9-9a96315ab91d'), 'type': 'attr', 'function': <bound method IkeaController.state of <z2m_ikea_controller.E1810Controller object at 0x7fc7f82df748>>, 'attribute': 'state', 'entity': 'sensor.0x90fd9ffffedc7ddd_action', 'new_state': 'arrow_right_click', 'old_state': 'arrow_right_click', 'kwargs': {'handle': UUID('05ae5341-804c-40ce-aba9-d777a16f787e')}}
2019-12-01 13:39:00.360199 WARNING AppDaemon: ------------------------------------------------------------
2019-12-01 13:39:00.360612 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 595, in worker
    self.sanitize_state_kwargs(app, args["kwargs"]))
  File "/conf/apps/z2m_ikea_controller/z2m_ikea_controller.py", line 70, in state
    self.turn_on_light(attribute, value, sign, self.manual_steps)
  File "/conf/apps/z2m_ikea_controller/z2m_ikea_controller.py", line 96, in turn_on_light
    new_state_attribute = old + sign * step
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

2019-12-01 13:39:00.360769 WARNING AppDaemon: ------------------------------------------------------------

apps.yaml:

/conf/apps/apps.yaml
hello_world:
  module: hello
  class: HelloWorld
smallroom_light:
  module: z2m_ikea_controller
  class: E1810Controller
  sensor: "sensor.0x90fd9ffffedc7ddd_action"
  light: "light.0x90fd9ffffef3826c_light"
@xaviml
Copy link
Owner

xaviml commented Dec 1, 2019

The code right now just uses the following light attributes: "brightness" and "color_temp". Your light is not changing the color since LED1624G9 does not support the color temperature (color_temp) attribute, just the xy_color. I see two solutions for this:

  • Convert from colot_temp to xy_color. This conversion can be found in the util from home assistant. However, I think it is not possible to access to home assistant util from appdaemon.

  • Pass two colors through parameters and go from one color to another one in a gradient step.

I see the second solution more feasible for this use case.

@lorek123
Copy link
Author

lorek123 commented Dec 2, 2019

Let me know how I can help, I could try to code that if there is an example I could use

@ginodp
Copy link

ginodp commented Dec 29, 2019

Same problem here.
Color change not working.
Hope there will be a fix.

@xaviml
Copy link
Owner

xaviml commented Jan 6, 2020

Hi @lorek123 and @ginodp,

I updated the code and now it supports color for the lights that have xy_color attribute. I haven't released the code yet, but you can copy and paste the code from the master branch and let me know if this works for you. I now have the LED1624G9 and it worked on my end.

I updated the README file with the color feature. By default, it checks if the light supports xy_color, otherwise it will use color_temp. So if the light supports xy_color when the arrows are pressed, it does a loop of colors until the button is released.

Thank you for your support and let me know if it works as expected to close this issue.

@ginodp
Copy link

ginodp commented Jan 6, 2020

I will be home in 3 hours and will test if it's working. I'll let u know soon. Thanks in advance for your great work.

@ginodp
Copy link

ginodp commented Jan 6, 2020

I copied the "Master" -> "z2m_ikea_controller/apps/z2m_ikea_controller/z2m_ikea_controller.py"

2020-01-06 17:00:11.412622 INFO AppDaemon: Reading config
2020-01-06 17:00:11.425675 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified
2020-01-06 17:00:11.426296 INFO AppDaemon: App 'ikea_light_dressoir' changed
2020-01-06 17:00:11.427986 INFO AppDaemon: Terminating ikea_light_dressoir
2020-01-06 17:00:11.428930 INFO AppDaemon: Initializing app ikea_light_dressoir using class E1810Controller from module z2m_ikea_controller
2020-01-06 17:00:11.429867 WARNING AppDaemon: ------------------------------------------------------------
2020-01-06 17:00:11.430430 WARNING AppDaemon: Unexpected error running initialize() for ikea_light_dressoir
2020-01-06 17:00:11.430930 WARNING AppDaemon: ------------------------------------------------------------
2020-01-06 17:00:11.432440 WARNING AppDaemon: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/appdaemon.py", line 1581, in init_object
init()
File "/config/appdaemon/apps/z2m_ikea_controller/z2m_ikea_controller.py", line 200, in initialize
super().initialize()
File "/config/appdaemon/apps/z2m_ikea_controller/z2m_ikea_controller.py", line 98, in initialize
super().initialize()
File "/config/appdaemon/apps/z2m_ikea_controller/z2m_ikea_controller.py", line 50, in initialize
self.actions_mapping = {
File "/config/appdaemon/apps/z2m_ikea_controller/z2m_ikea_controller.py", line 53, in
if key in included_actions
TypeError: argument of type 'NoneType' is not iterable
2020-01-06 17:00:11.433036 WARNING AppDaemon: ------------------------------------------------------------

@xaviml
Copy link
Owner

xaviml commented Jan 6, 2020

Sorry @ginodp, it should be fixed now. Let me know about it.

@ginodp
Copy link

ginodp commented Jan 6, 2020

Very nice it works like a charm.

Can I add more colors to it? Like white!

@xaviml
Copy link
Owner

xaviml commented Jan 6, 2020

Perfect! We could add white near the light blue so it blends a little bit. If you open the dialog of the light on home assistant, you will see it goes over the whole circle, but not the middle, which is the middle.

@xaviml xaviml closed this as completed Jan 6, 2020
@ginodp
Copy link

ginodp commented Jan 10, 2020

I added the white color before blue starts for the blend.

    (0.141, 0.137),
    (0.146, 0.238),
    (0.323, 0.329),# white color middle
    (0.151, 0.343),
    (0.157, 0.457),

Works nicely. This middle color is a nice warm color next to the white from blue.

@xaviml
Copy link
Owner

xaviml commented Jan 10, 2020

Thanks @ginodp. I will add the color and let you know about it.

@xaviml xaviml reopened this Jan 10, 2020
@xaviml
Copy link
Owner

xaviml commented Jan 11, 2020

Hey @ginodp,

I just add the white color as you said, the color blends in quite well. You can download the last version for it.

@xaviml xaviml closed this as completed Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants