Deconz, Xiaomi Cube and Value_template in automation triggers?

Here you go. Fun with the cube and a room with hue lights.

[{"id":"1ed7c46a.e8b7cc","type":"tab","label":"Fun with cube","disabled":false,"info":""},{"id":"9c46a766.e8da08","type":"server-events","z":"1ed7c46a.e8b7cc","name":"Zigbee Events","server":"ec85cd17.af94a","event_type":"deconz_event","x":70,"y":40,"wires":[["de7fc94d.a22428","ac2c747e.33e9e8"]]},{"id":"5a412700.5c88c8","type":"function","z":"1ed7c46a.e8b7cc","name":"pass massaged event number","func":"var test;\nvar duration;\n\ntest = msg.payload.event.event;\n\nif (test - parseInt(test / 1000) * 1000 === 0){\n    return [null,null];\n}\n\nif (test - parseInt(test / 1000) * 1000 === parseInt(test / 1000)){\n    if (parseInt(test / 1000) <= 3)\n      {duration = \"short\"}\n    else\n      {duration = \"long\"}\n    msg.payload = duration;\n    return [null,msg];\n}\n\nmsg.payload = [\"0.\" + parseInt(test / 701) ,\"0.\" + (test - (parseInt(test / 1000) * 1000))] ;\n\nreturn [msg,null];","outputs":2,"noerr":0,"x":490,"y":120,"wires":[["4da588ef.624b18"],["98df851a.f55b78"]],"info":"The cube event is a 4 digit number in the form x00y.\nx is the face number moved from and y is the face number moved to.\n\nSo I dismantle that into 0.x,0.y and use it in xy_color of a light.\n\nFiddle with the cube and the light changes colour.\n\nShake the cube is 7007.\n\nignore pushes and wake up, too easy to happen\nthese are n000 where n is face number and n=7 is wake up\n\nIf it was a tap not a turn or roll, eg 1001 is aqara face tap\nsee if we can flash the lights\n"},{"id":"de7fc94d.a22428","type":"switch","z":"1ed7c46a.e8b7cc","name":"Only Cube","property":"payload.event.id","propertyType":"msg","rules":[{"t":"eq","v":"cube","vt":"str"},{"t":"eq","v":"","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":250,"y":40,"wires":[["5a412700.5c88c8"],[]]},{"id":"4da588ef.624b18","type":"api-call-service","z":"1ed7c46a.e8b7cc","name":"Tip - Colour change","server":"ec85cd17.af94a","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.lounge","data":"{\"xy_color\":msg.payload}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":810,"y":100,"wires":[[]]},{"id":"ac2c747e.33e9e8","type":"switch","z":"1ed7c46a.e8b7cc","name":"Cube Rotation","property":"payload.event.id","propertyType":"msg","rules":[{"t":"eq","v":"switch_7","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":240,"y":160,"wires":[["d94b80be.23af7"]]},{"id":"d94b80be.23af7","type":"function","z":"1ed7c46a.e8b7cc","name":"Rotated clock or anti-clock","func":"var test;\nvar res;\ntest = msg.payload.event.event;\nres = parseInt((parseInt(test/100)+(40*Math.sign(test)))/90);\nmsg.payload = res;\nif (res<=-1){\n    return [msg,null,null];\n}    \nif (res===0){\n    return [null,msg,null];\n}\nif (res>=1){\n    return [null,null,msg];\n}","outputs":3,"noerr":0,"x":480,"y":280,"wires":[["adae00f2.83856"],[],["9155d3e9.feefd"]]},{"id":"9155d3e9.feefd","type":"api-call-service","z":"1ed7c46a.e8b7cc","name":"Lights On","server":"ec85cd17.af94a","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.lounge","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":780,"y":320,"wires":[[]]},{"id":"adae00f2.83856","type":"api-call-service","z":"1ed7c46a.e8b7cc","name":"Lights Off","server":"ec85cd17.af94a","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.lounge","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":780,"y":260,"wires":[[]]},{"id":"98df851a.f55b78","type":"api-call-service","z":"1ed7c46a.e8b7cc","name":"Double Tap - Flash","server":"ec85cd17.af94a","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.lounge","data":"{\"flash\":msg.payload}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":810,"y":180,"wires":[[]]},{"id":"ec85cd17.af94a","type":"server","z":"","name":"Home Assistant"}]

seems like a lot of int parsing going on :-p
I’m working on a nodered script to parse the raw deconz events into a few mqtt sensors (rotate, flip, move, tap, shake) for further automation.

Once that’s done, I intend to have this thing control the home theater, so we won’t need any remotes anymore. Each side will select a different input on the TV (netflix, disney+, PC) and rotating will call volume up / volume down. moving left / right controls left and right button on the remove, tap and double tap for confirm / cancel.
One of the sides will power everything off, but you don’t want that to happen accidentally, so maybe power on / off events are only allowed for a minute after a shake event. this seems a nice way to wake up the system :smiley:

TLDR thanks to OP for parsing the event codes.:heart: