Turned out the Hue-Binding couldn’t find deCONZ when it was on a non-standard port.
Ended up using the http binding:
Here are the tested files:
http.cfg
# deCONZ Cube Pink1 side/gestures sensor 2
MiCubePink1GestureCache.url=http://127.0.0.1:8090/api/0365EEAA94/sensors/2
MiCubePink1GestureCache.updateInterval=500
# deCONZ Cube Pink1 rotation sensor 3
MiCubePink1RotationCache.url=http://127.0.0.1:8090/api/0365EEAA94/sensors/3
MiCubePink1RotationCache.updateInterval=500
mi.items
String Pink1CubeButtonLastUpdated { http="<[MiCubePink1GestureCache:500:JSONPATH($.state.lastupdated)]" }
Number Pink1CubeButtonEvent { http="<[MiCubePink1GestureCache:500:JSONPATH($.state.buttonevent)]" }
String Pink1CubeRotAngleLastUpdated { http="<[MiCubePink1RotationCache:500:JSONPATH($.state.lastupdated)]" }
Number Pink1CubeRotAngleEvent { http="<[MiCubePink1RotationCache:500:JSONPATH($.state.buttonevent)]" }
mi.rules
rule "Xiaomi Cube action"
when
Item Pink1CubeButtonLastUpdated changed
then
Thread::sleep(20)
var actionName = Pink1CubeButtonEvent.state
var name = "Cube P1"
logInfo(name, "Event: " + actionName)
end
rule "Xiaomi Cube angle"
when
Item Pink1CubeRotAngleLastUpdated changed
then
var Cstate = Pink1CubeRotAngleEvent.state
var name = "Cube P1"
logInfo(name, "Rotation: " + Cstate)
end
log example
2018-06-09 20:47:28.996 [INFO ] [lipse.smarthome.model.script.Cube P1] - Event: 6000
2018-06-09 20:50:16.084 [INFO ] [lipse.smarthome.model.script.Cube P1] - Event: 7000
2018-06-09 20:50:17.087 [INFO ] [lipse.smarthome.model.script.Cube P1] - Event: 5006
2018-06-09 20:50:19.084 [INFO ] [lipse.smarthome.model.script.Cube P1] - Rotation: 9020
The big upside to using this approach instead of the Xiaomi Gateway & Binding, is that deCONZ reports which side is facing up when flipped, tapped or moved. It also reports what side was facing up before the flip.
deCONZ has 2 outstanding issues: (due in beta .29)
Issue 1
Issue 2
Also note the Thread:sleep(10) needed to ensure buttonevent had the latest value after lastupdated changes.
Have asked doCONZ about this.