steveredden / homebridge-kasa-lightstrip

A homebridge plugin for controlling Kasa Light Strips :zap:
MIT License
2 stars 1 forks source link

1) Fix minor parsing issues in hue/saturation get'ing. Should reduce … #9

Open justinmm2 opened 2 years ago

justinmm2 commented 2 years ago

…the number of warning messages (as well as display proper info!)

2) Thie bigger issue: python-kasa now wants --type lightstrip, and has deprecated --lightstrip. So, upon init, check version of PK. If 0.4.0, use old style. If 0.4.1 or newer, use new style. Place most parsing code in try/catch blocks. Failures result in version 0.0.0 getting set, which in turn causes an informational message pointing to the README.md for installing python-kasa. I've tried to do this all in such a way that it a) avoids bringing down Homebridge in the event of errors, b) is persistent about warnings. It's easy to miss them in the log if they only happen at init.

justinmm2 commented 2 years ago

Hey @steveredden - please review carefully, leave comments, changes, etc.

I ask for the close review because I've been doing this whole on a hobbled together Synology docker environment, I've actually been cutting and pasting my code over from my desktop; next time I won't make the same mistake and will set up a proper dev environment. I did my best to try python-kasa both 0.4.0 and 0.4.1, and made dummy 'kasa' binaries that printed versions like 0.0.0, 0.1.0, 0.5.0, etc.

One thing I tried to do here is make the plugin more resilient to python-kasa parsing. Put a few things inside try/catch() blocks, and the whole thing is very verbose now about installing python-kasa; if it can't properly run or parse the version string, it suggests to the user they do so. Notably, it does so at any point it can't properly operate, not just at initialization time! Some of my earliest HB issues were caused by the error only being printed at the beginning of the log, and me not seeing it at all!

Hope this helps!

justinmm2 commented 2 years ago

Just noticed I missed KasaLightEffect.js (never used it). Will see what I can do shortly.. (Edit: updated) I actually have no idea how to use these from Apple Home, so it's completely untested