Skip to content

Loading a profile mapped from a color

Jan W edited this page Feb 15, 2021 · 3 revisions

In this example a color is received as a property of an object via MQTT (e.g. { "color": "ED2015" }, extracted from the object, and subsequently mapped to an OpenRGB profile.

Note the mapping transformation in the Transformations property of the OpenRGB sink. It has 2 mapping expressions. The first one maps any string matching the regular expression #?FFFFFF, to the profile name White.orp. The second expression maps any string that has any characters at all to Multicolor.orp. The mapping transformation always returns the to value from the first expression matching the input value.

// allmylightsrc.json

{
  "Sources": [
    {
      "Type": "Mqtt",
      "Server": "192.168.168.1",
      "Port": 1883,
      "Topics": {
        "Result": "stat/openrgb/color"
      }
    }
  ],
  "Sinks": [
    {
      "Type": "OpenRGB",
      "Server": "127.0.0.1",
      "Port": 6742,
      "Transformations": [
        {
          "Type": "JsonPath",
          "Expression": "$.color"
        },
        {
          "Type": "Mapping",
          "FailOnMiss": true,
          "Mappings": [
            {
              "From": "#?FFFFFF",
              "To": "White.orp"
            },
            {
              "From": ".+",
              "To": "MultiColor.orp"
            }
          ]
        }
      ]
    }
  ]
}