Kodi and MiLight integration

Description

This is a simple integration to show NodeRed controlling MiLight based lights (e.g. LimitLess Led) based on Kodi Websocket announcements.

More work is required to prevent race conditions and add fading etc.

Actions

  • Lights turn on when the screensaver is deactivated or a video is paused/stopped.
  • Lights turn off when a video starts playing or the screensaver activates.

Setup

  • Install https://github.com/Daniel-t/node-red-contrib-milight
  • Update the 'Kodi' Websocket node to point at your Kodi (XBMC) computer. ** Note: you need to enable WebSockets in Kodi by enabling both TCP control and control from other computers
  • Update the 'MiLight White' and 'MiLight Power' nodes with your zone number and optionally the IP address of your MiLight bridge.
[{"id":"f97d55c1.0682a8","type":"websocket-client","z":"58fb4b3d.a704b4","path":"ws://192.168.0.97:9090/jsonrpc","wholemsg":"false"},{"id":"821a56b.f7de5a8","type":"websocket in","z":"58fb4b3d.a704b4","name":"Kodi","server":"","client":"f97d55c1.0682a8","x":91,"y":50,"wires":[["94c56758.6b3a98"]]},{"id":"9ca93354.6356d","type":"debug","z":"58fb4b3d.a704b4","name":"logs","active":true,"console":"false","complete":"true","x":583,"y":66,"wires":[]},{"id":"88daaac4.772558","type":"switch","z":"58fb4b3d.a704b4","name":"","property":"payload.method","rules":[{"t":"eq","v":"Player.OnPlay"},{"t":"eq","v":"Player.OnPause"},{"t":"eq","v":"Player.OnStop"},{"t":"eq","v":"GUI.OnScreensaverActivated"},{"t":"eq","v":"GUI.OnScreensaverDeactivated"}],"checkall":"false","outputs":5,"x":230.99999237060547,"y":232.99999046325684,"wires":[["229c187e.dd63e8"],["87b6d804.784928"],["87b6d804.784928"],["451d2e98.bae2d"],["af74cda4.508b3"]]},{"id":"94c56758.6b3a98","type":"json","z":"58fb4b3d.a704b4","name":"","x":256,"y":51,"wires":[["88daaac4.772558","9ca93354.6356d"]]},{"id":"a6160a3e.59e9f8","type":"MiLightPower","z":"58fb4b3d.a704b4","name":"MiLight Power","zone":1,"ip":"255.255.255.255","broadcast":true,"x":1247.0000305175781,"y":866.6666479110718,"wires":[]},{"id":"a61743ce.59e8c","type":"MiLightWhite","z":"58fb4b3d.a704b4","name":"MiLight White","zone":1,"ip":"255.255.255.255","broadcast":true,"x":1266.6666412353516,"y":459.0000190734863,"wires":[]},{"id":"d593b545.2a6c48","type":"template","z":"58fb4b3d.a704b4","name":"on","field":"payload","format":"handlebars","template":"on","x":1095.0000305175781,"y":838.6666479110718,"wires":[["a6160a3e.59e9f8"]]},{"id":"24db4f8c.db24b","type":"template","z":"58fb4b3d.a704b4","name":"off","field":"payload","format":"handlebars","template":"off","x":1100.0000305175781,"y":909.6666479110718,"wires":[["a6160a3e.59e9f8"]]},{"id":"764a2806.89b5d8","type":"delay","z":"58fb4b3d.a704b4","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":922.9999313354492,"y":967.6666622161865,"wires":[["24db4f8c.db24b"]]},{"id":"367f5764.c980a8","type":"function","z":"58fb4b3d.a704b4","name":"30","func":"msg.payload=30;\nreturn msg;","outputs":1,"noerr":0,"x":1044.3333129882812,"y":342.6666955947876,"wires":[["a61743ce.59e8c"]]},{"id":"451d2e98.bae2d","type":"function","z":"58fb4b3d.a704b4","name":"Screensaver On","func":"\nreturn msg;","outputs":1,"noerr":0,"x":503.33338165283203,"y":636.333330154419,"wires":[["367f5764.c980a8","764a2806.89b5d8"]]},{"id":"af74cda4.508b3","type":"function","z":"58fb4b3d.a704b4","name":"Screensaver Off","func":"\nreturn msg;","outputs":1,"noerr":0,"x":493.33331298828125,"y":753.3333177566528,"wires":[["d593b545.2a6c48","2edbb28c.d1244e"]]},{"id":"2edbb28c.d1244e","type":"delay","z":"58fb4b3d.a704b4","name":"","pauseType":"delay","timeout":"300","timeoutUnits":"milliseconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":983.3333282470703,"y":475.0000343322754,"wires":[["345f6f6c.cba09"]]},{"id":"345f6f6c.cba09","type":"function","z":"58fb4b3d.a704b4","name":"50","func":"msg.payload=50;\nreturn msg;","outputs":1,"noerr":0,"x":1039.9999465942383,"y":523.3333435058594,"wires":[["a61743ce.59e8c"]]},{"id":"87b6d804.784928","type":"function","z":"58fb4b3d.a704b4","name":"Pause/Stop","func":"\nreturn msg;","outputs":1,"noerr":0,"x":486.6666564941406,"y":504.9999694824219,"wires":[["d593b545.2a6c48","2edbb28c.d1244e"]]},{"id":"229c187e.dd63e8","type":"function","z":"58fb4b3d.a704b4","name":"Play","func":"\nreturn msg;","outputs":1,"noerr":0,"x":483.33331298828125,"y":396.6666564941406,"wires":[["ac5e6589.53a198","367f5764.c980a8"]]},{"id":"ac5e6589.53a198","type":"delay","z":"58fb4b3d.a704b4","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":924.9999389648438,"y":903.3333129882812,"wires":[["24db4f8c.db24b"]]}]
Daniel-t

Flow Info

created 1 year, 4 months ago

Node Types

Core
  • debug (x1)
  • delay (x3)
  • function (x6)
  • json (x1)
  • switch (x1)
  • template (x2)
  • websocket in (x1)
  • websocket-client (x1)
Other
  • MiLightPower (x1)
  • MiLightWhite (x1)

Tags

  • Kodi
  • XMBC
  • MiLight
  • limitlessled
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option