Need help to convert java script to rest command

Hi All,
I need some help how can I convert my java script to switch to config file.
I use this to control my legacy Arduno based home control.

This is the command what works with my Arduino, I control it via simple html.

function proceed (x) {var form = document.createElement(‘form’);form.setAttribute(‘method’, ‘post’);switch (x){
case 1:form.setAttribute(‘action’, ‘’);break;
case 2:form.setAttribute(‘action’, ‘’);break;
form.setAttribute(‘target’,‘hidden-form’); = ‘hidden’;document.body.appendChild(form);form.submit();} :script end

I use this command to run:

#<#a onclick=“proceed(1)” title=“light up” style="position: absolute; left: 61%; top: 15%; width: 10%; height: 10%; z-index: 99; "/a>
#<#<a onclick=“proceed(2)” title=“light down” style=“position: absolute; left: 61%; top: 32%; width: 10%; height: 10%; z-index: 9;”/a>

I think you first need to set the two urls up as restful commands. You can then check them out with developer tools to make sure they work, and then use the commands as services in scripts.

Yes, however this is my problem, i do not know how to do it. I tried it different ways w/o success

Which bit do you not understand?

How to set up the restfull command first>
I started with this one, but does not work:
url: ‘

I think you need to use the POST method. The default is GET.

And can you format your yaml snippets using the instructions in the blue box at the top of the page, it makes them easier to see any problems as spacing is important.

Thank you !
It is working now


1 Like