Help with Item/Binding of FreeBox into openHAB

For one of my Vera plugins (Freebox), I am setting a variable with a XML data.

I need in openHAB to set an item taking one information from this XML data. So I need to write a IN transformation file.
Any advice / example how to do that ?
If I do it using JavaScript, do you think I could re-use a big part of my JavaScript code from the Vera plugin UI that loads this XML using window.DOMParser ?
XSLT could be more appropriate in this case ?

[quote=“lolodomo, post:1, topic:185656”]For one of my Vera plugins (Freebox), I am setting a variable with a XML data.

I need in openHAB to set an item taking one information from this XML data. So I need to write a IN transformation file.
Any advice / example how to do that ?
If I do it using JavaScript, do you think I could re-use a big part of my JavaScript code from the Vera plugin UI that loads this XML using window.DOMParser ?
XSLT could be more appropriate in this case ?[/quote]

Your transform will either be of the form:
[tt]…,in:XPATH(/rootNode/next/next2/stuffToExtract),…[/tt] OR;
[tt]…,in:XSLT(yourFile.xsl),…[/tt] OR;
[tt]…,in:JS(yourFile.js),…[/tt]

…depending upon the complexity of the data-extraction. I would guess that running XPath is going to be the easiest for most simple cases, with XSLT and JS just being a preference (and potentially performance, but I’ve never measured their cost)

These are all built into openHAB, but there’s not a lot of documentation to go on. There is this page, but it’s minimalist. The XSLT Transformation has some examples.

NOTE: The fileName forms (XSLT and JS) should work without too much headache, but it’s possible that my Binding parse code could break on more complex XPath expressions… If you try this path, and it breaks, let me know and I’ll tighten up that parsing logic.

[quote=“guessed, post:2, topic:185656”]Your transform will either be of the form:
[tt]…,in:XPATH(/rootNode/next/next2/stuffToExtract),…[/tt] OR;
[tt]…,in:XSLT(yourFile.xsl),…[/tt] OR;
[tt]…,in:JS(yourFile.js),…[/tt]

…depending upon the complexity of the data-extraction. I would guess that running XPath is going to be the easiest for most simple cases, with XSLT and JS just being a preference (and potentially performance, but I’ve never measured their cost)[/quote]

Ok, I tried with XPath after adjusting a little my Vera plugin.

Here is my item definition in openHAB:

String FreeboxTeleviseur "T?l?viseur [%s]" (GVera) {mios="unit:house,device:437/service/urn:freebox-fr:serviceId:Freebox1/PeripheriquesReseau, in:XPATH(/net_devices/device[@mac=\"XX:XX:XX:XX:XX:XX\"])"}

At openHAB, I get this error:

2014-12-23 11:06:06.585 [ERROR] [i.internal.GenericItemProvider] - Binding configuration of type 'mios' of item ?FreeboxTeleviseur? could not be parsed correctly. org.openhab.model.item.binding.BindingConfigParseException: Config for item 'FreeboxTeleviseur' could not be parsed. Bad general format 'unit:house,device:437/service/urn:freebox-fr:serviceId:Freebox1/PeripheriquesReseau, in:XPATH(/net_devices/device[@mac="00:1B:D3:D2:65:02"])'

Any idea ? Is my declaration wrong ?

Edit: I tried with that item definition too but no better result:

String FreeboxTeleviseur "T?l?viseur [%s]" (GVera) {mios="unit:house,device:437/service/urn:freebox-fr:serviceId:Freebox1/PeripheriquesReseau, in:XPATH(/net_devices/device[@mac='XX:XX:XX:XX:XX:XX'])"}

Edit2: fixed by suppressing the space in the mios string 8)

[s]I have done another test using transformation (no XPath in this case) and I got a similar issue. I probably missed something that is obvious for you.

Here is my item definition:[/s]

Switch FreeboxWifi "Wifi [MAP(fr.map):%s]" (GVera) {mios="unit:house,device:437/service/urn:freebox-fr:serviceId:Freebox1/WifiActif,in:MAP(miosBooleanIn.map),command:MAP(miosFreeboxWifiCommand.map)"}

Edit: fixed by reversing in and command in the string.

Switch FreeboxWifi "Wifi [MAP(fr.map):%s]" (GVera) {mios="unit:house,device:437/service/urn:freebox-fr:serviceId:Freebox1/WifiActif,command:MAP(miosFreeboxWifiCommand.map),in:MAP(miosBooleanIn.map)"}

Here is the error at startup:

2014-12-23 13:00:11.853 [ERROR] [i.internal.GenericItemProvider] - Binding configuration of type 'mios' of item ?FreeboxWifi? could not be parsed correctly. org.openhab.model.item.binding.BindingConfigParseException: Config for item 'FreeboxWifi' could not be parsed. Bad general format 'unit:house,device:437/service/urn:freebox-fr:serviceId:Freebox1/WifiActif,in:MAP(miosBooleanIn.map),command:MAP(miosFreeboxWifiCommand.map)'

… yes, my Parsing code is a little touchy… :wink: