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

python-kasa 0.4.1 output breaks homebridge-kasa-lightrstrip parsing #8

Open
justinmm2 opened this issue Jan 29, 2022 · 8 comments
Open

Comments

@justinmm2
Copy link

Hi,

I wanted to report this for anyone Googling. In short, homebridge-kasa-lightstrip won't work properly if your version of python-kasa is too new (0.4.1). In summary: python-kasa now wants "--type lightstrip" instead of "--lightstrip". Using the older "--lightstrip" argument will cause the "kasa" binary to print a warning about deprecated arguments; in turn, homebridge-kasa-lightstrip will fail to parse this warning message, thinking it's an HSV string.

I've written to @steveredden because I've got a patch to fix this so close to working..

@steveredden
Copy link
Owner

steveredden commented Jan 30, 2022

Nice find -

The lazy fix: is it possible to just use the old version of that library - does everything work as expected?

pip3 install python-kasa==0.4.0

I have not updated to 0.4.1 of their library, so everything (of course) works fine for me... 🤦‍♂️

Otherwise, the first glance at your diff seems like a fine start, indeed!

@justinmm2
Copy link
Author

I suppose using 0.4.0 probably would work? But I'm not sure how you'd enforce that, unless package.json has some way of installing pip packages?

If you have thoughts on how I can clean up the async issue, let me know! Would hate to see this wither on the vine. I asked on the Homebridge Discord (#plugin-development), but there wasn't any response. Either way, the (unrelated) string parsing bugfixes dramatically cut down on the number of warning messages in my environment. The async thing is a shame; it works 95% of the time for me, but I don't want to open a PR for code that's not 100% - there must be a way to do it, no?

@steveredden
Copy link
Owner

steveredden commented Jan 31, 2022

Total js noob here too. But I would think your exec version parsing best belongs in the initial load of the plugin, line 10:17 area:

This way you’re only retrieving and parsing it once.

[maybe even add a fatal error or at least warning log message if the user HASNT installed the Kasa python package… enhancement]

Then, pass a new param (bool or something) that indicates which exec variant to use:

new KasaLightstrip(this.log, lightstrip, this.api, this.debug, uuid, accessory);

And

constructor(log, config, api, debug, uuid, device) {

.

@JBryant915
Copy link

JBryant915 commented May 2, 2022

I am having this same issue. when the argument is sent with --lightstrip instead of --type lightstrip, or even just leaving that argument out all together, it works. I can turn it on or off with simply "kasa --host 'ipaddress' on" or "kasa --host 'ipaddress' --type lightstrip on. Turning off works the same except, of course, substituting off for on in both cases issuing the command from CLI of my rpi. I did do the pip3 install python-kasa==0.4.0, which would allow the command to run as is from CLI, but not from the plugin, looks like it still tries to use the newer version of Kasa for some reason. Not sure how to uninstall so only 0.4.0 would be the only one there.

Is there any updates as to when this maybe corrected?? Thanks for all the hard work!!

@steveredden
Copy link
Owner

The newest versions of python-kasa prove to be quite unstable in my testing. VERY frequently getting timeout/connection errors in their protocol.py file.

A known-good version (and the version this was developed against) is 0.4.0.dev3

I recommend everyone pins to that version, using:

sudo pip3 uninstall python-kasa
sudo pip3 install python-kasa==0.4.0.dev3

@JBryant915
Copy link

JBryant915 commented May 2, 2022 via email

@JBryant915
Copy link

I do believe that did it for me. I'm not at home, but doing this by remote. I just did the basic config so on/off is all I can test at the moment. I verified that much by using the Kasa app to check to see if using the dashboard widget turned it on or off and it did so I couldn't think of a reason it wouldn't work in HK. When I get home, I will add the affects switches and then add it to homekit. I have no doubt it will work. Thanks for all you guys do!!

@JBryant915
Copy link

JBryant915 commented May 2, 2022

Well I thought that would do it, but it only mostly did the trick. I got home, changed the config to include aurora, flicker and rainbow affects and saved it. Added it to Homekit and it won't turn the strip on. It acts like it does and shows it at 22 present brightness but doesn't actually turn the strip on. Funny thing is, any of the 3 affects will turn the light on and actually work for the affect that was chosen. The main tile to turn on/off the strip will actually turn the strip off. Just not on. Any ideas there?

I should note that when I try to turn the strip on with the Homekit tile, I can open the Kasa app and it does show that the strip should be on. Which confuses me even more.

EDIT:

Once the strip is on, I can control colors and brightness through Homekit as well, just won't turn it on for some reason, lol

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

No branches or pull requests

3 participants