-
Notifications
You must be signed in to change notification settings - Fork 0
Publishing from OpenRGB to MQTT
Jan W edited this page Mar 26, 2021
·
2 revisions
In this example OpenRGB is used as source. Any updates to your OpenRGB managed devices will be published as a comma-separated RGB string to your MQTT broker (e.g. 255,20,100
).
It assumes an OpenRGB device named Corsair H150i PRO RGB
and extracts the color of the first LED of that device. To find out what devices are connected, you can use AllMyLights.exe --info > info.txt
or ./AllMyLights --info > info.txt
on unix and look at the device information of the OpenRGB source. You will see an array of objects that each have a name
property that holds the required name to be used in the Expression transformation.
Note that the Mqtt sink can be configured to publish to more than just one topic.
// allmylightsrc.json
{
"Sources": [
{
"Type": "OpenRGB",
"Server": "127.0.0.1",
"Port": 6742,
"Transformations": [
{
"Type": "Expression",
// this expression accesses the value returned by the OpenRGB source which is a dictionary keyed by device name
// Each value in this dictionary has a Colors property that holds the active Colors of the device - one per LED.
// The extension method ToCommaSeparatedRgbString transforms the color to a comma-separated RGB string
// Other extensions such as ToHexString or ToBgrDecimal could also be used
"Expression": "value[\"Corsair H150i PRO RGB\"].Colors.Cast().First().ToCommaSeparatedRgbString()",
}
]
}
],
"Sinks": [
{
"Type": "Mqtt",
"Server": "192.168.168.1",
"Port": 1883,
"Topics": ["first/topic", "another/topic"],
// optional
"Username": "my username",
"Password": "my password"
}
]
}