Shelly Bulb via MQTT 2.4

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:

JS:shelly_bulb_switch_input.js:

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

JS:shelly_bulb_color_input.js:

(function(i) {
    shellyInput = JSON.parse(i);
    return shellyInput.red + "," + shellyInput.green + "," + shellyInput.blue;
})(input)

JS:shelly_bulb_color_output.js:

(function(i) {

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

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

    return JSON.stringify(shellyOutput);

})(input)

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.

2 Likes