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

Add multi-component light switch support #71

Closed kliu99 closed 1 year ago

kliu99 commented 1 year ago

Fix #70.

iklein99 commented 1 year ago

I don't think this will work. I think the status query will fail since it only looks at the main component.

Can you run this on that device and send me the results? curl -H "Authorization: Bearer: " \ https://api.smartthings.com/v1/devices//status

Replace those fields with the proper values and send me the results.

kliu99 commented 1 year ago

It seems working for me in my local demo. The response is attached: https://gist.github.com/kliu99/4fec6261790bfa391d46f2f5be89af03

iklein99 commented 1 year ago

The issue is that while you are looking through all of the components for the capabilities, the fetching of status only looks at the ‘main’. It just so happens that the capabilities you care about are in the main component (just not the first one).

I made a smaller simpler change that is checked in. Since you can pull that down and test it. I changed it look at the main component (which is where your light capabilities are). Test this out and let me know.

I will look into better support for multi-component devices in a future release. In order to do that, I need to maintain (track) which component a capability is on so that I can make sure to query the right component.

Let me know how your testing goes.

On Nov 1, 2022, at 8:21 PM, Kai Liu @.***> wrote:

It seems working for me in my local demo. The response is attached: https://gist.github.com/kliu99/4fec6261790bfa391d46f2f5be89af03 https://gist.github.com/kliu99/4fec6261790bfa391d46f2f5be89af03 — Reply to this email directly, view it on GitHub https://github.com/iklein99/homebridge-smartthings/pull/71#issuecomment-1299386373, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABG55EQSSDNEO4DT3UB5U43WGGXYJANCNFSM6AAAAAARSU5TNE. You are receiving this because you commented.

kliu99 commented 1 year ago

I doesn't work in my local instance. Getting comm error: https://gist.github.com/kliu99/1ab072e3d922b7ec47b6bee2e8854ef4

kliu99 commented 1 year ago

The problem is in the lightService.ts, you are still reading from accessory.context.device.components[0].capabilities instead of reading from the main component. I'd suggest you extract a function like I did in the PR that finds the compatible device component and reuse it in lightService.ts and also in the platform.ts so that they won't get out-of-sync in the future.

iklein99 commented 1 year ago

Give it another try.

kliu99 commented 1 year ago

Works now. Thanks for the fix.

kliu99 commented 1 year ago

Are you planning to bump the version so I can get the update for my prod instance?

iklein99 commented 1 year ago

Yes, I will. The fix will be in the next release.

On Nov 5, 2022, at 3:43 PM, Kai Liu @.***> wrote:

Are you planning to bump the version so I can get the update for my prod instance?

— Reply to this email directly, view it on GitHub https://github.com/iklein99/homebridge-smartthings/pull/71#issuecomment-1304620532, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABG55EVWRZ35PBFGU74YX4LWG22FLANCNFSM6AAAAAARSU5TNE. You are receiving this because you modified the open/close state.