JSON API to Blocks Conversion

Hello, I’m having trouble converting my Python code into blocks. I’m using a JSON API where I created a Class with Python. Now I am trying to transfer that Class into Kodular. Here are some screenshots of my blocks. I’ve tried multiple combinations using blocks…

Here is some of the documentation for the API I am using…

Setting new values

Sending a POST request to /json or /json/state with (parts of) the state object will update the respective values. Example: {"on":true,"bri":255} sets the brightness to maximum. {"seg":[{"col":[[0,255,200]]}]} sets the color of the first segment to teal.

CURL example

This will toggle on and off and return the new state (v0.13+): curl -X POST "http://[WLED-IP]/json/state" -d '{"on":"t","v":true}' -H "Content-Type: application/json"

Python Code:

def update_light(node,on=True, bri=127, trans=5, ps=-1, pl=-1):
    url = protocol+node+api+'/state'
    print(url)
    status = {'on':on, 'bri':bri, 'transition':trans, 'v':True, 'ps':ps, 'pl':pl}
    OBJ = requests.post(url, json = status)

Here are my blocks:

1 Like