Hi @ssalonen I started to get the following warn when using transformation invertstate script that you’ve provided here
Previously it was working properly, any hints?
2019-01-20 21:28:12.442 [WARN ] [ernal.handler.ModbusDataThingHandler] - Channel switch will not be updated since transformation was unsuccessful. Channel is expecting the following data types [OnOffType, UnDefType]. Input data: number value 0 (value type 'bit' taken into account) and bool value false. Transformation: Transformation@15699a[tranformation=JS(invertstate.js),transformationServiceName=JS,transformationServiceParam=invertstate.js]
invertstate.js
// function to invert Modbus binary states
// variable "input" contains data passed by OpenHAB binding
(function(inputData) {
var out = inputData ; // allow Undefined to pass through
if (inputData == '1' || inputData == 'ON' || inputData == 'OPEN') {
out = '0' ;
} else if (inputData == '0' || inputData == 'OFF' || inputData == 'CLOSED') {
out = '1' ;
}
return out ; // return a string
})(input)
Sorry, I don’t get what you’re talking about. What is wrong with the current configuration and js? Why did it stop working?
Do you mean this?
// function to invert Modbus binary states
// variable "input" contains data passed by OpenHAB binding
(function(inputData) {
var out = inputData ; // allow Undefined to pass through
if (inputData == '1' || inputData == 'ON' || inputData == 'OPEN') {
out = 'OFF' ;
} else if (inputData == '0' || inputData == 'OFF' || inputData == 'CLOSED') {
out = 'ON' ;
}
return out ; // return a string
})(input)