bitfocus / companion-module-generic-http

Generic HTTP module
MIT License
9 stars 19 forks source link

add vairiables #44

Open Mike-Ghosty opened 1 year ago

Mike-Ghosty commented 1 year ago

Can you add variables to a connection for use when running scripts to that connection.

josephdadams commented 1 year ago

Can you add more information? I don’t understand.

otelom commented 10 months ago

Hello,

I found this issue and I think I can add my request here.

I would like to have custom variables so we could have, for instance, the host URL being formed by variables. I have a lot of devices in my network, and I use HTTP commands to operate them. At this point, I have to create a button per IP per command. I would prefer to just have one button per command and have a keypad to set the ip number of the host and the value for the setting.

So the URL would be something like http://192.168.1.[variable1]:xyz/?blah=asd

Basically I want to dinamycally allow the user to define the host IP or just part of it. We could even have more variables so we could do http://192.168.[variable1].[variable2] or something like http://192.168.[variable1].[variable2]:1234/?command=[variable3]&value=[variable4]

Do you understand what I'm saying?

Then I would have to create a page with buttons from 0 till 9 and each time I would press them it would create an integer (we could create another button for the decimal point "." so we could also parse decimal numbers). Pressing numbers 1, 2, 3 would result in storing number 123 to variable X.

It would be nice to have a variable to be used as a temporary place to store the content as a string while still building it. That is, imagine we have variable A, B and C (btw, let us create and name how many variables we want if possible), now I build a page to create a keypad, I'll add 10 buttons (from 0 till 9) and their action will be to append to the temporary variable the value of that button (you could do this or allow us to set it with an expression, something like tempVariable=tempVariable+value), I would also need a few more buttons, a CLEAR (to clear the value of the temporary variable), a SAVE (to save the value of the temporary button to the desired variable) and a "." decimal point (to append to the string of the temporary variable while builind the number). The SAVE button will need to know to which variable it will save the temp value into, for that we need another action, SELECT VARIABLE TO EDIT, this will tell the SAVE button where to save to.

Sorry for all the text but I hope I was clear enough and let me know if I wasn't or if you have any doubts so I can help clearing them.

spoelstraethan commented 8 months ago

It would be really interesting if the page number was a variable, as then you could potentially use that as part of your host targeting scheme, or some operation against the page number if you had a "table of contents" that was pg 1 with your host pages listed, and then the last button of each host page could bring you back to the "top", but you could easily build up strings using the IP if you follow a consistent pattern.