[NEEDS UPDATING] Party Mode to the MAX

Hello All,

This is probably my first major post on this form. I did this project about a year ago, but recently I felt like sharing this with the online community.

I wanted a party mode in my home, more than just looping light colors or anything of the sort. I wanted an actual orchestrated “light show” in my house. Like you would have if you connected a $1000 DMX light board to a bunch of DMX controlled lights.

I knew I wanted to pre-program light events. But there was no way I was going to write events, line by line, in code for each “light show”. Because of my background in Music production, I thought MIDI files would fit the bill perfectly. Light on events are if the note is pressed, Light off when the note is let go, and CC events to control color/fade speed etc. If you match the BPM of a song to the time signature of a Midi track, you can easily click in your light events in your favorite DAW (I use Cubase but there certainly are free options).

At first, I wanted this to all run in the cloud. There would be no latency concerns and it would all run in its own container, but I quickly found out you can’t just load any Java library into a SmartApp, so that was a quick end to that route. I ended up just writing a local application (running on my server) that calls out to my SmartApp to actually control devices. The latency usually is not a big deal, sometimes it gets slow but normally it’s a pretty static delay (which is compensated in the exe), and I haven’t hit any rate limiting issues yet.

The code took me a while to write and to debug. I don’t know how much time I put into it. I was between jobs, so the concept of time was just a blur anyway. Its written as a C# .NET console application. When the application loads it reads a midi file and all its events, then it starts a ton of threads for each event (grouping events that occur at the same time to the same thread) with a delay of when it should fire. I wanted to include it in the API I wrote, but ServiceStack was fighting me on disposing the threads prematurely, I can’t remember the details. I ended up to just have SmartThings call my API, which then starts (and stops if needed) this EXE, gross. I’m sure this can be done a smarter way, but frankly, I don’t care. I spent enough time on this and it hasn’t stopped working in the year I built it.

I think I’ve rambled on enough, and im sure no one will read it, so here is the high level order of operations:

  • I pull a fire alarm in my house, this fire alarm is connected to an input on a NodeMCU chip with
    @heythisisnate Konnected Firmware
  • My SmartApp sees this change, and sends an API call to my server to start partymode.exe with the arguments for the midi track to play. Partymode.exe calls out to Cast-Web to start the music at the start of the app
  • The midi file queues a bunch of threads that run with specific delay. As the song plays, those threads run, and based on the event from the midi file, will trigger specific lights to turn on/off/colorchange

Really, that’s about it. Writing the light MIDI files is a curve and sucks sometimes, but I found a groove. And it definitely beats writing line by line. I suppose writing some sort of custom midi editor would work better than a DAW. You would definitely have to change the code in the EXE for your own home and I bet my code looks like spaghetti noodles, so good-luck… I don’t have any code ready to post, it’s probably messy since I just kind of got it working and never went back to clean it up. If people want to see it, I can go through the code and clean it up and commit it to my GitHub repo.

Here is a video of it in operation, it loops through a setlist of songs/midi files. I didn’t cover that anywhere in this post, if you can understand how I made this work, looping through songs should be a cake walk.


Fun project, I did something simular with Core, LIFX bulbs, an old jail broken iPhone auto touch app (cydia) and the LIFX music visualizer. Basically i have a switch that when turns on, core sends a http command to auto touch on the iPhone to turn on the LIFX music vis… then all my LIFX bulbs pulse and change color to the sounds of the music in the room.
To max it out i added an android tv device w/ tasker and sharptools to start up projectm on my tv.
It’s always good to find another kindred spirit :wink:


I definitely would like hear more about this project

This is awesome!

That is really cool. Nice job.