Shelly Bulb via MQTT 2.4

Is it the case that outgoing transformations are there, but just for files and not for the PaperUI?

I was able to find the incoming transformations, and with a simple made the incoming stat events update the state of the item:

(function(i) {
    shellyInput = JSON.parse(i);
    return + "," + + "," +;

But I’m struggling to find where to put the outbound transformation in PaperUI.

I can manage to code and go to the lower level but I’d rather stay within PaperUI as much as I can to keep the target of users of my openhab as wide as possible.

Surely not. The entire xtend file configuration nonsense (read: .thing and .item files) is not supported by me. You can be sure that every binding that is maintained by me works in Paper UI. You need OH 2.5M1 though.

1 Like

Thanks for the tip.

For what is worth I made it work, it was a simple as creating a Thing with a switch and a color channel, for the switch one set the “Custom On/Open value” to “on” (lowercase) and the off/closed to “off”.

Then for the switch one, incoming transformation: JS:shelly_bulb_switch_input.js
For the color one, incoming: JS:shelly_bulb_color_input.js and outgoing: JS:shelly_bulb_color_output.js.

Then just create the files in transformation:


(function(i) {
    shellyInput = JSON.parse(i);
    return shellyInput.ison ? "on" : "off";


(function(i) {
    shellyInput = JSON.parse(i);
    return + "," + + "," +;


(function(i) {

    var rgb = i.split(",");

    shellyOutput = {
        "ison": true,
        "mode": "color",
        "red": rgb[0],
        "green": rgb[1],
        "blue": rgb[2]

    return JSON.stringify(shellyOutput);


All this of course using the version @David_Graeff mentioned. I upgraded with a simple sudo openhabian-config to change to the testing channel.

I know this is cumbersome and it would me ten times better to have homie support, but at least its better than nothing.


Thanks for the code, I’ve used it to integrate the shelly bulb into my system.
I made a couple of improvements.

The first: you don’t need the shelly_bulb_switch_input.js if you define the “on/off” directly in the channel:

Type switch : color_switch_01 "Color Switch" [ stateTopic="shellies/shellybulb-xxxxxx/color/0", on="on", off="off", commandTopic="shellies/shellybulb-xxxxxx/color/0/command"]

You can also add some basic brightness and color temperature control by using additional channels in the thing definition. Also here no need for a separate js file.

        Type dimmer : white_dim_01 "Brightness" [ stateTopic="shellies/shellybulb-xxxxxx/color/0/status", transformationPattern="JSONPATH:$.brightness", commandTopic="shellies/shellybulb-xxxxxx/color/0/set", formatBeforePublish="{ \"mode\": \"white\", \"brightness\" : %.0f }"]
        Type dimmer : white_temp_01 "White Temperature" [ stateTopic="shellies/shellybulb-xxxxxx/color/0/status", transformationPattern="JSONPATH:$.temp", commandTopic="shellies/shellybulb-xxxxxx/color/0/set", min=3000, max=6500, step=10, formatBeforePublish="{ \"mode\": \"white\", \"temp\" : %s }"]
        Type dimmer : color_gain_01 "Color Brightness" [ stateTopic="shellies/shellybulb-xxxxxx/color/0/status", transformationPattern="JSONPATH:$.gain", commandTopic="shellies/shellybulb-xxxxxx/color/0/set", formatBeforePublish="{ \"mode\": \"color\", \"gain\" : %.0f }"]
        Type string : color_mode_01 "Color Mode" [ stateTopic="shellies/shellybulb-xxxxxx/color/0/status", transformationPattern="JSONPATH:$.mode"]
1 Like