Roller shutter: Use slider to move up and down

Hi all,

I am a little bit stuck. I would like to use a slider to move my roller shutter without MQTT. I have the right URL which works well, but here is my challenge:

The URL in my http-request-node is like: "http://192.168.XXX.XXX/roller/0?go=to_pos&roller_pos="

THe value for the position should be provided by the slider - the payload is the number which could be used. But I do not get it, how I use the msg.payload from the slider to complete the above url - how would you solve it?

I treid to use a function and combine the values to one variable and return it as one value form the function to the http-request-node. But the function node only gives out an error message that it tried to return a string.

Does anyone have a clue , hint for me? :slight_smile:

you can use the template mustashe,

http://192.168.xxx.xxx/roller/0?go=to_pos&roller_pos={{payload.whateverelement}}

or

make sure you return a object
so in your function return {"payload": your_var};

How do I know which "element" I have to use? Now it looks better, but the http-request-node says "invalid payload".

put a debug after the slider node and post the output message.

It is most likely just "payload".

Maybe this helps:

[{"id":"f812e60c.6453c","type":"ui_slider","z":"f1a51433.4fb368","name":"Küchenslider","label":"","tooltip":"","group":"bd3c2028.1a693","order":4,"width":"6","height":"1","passthru":true,"outs":"end","topic":"","min":0,"max":"100","step":1,"x":430,"y":180,"wires":[["27a93478.46fee4"]]},{"id":"b5cae51e.e66648","type":"http request","z":"f1a51433.4fb368","name":"Küchenfenster_Slider_Position","method":"GET","ret":"obj","paytoqs":true,"url":"http://192.168.XXX.20/roller/0?go=to_pos&roller_pos={{payload.msg}}","tls":"","persist":false,"proxy":"","authType":"basic","x":810,"y":160,"wires":[["b12aeef3.f11cc"]]},{"id":"b12aeef3.f11cc","type":"debug","z":"f1a51433.4fb368","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":850,"y":320,"wires":[]},{"id":"4a87804b.ff31a","type":"debug","z":"f1a51433.4fb368","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":320,"wires":[]},{"id":"27a93478.46fee4","type":"function","z":"f1a51433.4fb368","name":"","func":"var message = msg.payload;\nvar url = \"http://192.168.xxx.20/roller/0?go=to_pos&roller_pos=\";\n//msg = url.toString() + message.toString();\nreturn {\"payload\": message};\n\n\n//x = msg.toString(8);\n//return \"http://192.168.178.20/roller/0?go=to_pos&roller_pos=\"+ msg.toString();\n\n//msg1 = (\"http://192.168.xxx.20/roller/0?go=to_pos&roller_pos=\"+ x);\n//return msg1;","outputs":1,"noerr":0,"x":610,"y":220,"wires":[["4a87804b.ff31a","b5cae51e.e66648"]]},{"id":"bd3c2028.1a693","type":"ui_group","z":"","name":"Rolläden","tab":"f2bb749e.fdb478","order":1,"disp":true,"width":"18","collapse":false},{"id":"f2bb749e.fdb478","type":"ui_tab","z":"","name":"Rolläden","icon":"dashboard","disabled":false,"hidden":false}]

PLEASE PUT ``` BEFORE AND AFTER THE CODE ON NEW LINE SO CODE IS FORMATTED CORRECTLY and there is an easy link to click to copy your flow

that is the node exported. We need to seed the output from the slider node.
like this

I get the output from the slider, but the http-request-node does not work as I expected. I updated my post with the exported code, did you recognize it? :slight_smile:

Post your code like below

```
your code
```

> [{"id":"f812e60c.6453c","type":"ui_slider","z":"f1a51433.4fb368","name":"Küchenslider","label":"","tooltip":"","group":"bd3c2028.1a693","order":4,"width":"6","height":"1","passthru":true,"outs":"end","topic":"","min":0,"max":"100","step":1,"x":430,"y":180,"wires":[["27a93478.46fee4"]]},{"id":"b5cae51e.e66648","type":"http request","z":"f1a51433.4fb368","name":"Küchenfenster_Slider_Position","method":"GET","ret":"obj","paytoqs":true,"url":"http://192.168.XXX.20/roller/0?go=to_pos&roller_pos={{payload.msg}}","tls":"","persist":false,"proxy":"","authType":"basic","x":810,"y":160,"wires":[["b12aeef3.f11cc"]]},{"id":"b12aeef3.f11cc","type":"debug","z":"f1a51433.4fb368","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":850,"y":320,"wires":},{"id":"4a87804b.ff31a","type":"debug","z":"f1a51433.4fb368","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":320,"wires":},{"id":"27a93478.46fee4","type":"function","z":"f1a51433.4fb368","name":"","func":"var message = msg.payload;\nvar url = "http://192.168.xxx.20/roller/0?go=to_pos&roller_pos=";\n//msg = url.toString() + message.toString();\nreturn {"payload": message};\n\n\n//x = msg.toString(8);\n//return "http://192.168.xxx.20/roller/0?go=to_pos&roller_pos="+ msg.toString();\n\n//msg1 = ("http://192.168.xxx.20/roller/0?go=to_pos&roller_pos="+ x);\n//return msg1;","outputs":1,"noerr":0,"x":610,"y":220,"wires":[["4a87804b.ff31a","b5cae51e.e66648"]]},{"id":"bd3c2028.1a693","type":"ui_group","z":"","name":"Rolläden","tab":"f2bb749e.fdb478","order":1,"disp":true,"width":"18","collapse":false},{"id":"f2bb749e.fdb478","type":"ui_tab","z":"","name":"Rolläden","icon":"dashboard","disabled":false,"hidden":false}]

1 Like

3 back ticks before and after on new line. back tick is left of the 1 key on keyboard, normally

The function is most likely over writting the msg.payload.

The function node is unnecessary here as far as I understand. Just connect the slider node directly to http request. Set the request URL to: http://192.168.xxx.xxx/roller/0?go=to_pos&roller_pos={{payload}}

If this works, I would also consider adding a delay node in between to not overwhelm the roller shutters when moving the slider to the target position. This is if the slider constantly sends values when moved (I don't remember how it works tbh).

i f i directly connect it:

"Invalid payload"

Code:

[{"id":"b058fa45.3251c8","type":"ui_slider","z":"f1a51433.4fb368","name":"Küchenslider","label":"","tooltip":"","group":"bd3c2028.1a693","order":4,"width":"6","height":"1","passthru":true,"outs":"end","topic":"","min":0,"max":"100","step":1,"x":290,"y":180,"wires":[["666ccb61.a3b414"]]},{"id":"1c89ddd2.83bfda","type":"http request","z":"f1a51433.4fb368","name":"Küchenfenster_Slider_Position","method":"GET","ret":"obj","paytoqs":true,"url":"http://192.168.178.20/roller/0?go=to_pos&roller_pos={{payload}}","tls":"","persist":false,"proxy":"","authType":"basic","x":850,"y":180,"wires":[["8674576b.1f7f9"]]},{"id":"8674576b.1f7f9","type":"debug","z":"f1a51433.4fb368","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":890,"y":340,"wires":[]},{"id":"666ccb61.a3b414","type":"delay","z":"f1a51433.4fb368","name":"delay","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":510,"y":120,"wires":[["1c89ddd2.83bfda"]]},{"id":"bd3c2028.1a693","type":"ui_group","z":"","name":"Rolläden","tab":"f2bb749e.fdb478","order":1,"disp":true,"width":"18","collapse":false},{"id":"f2bb749e.fdb478","type":"ui_tab","z":"","name":"Rolläden","icon":"dashboard","disabled":false,"hidden":false}]

^^^ are not ``` Please edit your post and add the back ticks . It makes life easier for people trying to help you.

Got it, sorry :slight_smile:

In the http request block untick append msg.payload as query string parameters, als are your shelly's using username and password?

unticking the "append msg.payload" worked for me! mmh, interesting. Thanks a lot guys!

You can pass the query as a payload, so if you create the msg.payload in your function node like below.

msg.payload ={ "go": "to_pos", "roller_pos": msg.payload}

then if you tick append msg.payload, then your url would be

http://192.168.xxx.xxx/roller/0

The append msg.payload option attempts to parse a payload object into query parameters. So in this case you'd need a node to send a payload:

{
  "go": "to_pos", 
  "roller_pos": <number_from_slider> 
}

.. and then have the URL as just: http://192.168.xxx.xxx/roller/0. The go and roller_pos query parameters would be generated from the payload. But nevermind that now it you already got it working.

Edit: like @E1cid replied faster.

1 Like

Thanks to all helping to to better understand :wink:

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