# Control lights via HTTP API on a Dali IOT Gateway

**URL:** <https://discourse.nodered.org/t/control-lights-via-http-api-on-a-dali-iot-gateway/59924>\
**Category:** General\
**Created:** [16 March 2022 10:58 UTC](https://discourse.nodered.org/t/control-lights-via-http-api-on-a-dali-iot-gateway/59924 "2022-03-16T10:58:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BWTH](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@BWTH](https://discourse.nodered.org/u/BWTH)\
**Post date:** [16 March 2022 10:58 UTC](https://discourse.nodered.org/t/control-lights-via-http-api-on-a-dali-iot-gateway/59924/1 "2022-03-16T10:58:33Z")

</div>

Hi  
i am new on node red, absloute beginner, node red is set up on raspberry,  
i have an iot gateway to control lights, so i wan´t to control it over node red  
over the api commands i can controll it, who could this work in node red?  
what i get from the api controll is:

```auto
curl -X 'POST' \
  'http://192.168.1.1/broadcast/control' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
 "switchable": false

}
'

```

does this help to create an flow, please help

 ![dali api](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/a/daafe64c40ebc48a9c6a8a78325545c27e8b1994.jpeg)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 March 2022 11:37 UTC](https://discourse.nodered.org/t/control-lights-via-http-api-on-a-dali-iot-gateway/59924/2 "2022-03-16T11:37:30Z")

</div>

> [@BWTH](#):
>
> does this help to create an flow, please help

Yes.

You should read the docs - the ["node-red cookbook HTTP request"](https://cookbook.nodered.org/#http-requests) has examples you can work through to get a better understanding

Also, be sure to read the built in help (on the RH sidebar) for the HTTP Request node (it will explain much of what is inside the function I wrote for you)

  

Here is a demo to get you started....

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/e/deb2850941a80c7254c49f4af3ea73de8f95b0f1.png)

The flow (use CTRL+I to import)...

```auto
[{"id":"2a513db0f9657f02","type":"inject","z":"cf45249a93d7b57a","name":"Click me","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":600,"y":260,"wires":[["2a513db0f9657f03"]]},{"id":"2a513db0f9657f03","type":"function","z":"cf45249a93d7b57a","name":"Prep headers, method, url","func":"//original curl: \n//\n//curl -X 'POST' 'http://192.168.1.1/broadcast/control' -H 'accept: */*' -H 'Content-Type: application/json' -d '{\"switchable\": false}'\n\nmsg.method = \"post\";\nmsg.url = \"http://192.168.1.1/broadcast/control\";\nmsg.payload = {\n \"switchable\": false\n};\nmsg.headers = {\n \"accept\": \"*/*\",\n \"Content-Type\": \"application/json\"\n};\nmsg.cookies = null;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":830,"y":260,"wires":[["2a513db0f9657f04"]]},{"id":"2a513db0f9657f04","type":"http request","z":"cf45249a93d7b57a","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":710,"y":320,"wires":[["2a513db0f9657f05"]]},{"id":"2a513db0f9657f05","type":"debug","z":"cf45249a93d7b57a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":930,"y":320,"wires":[]}]

```

NOTE: 👆 untested (i dont have your device)

---

<div class="post-metadata">

**Author:** ![BWTH](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@BWTH](https://discourse.nodered.org/u/BWTH)\
**Post date:** [16 March 2022 11:53 UTC](https://discourse.nodered.org/t/control-lights-via-http-api-on-a-dali-iot-gateway/59924/3 "2022-03-16T11:53:28Z")

</div>

thank you very much, it works!!!!!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [30 March 2022 11:53 UTC](https://discourse.nodered.org/t/control-lights-via-http-api-on-a-dali-iot-gateway/59924/4 "2022-03-30T11:53:48Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
