I followed everything in this thread and seem to have this working except how do I add my motion sensors to OH2 Things to use them? I’m going to have at least 5 or more motion sensors.
I want to get the time of the last motion in the room. So I stored a new script called getHueMotionLU.js to the transformations:
(function(i) {
var json = JSON.parse(i);
return ((json['state']['lastupdated'])) ;
})(input)
It works but unfortunately the time zone (Berlin) is not set in the motion sensor so I have to add one hour. But how to do? Can anybody give me a hint?
When following the above procedure, I end up with this error… Now what? (sorry for the line breake, I dont know how to fix that).
2018-01-24 23:49:25.799 [ERROR] [ab.binding.http.internal.HttpBinding] - Transformation ‘JS(getHueMotionEvent.js)’ threw an exception. [response=[{“error”:{“type”:4,“address”:"/12",“description”:“method, GET, not available for resource, /12”}}]]
org.openhab.core.transform.TransformationException: An error occurred while executing script.
at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:62)[182:org.openhab.core.compat1x:2.1.0]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:189)[219:org.openhab.binding.http:1.10.0]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:157)[182:org.openhab.core.compat1x:2.1.0]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169)[182:org.openhab.core.compat1x:2.1.0]
2018-01-24 23:49:28.921 [ERROR] [ab.binding.http.internal.HttpBinding] - Transformation ‘JS(getHueMotionEvent.js)’ threw an exception. [response=[{“error”:{“type”:4,“address”:"/12",“description”:“method, GET, not available for resource, /12”}}]]
org.openhab.core.transform.TransformationException: An error occurred while executing script.
at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:62)[182:org.openhab.core.compat1x:2.1.0]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:189)[219:org.openhab.binding.http:1.10.0]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:157)[182:org.openhab.core.compat1x:2.1.0]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169)[182:org.openhab.core.compat1x:2.1.0]
2018-01-25 23:03:37.758 [INFO ] [b.core.service.AbstractActiveService] - HTTP Refresh Service has been started
2018-01-25 23:03:37.877 [ERROR] [ab.binding.http.internal.HttpBinding] - Transformation 'JS(getHueMotionEvent.js)' threw an exception. [response=[{"error":{"type":4,"address":"/12","description":"method, GET, not available for resource, /12"}}]]
org.openhab.core.transform.TransformationException: An error occurred while executing script.
at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:62)[182:org.openhab.core.compat1x:2.1.0]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:189)[219:org.openhab.binding.http:1.10.0]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:157)[182:org.openhab.core.compat1x:2.1.0]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169)[182:org.openhab.core.compat1x:2.1.0]
Hope it reads better now.
A short notice… Seems like the problem only regards for ID 12, the motion sensor. Temperatur does seem to work, though it doesn´t report often.
Hi Christoph…
How does the above round the output of a temperature in the items file ?
I have several (no Philips Hue) temperature sensors, and all of the reporting needs rouding. But I fail to understand how to do this in the item file using your example.
This is one of my temperature sensors:
Number koekken_Temperature "Temperature [%.1f °C]" <cu_heating> ["TargetTemperature"] {ihc="11011604"}
It results in outputting ie 20.08 degreese. I sure would like 20.9 indsted
The item itself contains the original value. Only the display value is rounded in this example to one decimal. You can adjust that by changing the %.1f to a different value. The 1 indicates the number if decimals. If you need to have rounded values in your item you have to use the first or second way.
Actually I could live with a not rounded value. But only one decimal.
Hmm, if the 1 indicates the number of decimals then something is wrong, as I get two decimals from all my temperature sensors. And the items is defined like showen above, [%.1f °C]