Help with logic on calling a JSON with substitution variables

My whole house audio system runs on Nuvo and I have a script running in homeseer that provides all of the control. I can access the script through JSON with various commands, I have provided an example below that switches zone 7 to source 2

…?action=setaudio&id=Z07CHASRC2

I am working on creating a dashboard that can be called to allow changing the zones, adjusting the volume, etc. I could create 12 dashboards - one for each zone - but I was thinking there would be a simpler way to create one dashboard and then specify which zone to act on.

Perhaps setting a variable with the zone number so when the dashboard loads it knows which zone it is acting on and then can call the JSON with zone substituted.

I have a similar need to control my sprinkler system.

Any thoughts / ideas would be great. Thanks.

That would be the first approach that comes to my mind as well. Sounds like a cool project! Is there something particular you have a question about?

Many questions.

First - when calling this dashboard how do I store the Zone number in the variable?

Once in the dashboard, how do I substitute the Zone number in the variable into the hyperlink?

So I call dashboard Select_Zone and put the value 1 in Active_Zone variable.

Then in the dashboard when I click on any of the channel buttons, it calls the hyperlink with the value of Active_Zone substituted so the hyperlink switches the channel for the specific zone?

Thanks.

Assuming the URL you mentioned is accessible from an internet facing endpoint, you could use the HTTP Actions in rules. You can tap the +VARIABLE button to insert a variable into your string, so you could use it to dynamically set a parameter if you wanted.

I’m not familiar with the intricacies of your URL parameters, but something like the following where $inputDemo = 07 and $myText = SRC2

You have a few options with how you store the data in the variable. You could just add the raw variable to your dashboard and manually change the input as needed (eg. tap on the variable tile and type with your keyboard).

Alternatively, you could create individual tiles that act like selections for each of your different variable values. You could do this with individual rules that each just set the variable value, but I think this is a good use case for $.runRule() Rule Parameters.

Depending on your setup, you could use any Hyperlink enabled tile – for example, an actual Hyperlink Tile or Media Tiles showing images for your various sources so it’s a bit more visual.

$.runRule("ZoneSetterRuleId", {"zone": "07"})
$.runRule("SourceSetterRuleId", {"source": "SRC2"})

You can then use those parameters in your rule just like the HTTP Triggers (context → event → http): How to trigger SharpTools rules using HTTP - SharpTools Knowledge Base

In the examples above, I’m using two separate rules dedicated to just receiving the event context variable and storing that into your dedicated variables for this purpose. Again, you can adapt do your needs as you see fit.

I figured you might have different ‘actions’ on your dashboard like setting the playback source, changing the volume, etc, but you could certainly have the rule react directly to one of those inputs changing as well.

I would also add that if you have a bit of HTML + JavaScript skills, you could also do this using a Custom Tile. That would give you a lot more control over how the UI looks, but is more of a developer focused feature.