- Platform information:
Latest OpenHabian on Pi4 (fresh install) - Issue of the topic: I have a FEIT RGBW bulb that I have flashed with Tasmota 9.2 and setup MQTT as needed. Everything seems to work except that tasmota has a range of 153:500 for Warm to Cool white… so I write a transform that takes the 2200:7000 Cool:Warm (Alexa inverts Kelvin for some strange reason) and maps it down the correct values:
/etc/openhab/transform/lighttemps.js:
(function(i) {
var lightMax = 500;
var lightMin = 153;
var tempMax = 7000;
var tempMin = 2200;
var result = (i - tempMin)/(tempMax - tempMin) * (lightMax - lightMin) + lightMin;
return Math.round((lightMax+lightMin)-result);
})(input)
In my Channel defintion for the light I have set the Profile to “JS” and the JavaScript filename to lighttemps.js. I have exposed the Lamp Group as Lighting and also tagged the “Color Temp” point as
ColorTemperatureController.colorTemeratureInKelvin for Alexa.
When I say, “Alex set Foyer Lamp to Cool White,” I get the following:
2020-12-28 20:13:20.347 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘FoyerLamp_ColorTemp’ received command 4000
2020-12-28 20:13:20.351 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item ‘FoyerLamp_ColorTemp’ predicted to become 7000
And in the console for the bulb I get:
21:13:20 MQT: stat/L_Foyer/RESULT = {“CT”:500}
- Anything value greater than 500 = 500
The value should be 336…
So how do I get Alexa’s (backward) Kelvin values to actually transform before dropping them into the queue?