- Platform information:
- RaspBerryPi 4 8GB
- Openhabian
- Java Runtime Environment: comes with openhabian
- openHAB version: 3.0.1
I am making a rule for converting Hue Illuminance to Lux for IHC and wants to use Math.log10 but it gives me the following error in the openhab.log: “failed: TypeError: Math.log10 is not a function in <eval> at line number 2”
The rules is crated in the UI as an ECMAScript rule:
var tempno = parseFloat(itemRegistry.getItem("hueSensorIlluminanceOut").getState());
var luxnumber = Math.log10(tempno + 1) * 10000;
//Adjusting luxcalculation to be within IHC accept level of 0-60000 Lux
luxnumber = (luxnumber < 0) ? 0 : luxnumber;
luxnumber = (luxnumber > 60000) ? 60000 : luxnumber;
events.sendCommand("IHC_Lux_Ude_HUE", luxnumber);
If I try to use Math.log it woks fine på gives the wrong result not base-10
Autocompletion gives the values to use log, log10, log1p, log2 I have only tried log and log10 and log works log10 doesn’t.
My old rule from DSL works fine:
var tempno = (hueSensorIlluminanceOut.state as Number).doubleValue
var luxnumber = ((Math::log10(tempno) * 10000) + 1)
//Adjusting luxcalculation to be within IHC accept level of 0-60000 Lux
if(luxnumber < 0) {
luxnumber=0;
}
if(luxnumber > 60000) {
luxnumber=60000;
}
IHC_Lux_Ude_HUE.postUpdate(luxnumber)
Any body got some experience or ideas on this?
Thanks for OH it is truly fantastic and a great forum.
Regards Jesper