Openhab2 item to Artnet for Alexa

If you havent gotten the DMX bindings working for Openhab2 here is a workaround.

For Alexa support you need to have Homekit and myOpenHab.org up and running for normal switched items, like so:

Switch entrylight "Entry Light" ["Lighting"] {mqtt=">[mymqtt:inside/entrylight:command:OFF:0],>[mymqtt:inside/entrylight:command:ON:1]"}

The ["Lighting"] field above tells Alexa how to discover this device and what it can do. Make sure you enable use of the new item in the myopenhab binding.

For the Dimmable light the item is fairly simple:

Dimmer HallwayLight "Hallway Light" ["Lighting"] {mqtt="> mymqtt:inside/hallway:command:*:default]"}

Now the trick is to convert the ON and OFF commands in node-red, as well as translate the dimming percentage to a 0-255 value.

Ive called the function Nightlight as the Hallway Light also has some Bigtimers attached for running at minimum brightness throughout the night.

[{"id":"3165d782.7d9cb8","type":"function","z":"f27227e7.c96118","name":"Nightlight","func":"var NightlightVal= msg.payload;\nmsg.payload = {\n    transition: \"linear\",\n    duration: 2000,\n  buckets: [\n    {channel: 1, value: NightlightVal},\n    ]\n};\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":100,"wires":[["d2c8f000.90afb"]]},{"id":"d2c8f000.90afb","type":"artnet out","z":"f27227e7.c96118","name":"Open DMX Ethernet","address":"192.168.1.35","port":6454,"size":512,"rate":40,"universe":"1","x":950,"y":100,"wires":[]},{"id":"d52f8cb2.6eb3a","type":"mqtt in","z":"f27227e7.c96118","name":"","topic":"inside/hallway","qos":"2","broker":"d8e7508f.58162","x":90,"y":60,"wires":[["c514419d.88649","aa617d1e.4402a","f89e6173.c88ba"]]},{"id":"c514419d.88649","type":"switch","z":"f27227e7.c96118","name":"ON","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"}],"checkall":"true","outputs":1,"x":310,"y":60,"wires":[["668cfc18.f5ef04"]]},{"id":"aa617d1e.4402a","type":"switch","z":"f27227e7.c96118","name":"OFF","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"OFF","vt":"str"}],"checkall":"true","outputs":1,"x":310,"y":100,"wires":[["2a76f3e2.c1358c"]]},{"id":"f89e6173.c88ba","type":"switch","z":"f27227e7.c96118","name":"Percentage","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"0","vt":"num","v2":"100","v2t":"num"}],"checkall":"true","outputs":1,"x":330,"y":140,"wires":[["a5218a01.5d0b38"]]},{"id":"668cfc18.f5ef04","type":"change","z":"f27227e7.c96118","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"255","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":60,"wires":[["3165d782.7d9cb8"]]},{"id":"2a76f3e2.c1358c","type":"change","z":"f27227e7.c96118","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":100,"wires":[["3165d782.7d9cb8"]]},{"id":"a5218a01.5d0b38","type":"function","z":"f27227e7.c96118","name":"","func":"var HallwayDim= msg.payload / 100;\nmsg.payload = 255 * HallwayDim;\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":140,"wires":[["3165d782.7d9cb8"]]},{"id":"d8e7508f.58162","type":"mqtt-broker","z":"","broker":"192.168.1.5","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
sjp770

Flow Info

created 8 months, 1 week ago

Node Types

Core
  • change (x2)
  • function (x2)
  • mqtt in (x1)
  • mqtt-broker (x1)
  • switch (x3)
Other
  • artnet out (x1)

Tags

  • dmx
  • artnet
  • openhab
  • openhab2
  • alexa
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option