Getting Hub Variables

I am writing an app which will create variables that i can send to a notification rule or to dashboard tile. I believe I want to create hub "global" variables to make those values easily accessible.

I have tried the following but i get a illegal declaration within a method.

getGlobalVar(String variablename)

Do i need to import anything and where exactly would you be putting imports into a script "preferences"

If there is a better way to get values from app calculations so i can use them elsewhere other than hub variables I am all ears.

Thanks

That should work, though you can't literally use "String variableName", which you might know but it's not clear from your description; you need to substitute an actual string variable or literal string value, e.g., getGlobalVar("myName").

If that doesn't help, I suggest sharing a minimal reproducable example, and someone can probably help you (if you aren't familiar with the concept: How to create a Minimal, Reproducible Example - Help Center - Stack Overflow -- more or less, though that was written with a general audience in mind and not the Hubitat environment specifically).

1 Like

Thanks I was using the String data type declaration and then the variables name. switched to "variables name" and worked.

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