Transformation from evaluated number to switch

I am trying to create a switch for alert to create a Alert badge in location UI if temperature goes under 15 degres with profile transform:js

Switch                BedRoom_Sensor_TempWarn           "Temperatur Varning"                    <temperature>    (geBedRoom_Sensor, gpC)                              ["Alarm"]                         {channel="rfxcom:temperaturehumidity:usb0:42752:temperature"  [profile="transform:JS", function="warnTemp.js"]}


(function(inputData) {
    var out = inputData ;      // allow Undefined to pass through
    if (inputData < 15  || inputData > 25) {
        out = 'ON' ;
    } else  {
        out = 'OFF' ;
    return out ;      // return a string

but i get this error:

2021-01-27 20:51:26.902 [WARN ] [e.internal.SseItemStatesEventBuilder] - Exception while formatting value 'OFF' of item BedRoom_Sensor_TempWarn with format '%.1f °C': f != java.lang.String

what am i doing wrong?

I think you’ve run into a version of this bug. The channel has a default (numeric) format option, and is trying to apply that to the transform’s (string) output.

Thanks to add [%s] in description seems to solve the problem :slight_smile:

That’s weird, really :slight_smile: