plasticrake / homebridge-tplink-smarthome

TP-Link Smarthome Plugin for Homebridge
MIT License
467 stars 70 forks source link

Dimmer switch failed to turn off #320

Open tatdathoang opened 7 months ago

tatdathoang commented 7 months ago

Is there an existing issue for this?

What happened?

After updating to version 8.0.0, all dimmer failed to turn the light off. Exception as follow: Unhandled error thrown inside write handler for characteristic: err_code not zero response: {"err_code":-3,"err_msg":"invalid argument"} command: {"smartlife.iot.dimmer":{"set_brightness":{"brightness":0}}}

Dimmer can be turned off normally via Kasa or GH.

What, if anything, has recently changed?

Upgraded to version 8.0.0

Version

8.0.0

Node Version

16.20.2

Homebridge Version

1.6.0

Which OS/Platform?

macOS

Relevant log output

Unhandled error thrown inside write handler for characteristic: err_code not zero response: {"err_code":-3,"err_msg":"invalid argument"} command: {"smartlife.iot.dimmer":{"set_brightness":{"brightness":0}}}

Configuration

{
    "platform": "TplinkSmarthome",
    "name": "TplinkSmarthome",
    "deviceTypes": [
        "plug"
    ]
}
shugass commented 7 months ago

None of my dimmers will turn on since installing v8. I figured out that v8 added outlet accessories to all my switches, which meant I now had to switch the outlet instead of the switch, so now every switch had 2 accessories, both the original switch, and this new outlet. The only way to turn off dimmers now is set the slide to zero percent, which means I couldn't turn them off just by clicking the left side of the button for them anymore. Also all my light switch automation broke. Reverted back to v7 and everything works perfectly as expected.

timleeds15 commented 7 months ago

Same problem here. My HS220 switches are useless now in the home app. My switches also got split into 2 accessories as well and broke everything. Now it shows a light AND an outlet? Only the “outlet” works

plasticrake commented 7 months ago

Odd this issue is popping up now as the code that relays the HomeKit brightness value to the device hasn't changed. The only change is a HomeKit lightbulb service is created for these switches instead of an outlet service that has a brightness characteristic. I made this change as adding a brightness characteristic to an outlet technically doesn't match HomeKit specs. My only guess is HomeKit wasn't relaying a brightness of 0 when the slider was all the way down before? I can either make it so that the minimum brightness is 1, or I can intercept the brightness of 0 and instead just turn off the light. I assume the later is preferrable. But I don't even have any of these devices myself.

plasticrake commented 7 months ago

Please try installing this prerelease version: homebridge-tplink-smarthome@8.0.1-0

I changed the method this plugin uses to communicate with the device from set_brightness to set_dimmer_transition with a transition time of 1 (ms). I believe it supports a brightness value of 0. Let me know if this works as I don't have a device to test it myself. If it doesn't work I'll change it to intercept a value of 0 and just turn off the device.

timleeds15 commented 7 months ago

Should the prerelease version also address the issue of the duplicate devices?

plasticrake commented 7 months ago

Should the prerelease version also address the issue of the duplicate devices?

No

plasticrake commented 7 months ago

Looks like this issue may be older, I see #312 reports it as well with the older version.

keenkreations commented 7 months ago

I also came into this discussion to see why the lights were not turning on. As for me, the switches I have (HS220) did not duplicate out as outlets. The issue for me was that the lights were not responding to commands in HomeKit; I had to use the Kasa app to control them from a phone. Could not turn on or off, or dim them in HomeKit. I ended up rolling back to version 7.0.1 to get it back to functioning as before.

timleeds15 commented 7 months ago

So it seems like only the HS200 switches got split into two. The HS220s did not, they just completely broke instead. Had to go back to 7.0.1

tatdathoang commented 7 months ago

For me, the split into two devices issue seems to be fixed by clearing the cache and pair again. I'm using HOOBS box, I don't know if it's possible to specify a version to install since it does not have a console interface. When I check for new version, 8.0.0 is the latest one it finds.

timleeds15 commented 7 months ago

Please try installing this prerelease version: homebridge-tplink-smarthome@8.0.1-0

I changed the method this plugin uses to communicate with the device from set_brightness to set_dimmer_transition with a transition time of 1 (ms). I believe it supports a brightness value of 0. Let me know if this works as I don't have a device to test it myself. If it doesn't work I'll change it to intercept a value of 0 and just turn off the device.

So I tried the prerelease version and the dimmer switches work but I have to go inside the switches to slide them down to turn them off. You can no longer just press the left side of the button to quickly turn it off, back to 7.0.1 for now.

nickv2002 commented 7 months ago

I was having similar issues with 8.0.0 breaking all my dimmers. Reverting to 7.0.1 seems to bring them back to working order after a quick test.

(Already cleared out my dupe switches otherwise I'd send my cachedAccessories your way)

plasticrake commented 7 months ago

Can someone please test using homebridge-tplink-smarthome@8.0.1-1 to see if it fixes turning off the switch using the button tap?

I can try to troubleshoot the duplicate devices issue. But I cannot replicate it on my end. I'm fairly certain if you cleared your device cache the duplicate would disappear. But I'd like to fix it so users do not have to do that and have to setup the devices as new. Can someone with this issue please provide their cachedAccessories file and I can probably figure it out.

brandonb927 commented 7 months ago

@plasticrake I just ran into this issue coincidentally after installing my first outdoor dimmer (KP405) and the prerelease version fixed the issue I had where in v8.0.0 the device was not turning on at all. I don't have any duplicate device issues that everyone else seems to have so I will say that your fix in this version has addressed a regression, at least in my case, with dimmers that you set out to fix! 🙌 I've been using this plugin for a long time and I appreciated the work you've put into this over the years 🦾

plasticrake commented 7 months ago

Fixed in d267e40ee0ab11f6182269dea16d5a0a2b328063 deff0549eb7c9d419a259257aa053f800e57b24a homebridge-tplink-smarthome@8.0.1

shugass commented 7 months ago

So version 8.0.1 fixed the dimmers, but broke the regular switches. Dimmer now only consist of a switch, but the regular switches now consist of 2 accessories grouped together - the switch, and an outlet. Clicking on the left side of the button for the regular swiches no longer works, but works fine for the dimmers. Dropped back to v 7.0.1 and everything is fine again. Logs after downgrading to older version show "removing stale service outlet" for the regular switches that broke in v 8.0.1.

tatdathoang commented 7 months ago

8.0.1 works for both switch types for me. The split into two device issue can be fixed by clearing cache, but that requires binding all devices and setup automations, scenes again.

plasticrake commented 7 months ago

I've been asking for someone to provide me their cachedAccessories who is currently experiencing duplicate devices but so far I have not had any takers. I can't really help without it. It appears that deleting this file will "fix" the issue but I'd like to find out why this happened and I can update the code to fix itself without requiring the file to be deleted or modified.

shugass commented 7 months ago

I'll get you my cached accessory list, is there an easier way to do it aside from a bunch of screenshots? I assume we should do it before and after the duplicates arrive once v8 is installed?

plasticrake commented 7 months ago

I'll get you my cached accessory list, is there an easier way to do it aside from a bunch of screenshots? I assume we should do it before and after the duplicates arrive once v8 is installed?

@shugass I would like the actual file contents, not a screenshot. You can attach it here or you can email code@plasticrake.com if you prefer. Thanks!

shugass commented 7 months ago

I’m just not sure how to do that, I’ll need some guidance. Thanks!

From: Patrick Seal 'notifications at @.> Sent: Monday, November 20, 2023 5:08 PM To: @*.**@*.***> Subject: Re: [plasticrake/homebridge-tplink-smarthome] Dimmer switch failed to turn off (Issue #320)

I'll get you my cached accessory list, is there an easier way to do it aside from a bunch of screenshots? I assume we should do it before and after the duplicates arrive once v8 is installed?

@shugasshttps://github.com/shugass I would like the actual file contents, not a screenshot. You can attach it here or you can email @.**@.> if you prefer. Thanks!

— Reply to this email directly, view it on GitHubhttps://github.com/plasticrake/homebridge-tplink-smarthome/issues/320#issuecomment-1819882216, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AQBYGZHHYXNUW6VELVV2AKTYFPIDTAVCNFSM6AAAAAA7RLSKSCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJZHA4DEMRRGY. You are receiving this because you were mentioned.Message ID: @.> This email was sent to @. (github site) from @.*** Click herehttps://app.addy.io/deactivate/ec8f5aa2-4ed2-4416-b011-eb13de68c3fb?signature=2c14f20b92b523b4412ebad2569f5654d2b05cc10073de1621d6e2accdb70a9b to deactivate this alias

plasticrake commented 7 months ago

@shugass The instructions to access the cachedAccessories file are highly dependent on which OS and method you're running homebridge. But if you use homebrige-config-ui-x you can click the three dots in the upper right corner and export a backup of your homebridge files. You can send that entire thing or just the cachedAccessories file to me.

shugass commented 7 months ago

Thanks, I emailed them directly to you. Both before and after the v8 install so you should be able to see the duplicates. Thanks!

From: Patrick Seal 'notifications at @.> Sent: Monday, November 20, 2023 5:40 PM To: @*.**@*.***> Subject: Re: [plasticrake/homebridge-tplink-smarthome] Dimmer switch failed to turn off (Issue #320)

@shugasshttps://github.com/shugass The instructions to access the cachedAccessories file are highly dependent on which OS and method you're running homebridge. But if you use homebrige-config-ui-x you can click the three dots in the upper right corner and export a backup of your homebridge files. You can send that entire thing or just the cachedAccessories file to me.

— Reply to this email directly, view it on GitHubhttps://github.com/plasticrake/homebridge-tplink-smarthome/issues/320#issuecomment-1819919212, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AQBYGZGPPW5COVFTGJOPSWDYFPL6RAVCNFSM6AAAAAA7RLSKSCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJZHEYTSMRRGI. You are receiving this because you were mentioned.Message ID: @.> This email was sent to @. (github site) from @.*** Click herehttps://app.addy.io/deactivate/ec8f5aa2-4ed2-4416-b011-eb13de68c3fb?signature=2c14f20b92b523b4412ebad2569f5654d2b05cc10073de1621d6e2accdb70a9b to deactivate this alias

shugass commented 7 months ago

Hi @plasticrake just wanted to make sure the cachedAccessories files made it to you?

plasticrake commented 7 months ago

@shugass Yes thank you! Can you tell me which device(s) were duplicated?

shugass commented 7 months ago

For sure it is at least these ones (see screenshot), since they say “all off” they are referring to the switch & the plug, so those ones for sure at least. Those are the easiest to fine as they show up on the main favorites pages since they didn’t exists before so weren’t “de-favorited” yet.

Upstairs, kitchen, landing, driveway light, printer, laundry, storage room, switch backyard, switch shed.

@.***

From: Patrick Seal 'notifications at @.> Sent: Tuesday, November 21, 2023 9:50 PM To: @*.**@*.***> Subject: Re: [plasticrake/homebridge-tplink-smarthome] Dimmer switch failed to turn off (Issue #320)

@shugasshttps://github.com/shugass Yes thank you! Can you tell me which device(s) were duplicated?

— Reply to this email directly, view it on GitHubhttps://github.com/plasticrake/homebridge-tplink-smarthome/issues/320#issuecomment-1822006599, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AQBYGZHLYJTJ5TD5XNO6IALYFVSATAVCNFSM6AAAAAA7RLSKSCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRSGAYDMNJZHE. You are receiving this because you were mentioned.Message ID: @.> This email was sent to @. (github site) from @.*** Click herehttps://app.addy.io/deactivate/ec8f5aa2-4ed2-4416-b011-eb13de68c3fb?signature=2c14f20b92b523b4412ebad2569f5654d2b05cc10073de1621d6e2accdb70a9b to deactivate this alias

chas3914 commented 7 months ago

I thought I would add my experiences to hopefully help with this issue. I just removed some old Tuya switches and changed to Kasa, both HS220 and HS210. During install into the Kasa app I was asked to update the firmware on both switch types (HS220 & HS210) which I did. I was running plugin 7.0.1 but I noticed the duplicating problem. So, I upgraded to 8.0.1. Then I went into Homebride Settings/Manage cached accessories/Remove Single Cached Accessory and deleted the cache for each new switch one by one rebooting after each removal. I first tried removing all the cached new switches at once but I saw no changes. When I removed one cached switch followed by a reboot of HB the duplicates went away.