Number ArbeitTemp “Arbeitszimmer [%.1f °C]” { http=“<[mobilealerts:60000:JS(getTempArbeit.js)]” }
JS Datei:
(function(i) {
var re = new RegExp('120DF8FF7516[\\s\\S]*?Temperatur[\\s\\S]*?<h4>([0-9]+,[0-9]+) C<\/h4>', 'm');
var out = i.match(re)[1];
return parseFloat(out.replace(',', '.'));
})(input)
After several hours and various attempts to get this to work in OH3 with the new HTTP binding and the GUI, I have to ask here if someone can give me a hint how I can get this to work in OH3.
id: Test
channelTypeUID: http:number
label: Test
description: “”
configuration:
stateTransformation: JS(getTempArbeit.js)
Error in openhab.log:
2020-12-23 16:46:48.122 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.thingUpdated()’ on ‘org.openhab.binding.http.internal.HttpThingHandler@7879c816’: The transformation pattern must consist of the type and the pattern separated by a colon
java.lang.IllegalArgumentException: The transformation pattern must consist of the type and the pattern separated by a colon
at org.openhab.binding.http.internal.transform.CascadedValueTransformationImpl.lambda$1(CascadedValueTransformationImpl.java:38) ~[?:?]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[?:?]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) ~[?:?]
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[?:?]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[?:?]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[?:?]
at org.openhab.binding.http.internal.transform.CascadedValueTransformationImpl.(CascadedValueTransformationImpl.java:39) ~[?:?]
at org.openhab.binding.http.internal.HttpHandlerFactory.getValueTransformation(HttpHandlerFactory.java:107) ~[?:?]
at org.openhab.binding.http.internal.HttpThingHandler.createItemConverter(HttpThingHandler.java:357) ~[?:?]
at org.openhab.binding.http.internal.HttpThingHandler.createGenericItemConverter(HttpThingHandler.java:365) ~[?:?]
at org.openhab.binding.http.internal.HttpThingHandler.createChannel(HttpThingHandler.java:247) ~[?:?]
at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085) ~[?:?]
at org.openhab.binding.http.internal.HttpThingHandler.initialize(HttpThingHandler.java:181) ~[?:?]
at org.openhab.core.thing.binding.BaseThingHandler.thingUpdated(BaseThingHandler.java:152) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:154) [bundleFile:?]
at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
Hi, i run into these problems too, migrating from OH2.5 to OH3
Where do I have to store the transformation JS ? what is the full path to this directory (on a raspberrypi) ?
So if I a have a JS in my openhab 2.5 containing the following code and named badezimmertemp.js
(function(i) {
var re = new RegExp('120DF8FF7516[\\s\\S]*?Temperatur[\\s\\S]*?<h4>([0-9]+,[0-9]+) C<\/h4>', 'm');
var out = i.match(re)[1];
return parseFloat(out.replace(',', '.'));
})(input)
I have to create a channel with channelType ‘NumberChannel’ and in State Transformation i just add JS:badezimmertemp.js
I tried to change the content of State Transformation with
JS:getBuedZemmerTemperature.js. (the js is stored in /etc/openhab/transform/)
and now I get the following errors :
2021-01-11 18:06:52.920 [INFO ] [nding.http.internal.HttpThingHandler] - Using the secure client for thing 'http:url:mobileAlerts'.
2021-01-11 18:06:52.922 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.thingUpdated()' on 'org.openhab.binding.http.internal.HttpThingHandler@2561e5': The transformation pattern must consist of the type and the pattern separated by a colon
java.lang.IllegalArgumentException: The transformation pattern must consist of the type and the pattern separated by a colon
Can any one help me in solving this, I am not a Java programmer, but a simple user.
Basoiically, I want to display the value returned in a dashboard as a temperature
(function(i) {
var re = new RegExp('xxxxxxxxxxx[\\s\\S]*?Temperatur Innen[\\s\\S]*?<h4>([0-9]+.[0-9]+) C');
var out = i.match(re)[1];
return parseFloat(out.replace(',', '.'));
})(input)
Hope this helps some of you who are still struggeling with this in OH3…
I don’t think that battery status is reported to the gateway in Mobile Alerts.
At least I cannot find any such info, neither in the mobile alerts app nor on the web page.
I have allways an error with my rain.
Tis is my getrain.js:
(function(i) {
var re = new RegExp('08112E6CE182[\\s\\S]*?Regen[\\s\\S]*?<h4>([0-9]+.[0-9]+) mm');
var out = i.match(re)[1];
return parseFloat(out.replace(',', '.'));
})(input)
and this is the error at the log:
[.transform.SingleValueTransformation] - Executing transformation ChannelStateTransformation{pattern=‘getrain.js’, serviceName=‘JS’} failed: An error occurred while executing script. TypeError: Cannot get property “1” of null in at line number 3