namacha/python-magichue

Color control not working properly

Opened this issue · 5 comments

Describe the bug
Working:

  1. Turning bulb on and off
  2. Using light.mode like RAINBOW_CROSSFADE is working
  3. Changing the colors via magic hue app

Not working:

  1. Changing colors using light.rgb
  2. Changing colors using light.hue
  3. Using CustomMode is not working

Device
https://www.amazon.com/Required-Magic-Hue-Equivalent-Compatible/dp/B07VKJ2VW5

Code

#!/usr/bin/env python3

import magichue
from magichue import CustomMode

light = magichue.Light('192.168.1.128')

light.on = True
light.is_white = False

light.mode = CustomMode(
    mode = magichue.MODE_GRADUALLY,
    speed = 0.5,
    colors = \
    [
        (255, 0, 255),
        (0, 0, 255)
    ]
)

Note: Please introduce Exceptions for color functions that are not working or connections that cannot be established... this library is impossible to debug otherwise

Please try light = magichue.Light(addr, confirm_receive_on_send=False)

Sorry but this has no effect using that code:

import magichue

light = magichue.Light('192.168.1.128', confirm_receive_on_send=False)

light.on = True
light.is_white = False

light.rgb = (0, 255, 0)

light.update_status()
print(light._get_status_data())

Returned status:

(129, 53, 35, 97, 1, 1, 0, 0, 0, 0, 7, 15, 15, 97)

It changes the saturation to 6% for some reason...? Properly the bulb's API is different?

@namacha Can I help you with that issue? Properly expose the bulb via my router and give you access for debugging?

I found your bulb has different protocol, so I decided to buy that bulb and do some hack. But I am so busy recently, so it may take a while..

Awesome - let's keep in touch for upcoming process. In the meanwhile I integrated your library with an hack for static colors.

https://github.com/redaxmedia/chroma-feedback/blob/master/chroma_feedback/consumer/magic_hue/light.py#L64-L72

That being said, it would be nice to have helper methods under the Light class / API because I had to wrap modes into another function for possible import errors / unit testing.

https://github.com/redaxmedia/chroma-feedback/blob/master/chroma_feedback/consumer/magic_hue/api.py#L30-L36

Suggested API:

light.setMode(
	mode = light.MODE_GRADUALLY,
	speed = 1,
	colors = \
	[
		(255. 0, 0),
		(0, 0, 0)
	]
)

light.setRGB(255, 0, 0)

light.turnOn()
light.turnOff()