Write Slide Value

#1

can anyone help me with this one?
i have a DDC controller, i can write value with this request:

http://192.168.1.240/root?resource=WriteProperty&jsoncode={"index"%3A335938824%2C"property"%3A85%2C"value"%3A45}&callback=_jqjsp&_1548966493485=

the value Writing is now 45. now i want to use the slider to change the value and send it.
i tried to use the http request node like this:
http://192.168.1.240/root?resource=WriteProperty&jsoncode={"index"%3A335938824%2C"property"%3A85%2C"value"%3A{msg.payload}}&callback=_jqjsp&_1548966493485=

but it doesn't work. does anyone has an idea?

thanks..

0 Likes

#2

try building the url in a function node and passing that to the http request node.

That way you can also use a debug to see what you have defined and where you might be going wrong.

0 Likes

#3

thanks for your feedback,

I have tried to write the function node but do not get it working. tried several things. I think it should look like this:

[{"id":"52da13b5.537f4c","type":"ui_slider","z":"912a3768.44dad8","name":"","label":"slider","tooltip":"","group":"369ad7fb.53ec58","order":0,"width":"6","height":"1","passthru":true,"outs":"all","topic":"","min":"35","max":"45","step":"1","x":490,"y":160,"wires":[["818cb14b.c0e95"]]},{"id":"818cb14b.c0e95","type":"function","z":"912a3768.44dad8","name":"Slider into HTTP request","func":"var msg = {\n    method: 'get',\n    url: 'http://192.168.1.240/root?resource=WriteProperty&jsoncode={%22index%22%3A335938824%2C%22property%22%3A85%2C%22value%22%3A :msg.payload }}&callback=_jqjsp&_1548966493485='\n};\nreturn msg;\n","outputs":1,"noerr":0,"x":730,"y":160,"wires":[["3b5a97d0.dd5ea8"]]},{"id":"3b5a97d0.dd5ea8","type":"http request","z":"912a3768.44dad8","name":"","method":"use","ret":"txt","url":"","tls":"","x":990,"y":160,"wires":[[]]},{"id":"369ad7fb.53ec58","type":"ui_group","z":"","name":"Woonkamer","tab":"856afc2a.9be24","disp":true,"width":"6","collapse":false},{"id":"856afc2a.9be24","type":"ui_tab","z":"","name":"Woonkamer","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

what am I doing wrong??

0 Likes

#4

If you look at the result in a debug node does it look correct?
Also your flow is not importable, you need to edit the previous post as described in How to share code or flow json

0 Likes

#5

That’s not how you concatenate strings in javascript
see

http://2ality.com/2011/10/string-concatenation.html

0 Likes