Issue of the topic: I’m looking how to passthrough all the values that aren’t mapped, for e.g 1=ON, the state will be ON, however if the value is 5 then the state would just be 5
Please post configurations (if applicable):
1023=ON
1023.0=ON
0.0=OFF
0=OFF
If logs where generated please post these here using code fences:
2019-02-06 17:01:42.201 [WARN ] [rm.AbstractFileTransformationService] - Could not transform '961.62' with the file 'pwmswitch.map' : Target value not found in map for '961.62'
2019-02-06 17:01:42.203 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'RGB_W2SW'
Only solution I see is to change the Item to be a String item and do the mapping within a rule.
String Item cause you want to have ON and OFF schown as well.
Thanks to @rossko57 , for getting me on the right path. The code below ended up working fine using the JS Transformation.
(function(i) {
if(i==1023 || i==1023.0) {
var state = "ON";
} else if (i==0 || i==0.0){
var state = "OFF";
} else {
var state = "NULL";
}
return state;
})(input)
Like the man says, that’s not the pass through you asked for. A default in MAP would do the same as your script.
0=OFF
0.0=OFF
1023=ON
1023.0=ON
=UNDEF
I would use UNDEF rather than NULL because they have slightly different meanings in openHAB
NULL = hasn’t been set up yet
UNDEF = something wrong or unexpected
(function(i) {
var state = ""
var value = parseInt(i)
if(value == 1023) {
state = "ON";
} else if (value == 0){
state = "OFF";
} else {
state = value.toString;
}
return state;
})(input)