Hi everybody, I’m quite new to openhab but realise it got huge potential. I’m trying to import XML data from xml file generatde by Cumulus weather station software files i pasted in below or atleast the most interesting parts, file is located in localhost c:\cumulus\data.xml i really hope someone could help me come up with a solution or just not a solution also giving me som new knowledge. And offcourse did I have to destroy some <tags i order to make pasted file visible.
/<?xml version="1.0" encoding="ISO-8859-1"?>
!–Cumulus WebTag XML Data file - version 1.8–>
weatherdata>
raintags>
item name=“TrrateYM”>
value>00:00/value>
unit>/unit>
image>/image>
class>dynamic/class>
description>Time of Yesterday’s maximum rain rate/description>
There is no file binding that I’m aware of, though I could see how that would be useful. Since you are on Windows I think the easiest thing will be to use the Exec binding and either XSLT or XPath Transformation to extract the value you want.
The following Item will execute a command to echo the contents of data.xml every five minutes and pass that text to trrateym.xsl to extract the value.
String TrrateYM "Time of Yesterday's maximum rain rate [%s]" <rain> {exec="[type c:\\cumulus\\data.xml:300000:XSLT(trrateym.xsl)]"}
Hi thanks for your reply so the string lin will be in item file qnd the rest code will be i transform file? I hope i understood correctly but how do i display thos with sitemap file and call value from rules?
Thanks one more I’ve now put in those things in files but couldnt see any outpu thought i will try to attach complete xml file, One basic question also do I need to install som other binding or import diffrent things in rules file?.data.xml (61.6 KB)
I finally got xsl transformation to work on a web servcie by adding version=“1.0” to xsl:stylesheet tag, but it seems like I have some problem witch execution of string item there’s no event i debug log for this command.
I think that xsl file is correct since I could validate tha code and pull the correct data from xml file. Its just that I dont see any events for execution of script in my logs and i dont get any data. So probably I have some problem with exec binding or item configuration.
My item line looks like this after translation into swedish and changed value to pull from what you supposed, But i can validate regn.xsl file on webservcies to pull correct data from data.xml, if i add < in {exec=<"type… then openhab will atleast do something but I gett an error in Swedish say something like file ended to soon or abrubted something like that. Do i nedd to provide full path to data.xml in regn.xsl?, vaule to shoe will be yesterdays rain in mm to control irrigation.
016-11-20 08:14:50.621 [ERROR] [.i.s.XsltTransformationService] - transformation throws exception
javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Filen har avslutats för tidigt.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source) ~[na:1.8.0_111]
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source) ~[na:1.8.0_111]
at org.openhab.core.transform.internal.service.XsltTransformationService.transform(XsltTransformationService.java:83) ~[na:na]
at org.openhab.binding.exec.internal.ExecBinding.transformResponse(ExecBinding.java:162) [bundlefile:na]
at org.openhab.binding.exec.internal.ExecBinding.execute(ExecBinding.java:136) [bundlefile:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) [org.openhab.core_1.8.3.jar:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) [org.openhab.core_1.8.3.jar:na]
Caused by: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Filen har avslutats för tidigt.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(Unknown Source) ~[na:1.8.0_111]
… 7 common frames omitted
Caused by: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Filen har avslutats för tidigt.
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(Unknown Source) ~[na:1.8.0_111]
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(Unknown Source) ~[na:1.8.0_111]
… 8 common frames omitted
2016-11-20 08:14:50.637 [ERROR] [.o.b.exec.internal.ExecBinding] - transformation throws exception [transformation=XSLT(regn.xsl), response=]
org.openhab.core.transform.TransformationException: transformation throws exception
at org.openhab.core.transform.internal.service.XsltTransformationService.transform(XsltTransformationService.java:86) ~[na:na]
at org.openhab.binding.exec.internal.ExecBinding.transformResponse(ExecBinding.java:162) [bundlefile:na]
at org.openhab.binding.exec.internal.ExecBinding.execute(ExecBinding.java:136) [bundlefile:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) [org.openhab.core_1.8.3.jar:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) [org.openhab.core_1.8.3.jar:na]
Caused by: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Filen har avslutats för tidigt.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source) ~[na:1.8.0_111]
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source) ~[na:1.8.0_111]
at org.openhab.core.transform.internal.service.XsltTransformationService.transform(XsltTransformationService.java:83) ~[na:na]
… 4 common frames omitted
Caused by: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Filen har avslutats för tidigt.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(Unknown Source) ~[na:1.8.0_111]
… 7 common frames omitted
Caused by: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Filen har avslutats för tidigt.
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(Unknown Source) ~[na:1.8.0_111]
at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(Unknown Source) ~[na:1.8.0_111]
… 8 common frames omitted
2016-11-20 08:14:50.855 [WARN ] [o.u.i.items.ItemUIRegistryImpl] - Exception while formatting value ‘’ of item regn with format ‘%.d MM’: java.util.UnknownFormatConversionException: Conversion = ‘.’
Hmm now I’m really lost how do i remove transform?, if i deltede XSLT binfing error could be phrased correctly. Do I have to put somethoing in excec.persits?,
Thanks for another good idea, but I’m not getting there got this strange message, I have had Xpath conersions into another home automation software before (switch king) so source file must be ok.
2016-11-23 06:35:20.308 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule ‘Väderstations temp’: Index: 0, Size: 0
Is there anything else I need to isntall on my cpu or any binding i havent thought of or some script issues. I’ve only installed exec binding and exec persitanace binding maybe need to import som new stuff into rules file?. I follow your earlier advice tp make a aswitch for testing.