iklein99 / homebridge-smartthings

This is a plugin to Homebridge to connect your Smartthings network into Apple Home Kit.
Apache License 2.0
150 stars 52 forks source link

Changing colour on a lightbulb doesn't work #96

Closed obrassard closed 1 year ago

obrassard commented 1 year ago

Describe The Bug:

When trying to change the colour of a RGB lightbulb the Home app, an error is thrown by the plugin. It seem that there is an issue with the API call that is made to Smart Things API when trying to set a new hue or saturation.

To Reproduce:

  1. Pair a RGB Light Bulb with Samsung SmartThings app
    • in my case it is a Teckin LightBulb paired with SmartLife (Tuya) and connected to SmartThings
  2. When the device appear in the Home app, click on the RGB light and try changing the colour
  3. The colour of the light bulb does not change an error is printed in the Homebridge Console

Note : Changing the colour in the SmartThings app works properly.

Expected behavior:

The colour of the lightbulb should be updated properly like it is when changing the colour directly in SmartThings

Logs:

Capture d’écran, le 2022-11-28 à 23 42 25

Plugin Config:

{
    "bridge": { ...
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Smartthings Plug (IK)",
            "BaseURL": "https://api.smartthings.com/v1/",
            "AccessToken": "...",
            "GarageDoorMaxPoll": 0,
            "PollLocksSeconds": 0,
            "PollDoorsSeconds": 0,
            "PollSensorsSeconds": 5,
            "PollSwitchesAndLightsSeconds": 1,
            "IgnoreDevices": [
                "Piscine"
            ],
            "platform": "HomeBridgeSmartThings"
        }
    ]
}

Environment:

obrassard commented 1 year ago

It seems to be an issue with the SmartThings API. Indeed, the API returns a cast error when trying to set hue or saturation with the following body :

[{"capability":"colorControl","command":"setHue","arguments":[10]}]

The request body seems ok according to SmartThings docs but still, we receive an error

Capture d’écran, le 2022-11-30 à 10 41 04

However, when changing the color using the setColor command it work...

Capture d’écran, le 2022-11-30 à 10 45 27
iklein99 commented 1 year ago

Thanks for looking into this. I am currently at the AWS conference. I'll be delayed in trying to fix this.

obrassard commented 1 year ago

Now worry, I started a thread on SmartThings Developers Community to see if they can do something on their side

https://community.smartthings.com/t/bug-with-sethue-and-setsaturation-commands-for-devices-with-colorcontrol-capabilities/253078

iklein99 commented 1 year ago

I'm going to fix this by using the setColor command if I detect an error sending individual hue and saturation. Will need you to test for me.

obrassard commented 1 year ago

@iklein99 Perfect, I think that's the best solution considering the information we have. I'm curious to see your PR, as I had tried to do this fix the other day, but wasn't sure how to proceed!

iklein99 commented 1 year ago

Fixed in 1.4.17. Try it out and let me know.

obrassard commented 1 year ago

@iklein99 Unfortunately it does not work

Capture d’écran, le 2022-12-11 à 11 32 03

The light bulb colour does not change

iklein99 commented 1 year ago

Ok. Think I found the issue. Try 1.4.18.

obrassard commented 1 year ago

@iklein99 It works ! Although, it seems that some colors are weird (between what I choose in the Home app, and the color that is really on the bulb), but it is probably not related to your fix

Capture d’écran, le 2022-12-11 à 19 10 29
obrassard commented 1 year ago

it seems that some colors are weird

Especially when switching quickly between colours... but anyway it's not a big deal!