Hey guys,
Following the method @vzorglub is mentioning above I stumbled into a problem and I would really appreciate any advice you have to offer.
The JS transformation solution is working fine, but after adding a second JS transformation file along with the proper channel and items, I get this warning even though everything is still working fine:
[WARN ] [eneric.internal.generic.ChannelState] - Command ‘317F0A’ not supported by type ‘OpenCloseValue’: No enum constant org.eclipse.smarthome.core.library.types.OpenClosedType.317F0A
After some digging, I discovered what is causing the error !
Every RF code received by the RF Bridge is being forwarded for every single channel (things file) to all the JS transformation files (as many as the physical contacts).
The warning occurs because each transformation file includes only 2 RF codes (open/closed) for a specific device. So any unknown RF code to that specific JS transformation file is not transforming and remains a string (eg. ‘F2670E’) which gives the warning message.
I’m really struggling to find a solution for some time now, but so far no luck…
This is my setup:
home.items
Contact LivingRoom_Window "Living Room Window [%s]" <window> (gLivingRoom, gWindow, MagicMirror) [ "ContactSensor" ] { channel="mqtt:topic:mosquitto:rf_bridge:livingroomwindow" }
Contact Office_Window "Office Window [%s]" <window> (gOffice, gWindow, gMagicMirror) [ "ContactSensor" ] { channel="mqtt:topic:mosquitto:rf_bridge:officewindow" }
home.things
Type contact:livingroomwindow "Living Room Window" [ stateTopic="tele/rf_bridge/RESULT", transformationPattern="JS:livingroom_window.js" ]
Type contact:officewindow "Office Window" [ stateTopic="tele/rf_bridge/RESULT", transformationPattern="JS:office_window.js" ]
livingroom_window.js
(function(jsonString) {
var data = JSON.parse(jsonString);
var window = data.RfReceived.Data;
if (window === null) window = UNDEF;
if (window == '317F0A') window = 'OPEN';
if (window == '317F0E') window = 'CLOSED';
return window;
})(input)
officewindow_window.js
(function(jsonString) {
var data = JSON.parse(jsonString);
var window = data.RfReceived.Data;
if (window === null) window = UNDEF;
if (window == '31910A') window = 'OPEN';
if (window == '31910E') window = 'CLOSED';
return window;
})(input)
In my case, RF Code ‘317F0A’ is not included in “officewindow.js” (but only in “livingroom_window.js”) and that returns the string and not a stare which is causing the warning.
Any help would be appreciated
Thank you in advance !