bitfocus / companion-module-generic-http

Generic HTTP module
MIT License
9 stars 19 forks source link

Add the ability ability to set custom variable values with an HTTP request #24

Closed amcchord closed 2 years ago

amcchord commented 2 years ago

Add the ability for a GET request to save the response from the remote server to a custom variable.

These variables can be used with other modules in the companion ecosystem.

One example might sending a GET request to get the name of file to play next from a custom web app. Then store this name in a variable and use it with the HyperDeck module to play that file.

retog commented 2 years ago

here you go:

let myCustomVariable = await (await fetch("https://github.com")).text()

amcchord commented 2 years ago

What? I think you are missing it. This would be added to the companion UI needs to be updated and would be great if I could specify a companion custom variable for the result of this call to be stored in.

Screen Shot 2022-02-01 at 4 06 32 PM
amcchord commented 2 years ago

yeah it needs to be part of the companion system the way the other valuables end up there. It's less about being in the browser and more about being part the system so you use the variables when working with other modules.

amcchord commented 2 years ago

Companion already supports variables and custom variables. You can create them in the UI and assign them a value there. The goal of this would be for a variable created in the companion UI to have its value updated by the result of companion making an HTTP GET request.

mertmit commented 2 years ago

I added the requested feature in my pull request (https://github.com/bitfocus/companion-module-generic-http/pull/25).

amcchord commented 2 years ago

I can help make the story clearer

amcchord commented 2 years ago

I guess the best way to think about this would be that you can add custom variables are part of the HTTP module and they would be assigned based on the response from a get request. If you are looking for examples of custom variables check out the Spotify Module.

Screen Shot 2022-02-10 at 12 37 25 PM

mertmit commented 2 years ago

@amcchord I used internal variables to save HTTP response -which you can use as $(internal:custom_VARNAME)- but I think you want to parse data you receive so you can assign more variables from one request. It is important to know what type of data you want to use as it is different to parse (JSON, raw HTML etc. or even if you want seperate options for both). So can you give further info on data you want to get.

(@abebeos I am not related with the team.)

mertmit commented 2 years ago

Settings Button1-1 Button1-2 Emulation1 Emulation2 Other-Buttons

@amcchord This is an example result after last push, I sticked to main repository and extended it so this PR not effect main function of the repository. You can assign internal variables and use them on other modules as intended.

Julusian commented 2 years ago

I've assigned the issues/prs related to this to myself, as I intend to properly read through this and figure out the correct approach over the weekend

JeffreyDavidsz commented 2 years ago

@abebeos as I read it, the solution is near. Please do not pollute this channel on external matters. I would advise not to go through other payment options until its absolutely clear Bountysource is failing. Then Bountysource should pay back to @amcchord first before he will transfer it again against something else. But again, this has noting to do with Companion, so please keep it out here.