Project Busylight Part 2 - Nodejs Code

The adventure continues. This fun little project now has some Javascript running on nodejs and seems to function pretty flawlessly.

I now have four different presence states based on feedback from the Room Kit:
  1. Flashing Red - Do not disturb
  2. Red - On a Call
  3. Blue - Room occupied based on people count
  4. Green - available and empty
The expansion of different presence states was pretty easy. I incorporated people count, do not disturb and the call API's. Do not disturb is a little hard to find on a Cisco Touch 10 so my advice is if you want users to actually use DnD or know its available build a custom UI widget for it. This can be used to toggle DnD via a Macro.

The project was a little larger than expected so I created a github repository to get access to code if your interested.

The design is pretty simple. The bl and endpoint files create class's for what you would think they are. The most interesting part of this project was creating a way to prioritise each presence state. What I created is based on the array index of a 4 element array [0,0,0,1]. Each presence state matches the following positions in the array:
  • Flashing Red (DnD) - 0
  • Red (in call) - 1
  • Blue (people present) - 2
  • Green (room is vacant) - 3
As the presence state changes so does the array. [1,0,1,1] means the room has been set to do not disturb and there are people in the room. The busylight shows a flashing red because it has the highest priority. The final element is alway left at 1 because it has the lowest priority default and it's not worth the effort to change. The "let indexColor = colorArray.indexOf(1);" looks up the first element in the array that has been set to 1 dictating what color to set the light.

Next step lets get it running on a Raspberry PI.


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.