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

changing color turns the light off #2

Open
NajiLutfalla opened this issue Jan 21, 2021 · 12 comments
Open

changing color turns the light off #2

NajiLutfalla opened this issue Jan 21, 2021 · 12 comments
Labels
bug Something isn't working
Milestone

Comments

@NajiLutfalla
Copy link

discovery and state work fine to turn the light's on and off, but when i try to us the color argument it turns the light off rather than change the color eg: $ magic-home c 192.168.1.7 255 0 0 0

@MoonLiightz
Copy link
Owner

I have two of these kind of devices and could not reproduce the problem. On both devices, the color was correctly changed to red. Do you have a similar device or even a second one you could test it with as well?

@metallitiger
Copy link

I recently ran into this issue as well. I purchased a magiclight bulb and an led strip. The led strip works great with your program, however the light bulb will just turn off when attempting to change the color.

@NajiLutfalla
Copy link
Author

i think i know what is causing the issue the lights aren't rgbw their rgbcw. thank you for your response.

@MoonLiightz
Copy link
Owner

Cold Warm (cw) is a good hint. I will try to implement this, but I don't have any devices to test. Can you help me and test it when I am ready?

@NajiLutfalla
Copy link
Author

Yeah can do

@domisol
Copy link

domisol commented Apr 13, 2021

Your program is great, but I have the same issue!
I can also test it with pleasure when you get it updated.

@MoonLiightz MoonLiightz added the bug Something isn't working label Apr 17, 2021
MoonLiightz added a commit that referenced this issue Apr 17, 2021
Remove cold warm (cw) bits from the color command bit mask to hopefully
keep the cw devices from being turned off.

Related to #2
@MoonLiightz
Copy link
Owner

Thanks for your feedback and sorry for the delay.
I have committed a possible fix in the fix/color-change branch. Are you able to test this directly from source? Golang has to be installed.

# Clone this repo
git clone https://github.com/MoonLiightz/magic-home.git
cd magic-home

# Checkout the branch with the fix
git checkout origin/fix/color-change

# Test the fix
go run cmd/main.go color <ip> <r> <g> <b>

@domisol
Copy link

domisol commented Apr 18, 2021

Thanks to you for your efforts !
As you can see it's a pity, but it doesn't work

go run cmd/main.go status --json 192.168.1.169
{"DeviceType":53,"State":0,"LedVersionNumber":8,"Mode":97,"Slowness":5,"Color":{"R":0,"G":0,"B":0,"W":3}}
go run cmd/main.go color 192.168.1.169 22 44 55
go run cmd/main.go status --json 192.168.1.169
{"DeviceType":53,"State":0,"LedVersionNumber":8,"Mode":97,"Slowness":5,"Color":{"R":0,"G":0,"B":0,"W":3}}

In the Terminal, the command I successfully use are:
echo "31 13 08 f3 00 00 f0 0f 43" | xxd -r -p | nc 192.168.1.169 5577
echo "31 00 00 00 20 40 0f 0f 43" | xxd -r -p | nc 192.168.1.169 5577
First one is RGB mode with R=0x13, G=0x08, B=0xf3
Second one is white LEDS with Warm = 0x20 and Cold = 0x40

Hope this helps!!!

MoonLiightz added a commit that referenced this issue May 2, 2021
@MoonLiightz
Copy link
Owner

Thanks @domisol, this helps a lot.
I think that the second last byte was not set correctly. In your terminal tests you have set it to 0x0f. I did the same now. Can you pull the changes in fix/color-change and test an RGB color change again?

@domisol
Copy link

domisol commented May 3, 2021

Hi Patrick. You're welcome. It seems it still doesn't work, but I'm not a github expert, so not sure how to pull the changes you asked me. But for my part I've been wondering a bit more and want to share a few more details with you.
First, I have two type of bulbs. On the version 8, I can use any byte for checksum byte it works. Version 7 requires a real calculated checksum to work. So in my last comment I put always "43" at the end of every message, but of course this is not correct, some bulbs need a true checksum.
Also there are a few little more options in version 8.
My main source to find correct codes is:
https://github.com/sahilchaddha/homebridge-magichome-platform/blob/master/src/flux_led_beta.py
As a synthesis:
"81 8a 8b" asks state.
"61 xx yy 0f" send preset where xx is preset number and yy is speed
"31 00 00 00 ww cc 0f 0f" send cold/warm blue light with ww and cc for warm and cold values.
"31 rr gg bb 00 00 f0 0f" send rgb light with rr gg bb for red green blue values.
"71230f" switches on
"71240f" switches off
"51 r1 g1 b1 51 r2 g2 b2....... r16 g16 b16 56 00 ss tt ff 0f" send custom preset with up to 16 rgb presets (r1 g1 b1 ... r16 g16 b16) and ss is speed and tt is 3a for gradual, 3b for jump, 3c for strobe.
There are also interesting timers functions...
This is for RGBCW lamps, which are the one I used, YMMV in the case of other types.
Jean-David

@MoonLiightz
Copy link
Owner

Thanks for your feedback.
If you are not sure how to get the changes you could click here and then use the green button to download the repo as a ZIP. Alternatively, I can attach a compiled version if you tell me for which architecture you need it.
The checksum thing is interesting, I was surprised at first that it always worked with 0x43. I always calculate the checksum in the code, should then work for version 7 and version 8 devices. But good to know.
It's also interesting that my on and off commands are different than the ones you wrote.

# my on command
0x71 0x23 0x94
-     -     -     
|     |     |     
|     |     +--------- checksum
|     +--------------- on command byte
+--------------------- command type (on/off)

# your on command
0x71 0x23 0x0f 0xa3
-     -     -    -
|     |     |    |
|     |     |    +------- new checksum after adding previous byte
|     |     +------------ I have no idea what this byte stands for?
|     +------------------ on command byte, like mine
+------------------------ command type (on/off), like mine

On my device both versions work, how is that for you, can you turn your devices on and off with my program?

When I developed this I didn't know about other devices with different commands. Maybe I need to order one of your devices so I can test it myself while programming. I would like to support all of this, including things like presets, but I will have to make a few more changes. Probably even breaking changes so we'll have to go to v2 here.
Can you send me a link of one of your devices? The best would be a store with global shipping like AliExpress.

@MoonLiightz
Copy link
Owner

Hi guys, as expected, breaking changes are necessary to provide a clean support of cold white devices. I will start the development in the v2 branch and keep you updated.

@MoonLiightz MoonLiightz added this to the v2.0.0 milestone Jun 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants