namacha/python-magichue

Setting color does not exit

Closed this issue · 13 comments

Hi,

it seems like that setting a color does not "exit" for me. For example, this program halts after setting the color to white:

Python 3.6.3 |Anaconda, Inc.| (default, Dec  5 2017, 17:30:25)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> import magichue
>>> light = magichue.Light('192.168.178.109')
>>> if not light.on:
...     light.on = True
...
>>> if light.is_white:
...   light.is_white = False
...
>>> light.rgb = (255, 255, 255)

Might be related to #4 ?

Thank you for posting issue!

There are different types of magichue(magichome) bulbs and their protocols may differs.
Which bulbs are you using?

Hmm.
Does this code light.rgb = (255, 255, 255) set the color and then it halts? Or nothing happen and halts?
Other functions are working?

light.rgb = (255, 255, 255) does change the colour on the device but then it halts. Turning on and off the device via light.on = value works fine, i.e. I can issue other commands afterwards.
Maybe the firmware on my device slightly differs to the one on your device?

Maybe the firmware on my device slightly differs to the one on your device?

It looks like it.

I created a new branch, you can try it. I think it works.

p.s.
If you don't mind, can you post the result of this?: print(light._get_status_data()) # after created the instance of magichue.Light

I'm having a similar problem described above.
This is my bulb: https://www.amazon.com/gp/product/B07H28N7TS

I pulled change #7 which ignores the .recv call so it at least doesn't hang. I can, however, confirm that the bulb does not actually change color as requested.

The output of "print(light._get_status_data()) # after created the instance of magichue.Light" for me is:

(129, 68, 35, 97, 1, 16, 0, 0, 0, 127, 8, 0, 15, 240)
Hopefully this helps with whatever compatibility is missing.

I guess you had to execute light.is_white = False before changing color.

right you are, sir. worked like a charm. thank you very much for the help!

So your script still hangs unless using #7 branch?

I had it working fine yesterday, today I can't seem to get it to act predictably.
After trying different combinations of .is_white and .rbg I couldn't change anything about the light.
I was able to turn it off with .on = False, but oddly enough could not turn it back on with .on = True
(this is all with #7 branch still in effect)
Now I can't change the color or unset is_white, all I can do is turn it off without turning it on.
I don't know if it will help but the status as of right now (off, can't turn on) is:
(129, 68, 35, 97, 1, 16, 0, 0, 0, 0, 8, 0, 15, 113)

Later today I will be able to do more comprehensive tests.

I have attached an excel document of my tests.
The reality of what the bulb displayed always matched the app, and sometimes (but not always) matched the library.
MagicHue tests.xlsx

Let me know if you have any questions.

Sorry for not responding sooner.

The results of tests look natural for me.
Magichue bulb does not accept any change of parameters while powered off( light.on = False). Maybe it causes strange (for you) behavior.

Anyway thank you for contributing.

All of my tests were conducted while the light was on. If i ever turned the light off it was to power cycle, I turned it back on before I did another test. All but one test in the attached spreadsheet has the .on return False.