CodeBardian / tplink-smartdevices-netstandard

.NET Standard 2.0 Library for Discovering and Operating TP-Link Smart Devices
https://codebardian.github.io/tplink-smartdevices-netstandard/
Apache License 2.0
18 stars 5 forks source link

tp-link KL-130 color not changing #6

Open ivandrofly opened 4 years ago

ivandrofly commented 4 years ago

see: https://github.com/CodeBardian/tplink-smartdevices-netstandard/issues/5#issuecomment-686252075

Jqnxyz commented 4 years ago

Am also experiencing this issue on a LB-130. Any workaround?

ivandrofly commented 4 years ago

Am also experiencing this issue on a LB-130. Any workaround?

I'm currently working on a patch for this.. maybe I need accelerate a bit :)

Jqnxyz commented 4 years ago

Saw your PR, I'd help but my .NET experience is extremely lacking hahaha

ivandrofly commented 4 years ago

Saw your PR, I'd help but my .NET experience is extremely lacking hahaha

No worries, I got your back 😄 !

CodeBardian commented 3 years ago

I just checked on this issue and it seems like it is caused because the command to change colour is build wrong. Not because it does not allow multiple commands at once. There simply is not a light_state object, instead all arguments are directly passed with transition_light_state So changing this:

Execute("smartlife.iot.smartbulb.lightingservice", "transition_light_state", "light_state", new JObject 
{
    new JProperty("hue", hsv.Hue),
    new JProperty("saturation", hsv.Saturation),
    new JProperty("brightness", (int)(hsv.Value * 100 / 255)),
});

to below, should solve the problem. At least it does for my KL-130, no clue about LB-130 yet :)

Execute("smartlife.iot.smartbulb.lightingservice", "transition_light_state", new JObject
{
    new JProperty("hue", hsv.Hue),
    new JProperty("saturation", hsv.Saturation),
    new JProperty("brightness", (int)(hsv.Value * 100 / 255)),
}, null);
ivandrofly commented 3 years ago

I just checked on this issue and it seems like it is caused because the command to change colour is build wrong. Not because it does not allow multiple commands at once. There simply is not a light_state object, instead all arguments are directly passed with transition_light_state So changing this:

Execute("smartlife.iot.smartbulb.lightingservice", "transition_light_state", "light_state", new JObject 
{
    new JProperty("hue", hsv.Hue),
    new JProperty("saturation", hsv.Saturation),
    new JProperty("brightness", (int)(hsv.Value * 100 / 255)),
});

to below, should solve the problem. At least it does for my KL-130, no clue about LB-130 yet :)

Execute("smartlife.iot.smartbulb.lightingservice", "transition_light_state", new JObject
{
    new JProperty("hue", hsv.Hue),
    new JProperty("saturation", hsv.Saturation),
    new JProperty("brightness", (int)(hsv.Value * 100 / 255)),
}, null);

Alright I will test your solution and report back! Thanks for information

ivandrofly commented 3 years ago

I haven't test your code yet, but new JProperty("brightness", (int)(hsv.Value * 100 / 255)), will still 'cause problem... the KL-130 model color are represented in degrees from 0-360

CodeBardian commented 3 years ago

I haven't test your code yet, but new JProperty("brightness", (int)(hsv.Value * 100 / 255)), will still 'cause problem... the KL-130 model color are represented in degrees from 0-360

Yes, that is true. I removed that nonsense in my tests too. when building the project from _color_changingfix branch I am now able to apply every color I could think of.

ivandrofly commented 3 years ago

Yes, that is true. I removed that nonsense in my tests too. when building the project from _color_changingfix branch I am now able to apply every color I could think of.

Nice, if you have any uncommitted changes please push them so I can rebase my branch/PR onto that...