python-magichue icon indicating copy to clipboard operation
python-magichue copied to clipboard

Color control not working properly

Open henryruhs opened this issue 5 years ago • 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

henryruhs avatar Mar 16 '20 23:03 henryruhs

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

namacha avatar Mar 17 '20 10:03 namacha

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?

henryruhs avatar Mar 17 '20 11:03 henryruhs

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

henryruhs avatar Mar 23 '20 16:03 henryruhs

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..

namacha avatar Mar 29 '20 18:03 namacha

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()

henryruhs avatar Mar 29 '20 18:03 henryruhs