How do you add the hue motion sensor too OH (SOLVED)


(Aaron) #1

im thinking about adding my Hue Motion Sensor to OH im mainly interested in the temp readings but might aswell have ago at just adding it all

all help appreciated i haven’t got a clue all links , help ,chat

whats the basic process

i have not created any item files or sitemaps yet im still new too this so as much detail as possible

TIA


Philips Hue Motion Sensor
(Christoph Weitkamp) #2

Hi Aaron,

Have a look over there


(Aaron) #3

thanks for the link i have followed it to the best of my ability, im unsure what any of the files do im getting this error now

19:36:28.132 [ERROR] [ab.binding.http.internal.HttpBinding] - Transformation 'JS(getHueMotionEvent.js)' threw an exception. [response=[{"error":{"type":3,"address":"/sensors/3","description":"resource, /sensors/3, not available"}}]]
org.openhab.core.transform.TransformationException: An error occurred while executing script.
        at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:62)[190: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)[190:org.openhab.core.compat1x:2.1.0]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169)[190:org.openhab.core.compat1x:2.1.0]

(Christoph Weitkamp) #4

You first have to check if the ID 3 is the correct one for your sensor. This differs in every setup. How it works see Philips Hue Motion Sensor OpenHAB2.


(Aaron) #5

thanks i will have alook through there


(Aaron) #6

Thanks for that i have managed too add both of my sensors now both the Motion and Temps are added im now receiving a different error

posted in this thread

the error is

22:29:00.255 [ERROR] [ab.binding.http.internal.HttpBinding] - Transformation 'JS(getHueDark.js)' threw an exception. [response={"state":{"daylight":null,"lastupdated":"none"},"config":{"on":true,"configured":false,"sunriseoffset":30,"sunsetoffset":-30},"name":"Daylight","type":"Daylight","modelid":"PHDL00","manufacturername":"Philips","swversion":"1.0"}]
org.openhab.core.transform.TransformationException: An error occurred while loading script.
        at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:62)[190: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)[190:org.openhab.core.compat1x:2.1.0]
        at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169)[190:org.openhab.core.compat1x:2.1.0]

I think its because i only have the two scripts from a different post no script called JS(getHueDark.js) any ideas


(Christoph Weitkamp) #7

Yes, that’s exactly what the error message tells you. I suggest to create the getHueDark.js script in your transform/ folder and put the desired logic inside.


(Christoph Weitkamp) #8

(Reto Stauffacher) #9

Hi there

I got the same error but i cant get it working. The errors are on every Sensor idlike to get. i already checked if the Sensors (2/3/4) are working and matching my programming. Aswell i can access the Sensor with my Userpass and the IP provided. What am i missing?
I followed the tutorial and rechecked it twice now.

Binding configuration of type ‘http’ of item ‘GF_Stairwell_HueTemp’ could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: bindingConfig ‘http://192.168.20.166/api/qW8YTbOAFY********************BHe-rRjof/sensors/2:30000:JS(getHueTemperature.js)]’ doesn’t contain a valid binding configuration
at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:51) [211:org.openhab.core.compat1x:2.2.0]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:341) [135:org.eclipse.smarthome.model.item:0.10.0.b1]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.dispatchBindingsPerType(GenericItemProvider.java:294) [135:org.eclipse.smarthome.model.item:0.10.0.b1]
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.addBindingConfigReader(GenericItemProvider.java:131) [135:org.eclipse.smarthome.model.item:0.10.0.b1]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:229) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:650) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:506) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.inject.BindMethod.invoke(BindMethod.java:658) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1722) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1699) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:372) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:320) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:291) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:127) [42:org.apache.felix.scr:2.0.12]
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) [?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:915) [?:?]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?]
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) [?:?]
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) [?:?]
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) [?:?]
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) [?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464) [?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:482) [?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:999) [?:?]
at org.openhab.core.binding.internal.BindingConfigReaderFactory.registerDelegateService(BindingConfigReaderFactory.java:70) [211:org.openhab.core.compat1x:2.2.0]
at org.openhab.core.binding.internal.BindingConfigReaderFactory.activate(BindingConfigReaderFactory.java:38) [211:org.openhab.core.compat1x:2.2.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:229) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:650) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:506) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:307) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:299) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:298) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:109) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:906) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:879) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:749) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:675) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:430) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:657) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:341) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:390) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.Activator.access$200(Activator.java:54) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:265) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:254) [42:org.apache.felix.scr:2.0.12]
at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:227) [42:org.apache.felix.scr:2.0.12]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) [?:?]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) [?:?]
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) [?:?]
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) [?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:903) [?:?]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) [?:?]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) [?:?]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) [?:?]
at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:156) [?:?]
at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) [?:?]
at org.eclipse.osgi.container.Module.start(Module.java:467) [?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1620) [?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1600) [?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1571) [?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1514) [?:?]
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]
2018-04-02 12:19:37.011 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type ‘http’ of item ‘GF_Stairwell_HueMotion’ could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: bindingConfig


(Christoph Weitkamp) #10

Hi Reto,

did you install all needed bundles? E.g. the HTTP binding and the JavaScript transformation?


(Reto Stauffacher) #11

Hi Christoph

Yeah. HTTP Binding and JavaScript Trans is installed. JSON aswell.

Could it be a problem, that the HUE Bridge was discovered automaticly without any “Item” Binding? As i Said username with link works. Bulbs working perfectly but the Sensor is a pain :frowning:


(Christoph Weitkamp) #12

Ok, can you please post your complete item and service configuration (*.items and http.cfg files)?


(Reto Stauffacher) #13

Number GF_Stairwell_HueTemp “Temperatur Sensor [%.2f °C]” { http=“http://192.168.20.166/api/qW8#######1PPwSRtECbidbxBHe-rRjof/sensors/2:30000:JS(getHueTemperature.js)]” }

Switch GF_Stairwell_HueMotion “Bewegungssensor [MAP(home.map):%s]” { http=“http://192.168.20.166/api/qW8Y#########OlMZdz1PPwSRtECbidbxBHe-rRjof/sensors/3:30000:JS(getHueMotion.js)]” }

Number GF_Stairwell_MotionLight “Lichtstärke [%.0f]” { http=“http://192.168.20.166/api/qW8YTb#######dz1PPwSRtECbidbxBHe-rRjof/sensors/4:30000:JS(getHueLight.js)]” }

Number GF_Stairwell_HueBattery “Batterie [%.0f %%]” { http=“http://192.168.20.166/api/qW8Y##############wSRtECbidbxBHe-rRjof/sensors/5:30000:JS(getHueBattery.js)]” }

Battery:
(function(i) {
var json = JSON.parse(i);
return parseInt(json[“config”][“battery”]);
})(input)

light:
(function(i) {
var json = JSON.parse(i);
return Math.pow(10, (parseInt(json[“state”][“lightlevel”]) - 1) / 10000);
})(input)

Motion:
(function(i) {
var json = JSON.parse(i);
return (json[“state”][“dark”]) == true ? “ON” : “OFF”;
})(input)

Temperature:
(function(i) {
var json = JSON.parse(i);
return parseFloat(json[“state”][“temperature”]) / 100;
})(input)

http.cfg is empty.


(Christoph Weitkamp) #14

There is a closing bracket at the end of each item - directly after the JS part - which doesn’t belong there. Please remove them.

Number GF_Stairwell_HueTemp “Temperatur Sensor [%.2f °C]” { http=“http://192.168.20.166/api/qW8#######1PPwSRtECbidbxBHe-rRjof/sensors/2:30000:JS(getHueTemperature.js)” }

May I ask you to use code fences the next time? To provide better readability.


(Reto Stauffacher) #15

Thanks for the help
I just restartet the Openhab Server but sadly, i got still the same errors.
Sorry about the code.
It still cant parse

2018-04-02 17:30:12.791 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation 'JS(getHueLastChange.js)' threw an exception. [response={"state":{"temperature":1687,"lastupdated":"2018-04-02T15:29:41"},"swupdate":{"state":"noupdates","lastinstall":null},"config":{"on":true,"battery":100,"reachable":true,"alert":"none","ledindication":false,"usertest":false,"pending":[]},"name":"Hue temperature sensor 1","type":"ZLLTemperature","modelid":"SML001","manufacturername":"Philips","productname":"Hue temperature sensor","swversion":"6.1.0.18912","uniqueid":"00:17:88:01:03:28:82:92-02-0402","capabilities":{"certified":true}}]
org.openhab.core.transform.TransformationException: An error occurred while loading script.
	at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:67) [211:org.openhab.core.compat1x:2.2.0]
	at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:194) [219:org.openhab.binding.http:1.11.0]
	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:144) [211:org.openhab.core.compat1x:2.2.0]
	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:166) [211:org.openhab.core.compat1x:2.2.0]
2018-04-02 17:30:13.812 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation 'JS(getHueLastChange.js)' threw an exception. [response={"state":{"temperature":1687,"lastupdated":"2018-04-02T15:29:41"},"swupdate":{"state":"noupdates","lastinstall":null},"config":{"on":true,"battery":100,"reachable":true,"alert":"none","ledindication":false,"usertest":false,"pending":[]},"name":"Hue temperature sensor 1","type":"ZLLTemperature","modelid":"SML001","manufacturername":"Philips","productname":"Hue temperature sensor","swversion":"6.1.0.18912","uniqueid":"00:17:88:01:03:28:82:92-02-0402","capabilities":{"certified":true}}]
org.openhab.core.transform.TransformationException: 

Thats what i get when i run your script with the config seperated in http.cfg and items

Edit
fuck its working. I guess the warning/error is because there wasnt any “past Temperature”


(Reto Stauffacher) #16

Hey there again. Everything still working.

One more question. I had to reset the Hue Bridge coz 1 buld wouldnt get recognized after i deleted it (not a Hue Bulb)
And after the Reset i added 4 Sensors.

Can anyone tell me how i do know, wich Temperature Sensor belongs to wich Motion Sensor? The Problem is, only on one Sensor (number) the name of the Motion Sensor is written down. All others are kinda the same.

Can i just take the Sensor Numbers bevore and after the Named Sensor and hope for the best or is there a way to figgure this out?

EDIT

If someone faces the same Problem.
Just deactivate all Motion Sensor beside 1! Then you can check the Sensor Page of the HUB and you will have “Null” Values at the deactivated Motion Sensor and some Real values on the Active one!

Cheers