@valentin I found some errors in the example code on the website.
Missing “;”:
var sliderValue = 0
var sliderPrevValue = 0
You should check for undefined in the if because the read function might return 0 which is a legit value. But 0 resolves to false, so the code in the if won’t be executed. Just took me two hours to figure that out. I have a switch which is 0 when it’s turned off and should be turned on in that case, but the code in the if just wouldn’t get executed.
So instead of:
obj.object.on("object", function (msg) {
var data = JSON.parse(msg)
if (obj.read("led", data)) {
slider.value = obj.read("led", data) * 255;
}
});
it should be:
obj.object.on("object", function (msg) {
var data = JSON.parse(msg)
if (obj.read("led", data) != undefined) {
slider.value = obj.read("led", data) * 255;
}
});