Sync computer's RGB peripherals via MQTT

I created a little tool to sync the RGB peripherals of my desktop computer with the LED strips in my apartment (which are controlled via openHAB/MQTT).
It subscribes to an MQTT topic from which it extracts colors and passes them on to one (or more) OpenRGB instances. OpenRGB is a neat open source project that grants unified access to proprietary RGB solutions without the necessity of installing the actual vendor tooling for them (such as Razer Synapse, MSI MysticLight).

Here’s a little demo and the link to the github repository in case someone finds this helpful and wants to use it as well:

Enjoy and so long :bulb:

3 Likes

Is it Possible to change saved open rgb profiles over mqtt with that?

Short answer: No.

Long answer: The OpenRGB SDK does not support saving profiles (yet) but as soon as it does this would be very easy to add. These are the currently supported operations of the SDK: https://gitlab.com/CalcProgrammer1/OpenRGB/-/blob/master/NetworkProtocol.h

I briefly thought of another way of solving this by directly writing to the OpenRGB config file but they use a proprietary format, so there’s no quick win here. I will open a feature request for the SDK to support saving profiles.

Could you also describe your specific use case so I know what exactly you’re trying to achieve? As of now my tool basically looks at a single color from a source (for now only MQTT topics are supported) and passes it on to what I call a sink (OpenRGB). As you probably know, OpenRGB allows for very fine grained configuration of devices, zones, and even single LEDs thereof. Would your requirement be to provide such a very fine grained configuration via MQTT or would saving a single color (maybe a single color per device) in the profile be sufficient?

Thx for the reply

Ah OK.
I also want to sync my Living room Colors with my Pc and at the moment I send via Node red a text file to Dropbox and I got an Program called Assistant Computer Control that checks an directory of Dropbox and when a file appears the program reads it and deleted it after.
And with this text file the program starts open rgb with an specific argument to load the right profile.
This works great but it took like 15 sec for a Change and I was hoping with mqtt to get rid of the Dropbox and also the open rgb start delay.

And yes in some profiles I got a lot different colors for different leds so only a color per device or even one color for all devices wouldn’t be that great.

But when the sdk may one day can just load the profiles that was saved in open rgb before would be rly nice

I initially misunderstood and thought you were trying to update profiles. So your use case is selecting profiles via MQTT. Sounds reasonable :slight_smile: I opened an issue already. Here’s the link so you can track the progress (maybe I even find the time to work on it myself)

Yes exactly, that sounds good I will keep an eye on it.
Thx a lot

The latest version of my little tool now supports loading OpenRGB profiles (and also changing the desktop background on Windows machines). Profile management was added to the OpenRGB API with commit f63aec11.

Apart from the general documentation that you can find in the README.md, I also added a couple of examples that demonstrate what the configuration file should look like in the wiki.

1 Like

That sounds great, when I got some free time I will look at it.
Thx for the update.

So Sorry i didnt had Time till now to Test it i tryed it today but i run in to an Problem.
I configured The allmylightsrc with my mqtt Server and the Open RGB Server that worked.
When i send an Profile name it says that Profile doesnt exist.
But it exist also when i stop the Open RGB Server it gives me an error that is off now so i guess iam connected in the right way.
Can it be a Problem that i use the newest Open RGB Version.

You may got an idea what iam doing wrong?

Could you invoke allmylights with --info and provide the output? Also the exact commit your OpenRGB was built from would help. You can find it under Information -> Software -> Git Commit ID

2021-07-25 19:38:08 (INFO): Configuring 1 sources
2021-07-25 19:38:08 (INFO): Configuring 1 sinks
MqttSource(192.168.2.186:1883) does not expose any configuration information.

OpenRGBSink(127.0.0.1:6742):
{
  "Devices": [
    {
      "Type": 0,
      "Name": "MSI MPG Z390 GAMING PRO CARBON AC (MS-7B17)",
      "Vendor": "MSI",
      "Description": "MSI Mystic Light Device (162-byte)",
      "Version": "APROM: 1.3, LDROM: 9.9",
      "Serial": "A02018072713",
      "Location": "HID: \\\\?\\hid#vid_1462&pid_7b17#6&3b2dc25d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}",
      "ActiveModeIndex": 0,
      "Modes": [
        {
          "Name": "Direct",
          "Value": 1,
          "Flags": 48,
          "SpeedMin": 0,
          "SpeedMax": 0,
          "ColorMin": 0,
          "ColorMax": 0,
          "Speed": 0,
          "Direction": -1,
          "ColorMode": 1,
          "Colors": []
        },
        {
          "Name": "Off",
          "Value": 0,
          "Flags": 0,
          "SpeedMin": 0,
          "SpeedMax": 0,
          "ColorMin": 0,
          "ColorMax": 0,
          "Speed": 0,
          "Direction": -1,
          "ColorMode": 3,
          "Colors": []
        },
        {
          "Name": "Breathing",
          "Value": 2,
          "Flags": 177,
          "SpeedMin": 0,
          "SpeedMax": 2,
          "ColorMin": 0,
          "ColorMax": 0,
          "Speed": 1,
          "Direction": -1,
          "ColorMode": 1,
          "Colors": []
        },
        {
          "Name": "Flashing",
          "Value": 3,
          "Flags": 177,
          "SpeedMin": 0,
          "SpeedMax": 2,
          "ColorMin": 0,
          "ColorMax": 0,
          "Speed": 1,
          "Direction": -1,
          "ColorMode": 1,
          "Colors": []
        },
        {
          "Name": "Double flashing",
          "Value": 4,
          "Flags": 177,
          "SpeedMin": 0,
          "SpeedMax": 2,
          "ColorMin": 0,
          "ColorMax": 0,
          "Speed": 1,
          "Direction": -1,
          "ColorMode": 1,
          "Colors": []
        },
        {
          "Name": "Lightning",
          "Value": 5,
          "Flags": 177,
          "SpeedMin": 0,
          "SpeedMax": 2,
          "ColorMin": 0,
          "ColorMax": 0,
          "Speed": 1,
          "Direction": -1,
          "ColorMode": 1,
          "Colors": []
        }
      ],
      "Zones": [
        {
          "Name": "JRGB1",
          "Type": 1,
          "LedCount": 1,
          "LedsMin": 1,
          "LedsMax": 1,
          "MatrixMap": null
        },
        {
          "Name": "JRGB2",
          "Type": 1,
          "LedCount": 1,
          "LedsMin": 1,
          "LedsMax": 1,
          "MatrixMap": null
        },
        {
          "Name": "JRAINBOW1",
          "Type": 1,
          "LedCount": 1,
          "LedsMin": 1,
          "LedsMax": 1,
          "MatrixMap": null
        },
        {
          "Name": "JRAINBOW2",
          "Type": 1,
          "LedCount": 1,
          "LedsMin": 1,
          "LedsMax": 1,
          "MatrixMap": null
        },
        {
          "Name": "JCORSAIR",
          "Type": 1,
          "LedCount": 1,
          "LedsMin": 1,
          "LedsMax": 1,
          "MatrixMap": null
        },
        {
          "Name": "Onboard LEDs",
          "Type": 1,
          "LedCount": 11,
          "LedsMin": 11,
          "LedsMax": 11,
          "MatrixMap": null
        }
      ],
      "Leds": [
        {
          "Name": "JRGB1 LED ",
          "Value": 1
        },
        {
          "Name": "JRGB2 LED ",
          "Value": 2
        },
        {
          "Name": "JRAINBOW1 LED ",
          "Value": 5
        },
        {
          "Name": "JRAINBOW2 LED ",
          "Value": 6
        },
        {
          "Name": "JCORSAIR LED ",
          "Value": 7
        },
        {
          "Name": "Onboard LEDs LED 1",
          "Value": 9
        },
        {
          "Name": "Onboard LEDs LED 2",
          "Value": 10
        },
        {
          "Name": "Onboard LEDs LED 3",
          "Value": 11
        },
        {
          "Name": "Onboard LEDs LED 4",
          "Value": 12
        },
        {
          "Name": "Onboard LEDs LED 5",
          "Value": 13
        },
        {
          "Name": "Onboard LEDs LED 6",
          "Value": 14
        },
        {
          "Name": "Onboard LEDs LED 7",
          "Value": 15
        },
        {
          "Name": "Onboard LEDs LED 8",
          "Value": 16
        },
        {
          "Name": "Onboard LEDs LED 9",
          "Value": 17
        },
        {
          "Name": "Onboard LEDs LED 10",
          "Value": 18
        },
        {
          "Name": "Onboard LEDs LED 11",
          "Value": 19
        }
      ],
      "Colors": [
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        },
        {
          "R": 0,
          "G": 0,
          "B": 0
        }
      ],
      "ActiveMode": {
        "Name": "Direct",
        "Value": 1,
        "Flags": 48,
        "SpeedMin": 0,
        "SpeedMax": 0,
        "ColorMin": 0,
        "ColorMax": 0,
        "Speed": 0,
        "Direction": -1,
        "ColorMode": 1,
        "Colors": []
      }
    }
  ],
  "Profiles": [
    "blue",
    "hell",
    "lil",
    "ocean",
    "orange",
    "red"
  ]
}
2021-07-25 19:38:09 (INFO): Connection to MQTT server (source) 192.168.2.186 established
2021-07-25 19:38:09 (INFO): Attempting to subscribe to allmylights/source

orgbgit

It finds the Profiles, i send for example “red.orp” via mqtt is that the right format when the profile name is “red” ?

Yeah, you’re using it the right way. I have to look into it to figure out what’s happening :thinking:

Idk for which Version you where coding your Software, but i remember older open rgb Versions where saving Profiles in the Location from where it was started. This Version now saves it
\Users"username"\AppData\Roaming\OpenRGB
May this is a reason for it?

I just went through the OpenRGB commit history and they changed a few things regarding the profile management (in particular they do no longer include the .orp extension in the profile list returned from the server and they also expect the profile name to be provided without the .orp extension edit: their profile loading code seems to be dealing with both cases just fine - with or without extension) Working on a fix (will be a quick one, an hour max) Will get back to you once finished :wink:

1 Like

I released a fix here that I cannot validate with an actual OpenRGB instance at the moment because I am moving apartments and my desktop computer is out of order. I basically worked off the changes I’ve noticed in the OpenRGB code and hope it works.

1 Like

Nice! Works Great now Thx a lot for the fast help :smiley:

1 Like

Hi, I still use your Tool Daily and it still works Without any problem.
Atm I use it to load Profiles in Openrgb and also to change the Desktop Background.

Since some days I have 2 Monitors with different resolution.

Is it in anyway Possible to set 2 Different Backgrounds on the both Monitors with your tool?

Thx in advance

Thanks for the feedback. I implemented the feature today and also added an example as for how to do it in the Wiki. This is only supported for Windows 8 or later since the respective COM API was only introduced with Windows 8. As always you can find the latest binaries in the release section. Please let me know if this works for you :wink:

Oh that was a fast release for that feature.
And it works great for me!

Thx a lot for the fast help!

1 Like