Control WLED through REST in a script

Heyho,
I played around with WLEd, a super attractive option for cheap LED controllers.
Now I have some of them and I want to trigger presets through nymea.
MQTT doesn‘t support triggering WLED presets, but through REST command it works.

https://kno.wled.ge/interfaces/http-api/

Can somebody pls post a code example for a script that does that?

Thanks!

Guess I figured it out:

import QtQuick 2.0
import nymea 1.0

Item {
    
    property string on: "http://10.10.10.180/win&T=1";
    property string off: "http://10.10.10.180/win&T=0";

    ThingState {
        id: oberleuchte
        thingId: "{73e382a8-e0b3-400d-81c3-d462fcc94338}" // Küche Oberleuchte - this is a generic light
        stateName: "power"
        onValueChanged:
        {
            if(value == 0) {
                var http = new XMLHttpRequest();
                http.open("GET", off, true);
                http.send(off);
            } else {
                var http = new XMLHttpRequest();
                http.open("GET", on, true);
                http.send(on);
            }
        }
    }
}

Any tips to make it better?

That looks great :+1:

Thanks for sharing