Add temperature scaling for Tuya lights #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a pull request to resolve issue #16.
As far as I can tell, rather than using the
CTL Temperature
field to directly set the temperature of the light, it maps the value of temperature from 800 to 20,000 K to a temperature between its own minimum and maximum (say 3,000 and 6,000 K for simplicity). As an equation:light_temperature = 3000 + (message_temperature-800) * (6000-3000) / (20,000-800)
In effect this means that changing the temperature within the 3000 K to 6000 K exposed in the UI results in negligible change in the output colour (~3340 to ~3810 K).
The fix applies the inverse scaling function when a configuration variable is set to true. The pull request also includes changes from another fork (upon which my fork is based).