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

Dimmer switch failed to turn off #320

Open
1 task done
tatdathoang opened this issue Nov 19, 2023 · 27 comments
Open
1 task done

Dimmer switch failed to turn off #320

tatdathoang opened this issue Nov 19, 2023 · 27 comments
Assignees
Labels

Comments

@tatdathoang
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

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
Copy link

shugass commented Nov 19, 2023

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
Copy link

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
Copy link
Owner

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
Copy link
Owner

plasticrake commented Nov 19, 2023

Please try installing this prerelease version: [email protected]

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.

@plasticrake plasticrake self-assigned this Nov 19, 2023
@plasticrake plasticrake changed the title Dimmer switch failed to turn on Dimmer switch failed to turn off Nov 19, 2023
@timleeds15
Copy link

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

@plasticrake
Copy link
Owner

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

No

@plasticrake
Copy link
Owner

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

@keenkreations
Copy link

keenkreations commented Nov 19, 2023

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
Copy link

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
Copy link
Author

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
Copy link

Please try installing this prerelease version: [email protected]

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
Copy link

nickv2002 commented Nov 19, 2023

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
Copy link
Owner

plasticrake commented Nov 19, 2023

Can someone please test using [email protected] 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
Copy link

@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
Copy link
Owner

Fixed in d267e40 deff054 [email protected]

@shugass
Copy link

shugass commented Nov 20, 2023

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
Copy link
Author

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
Copy link
Owner

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
Copy link

shugass commented Nov 20, 2023

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
Copy link
Owner

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 [email protected] if you prefer. Thanks!

@shugass
Copy link

shugass commented Nov 20, 2023 via email

@plasticrake
Copy link
Owner

@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
Copy link

shugass commented Nov 21, 2023 via email

@shugass
Copy link

shugass commented Nov 22, 2023

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

@plasticrake
Copy link
Owner

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

@shugass
Copy link

shugass commented Nov 22, 2023 via email

@chas3914
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants