caseyjhol / node-red-contrib-tplink

A collection of Node-RED nodes for TP-Link Smart Home devices
https://www.npmjs.com/package/node-red-contrib-tplink-iot
MIT License
16 stars 15 forks source link

Bugfix - Allow Temperature mode back to HSB mode #66

Closed SubBass100 closed 1 year ago

SubBass100 commented 1 year ago

I had a an issue request yesterday that I have solved. I've branched tested and updated the code and would like to contribute back to the project.

--the problem--

Currently you can change bulb colors by setting HSB which works great. You can then select a temperature (say 2700) and the bulb will leave hsb mode and enter temperature mode. If you give the bulb a new HSB value, it will not change to a color. I noticed that when in hsb mode the temperature value reads zero. After some testing I've concluded that by setting the temperature to zero the bulb leaves temperature mode and returns to the last hsb value used (which is pretty cool).

--the fix--

I've added an OR to your IF statement that checks the range to include 2700 to 6500 OR 0 to respect your range but also allow zero. I've also updated the helper function to include 0 and the readme.md so people know they can use it.

Thanks again for a great implementation!

caseyjhol commented 1 year ago

Thanks!