Difference between revisions of "Redirect variables"
(Created page with "Redirect variables allow UI Objects to be linked dynamically to a source. Variables can be used in: - any object's id - I/O Server Objects, in server id and address param...") |
|||
Line 16: | Line 16: | ||
Server UISets (from events or java) are used to set a redirect variable value. | Server UISets (from events or java) are used to set a redirect variable value. | ||
Each variable is a property of the "redirect" object. | Each variable is a property of the "redirect" object. | ||
− | For example, a variable called "myaddr" can be set to | + | For example, a variable called "myaddr" can be set to "70" with a [[Action_Keywords#UISET|UISet]] command on events: |
UISET redirect.myaddr=70 | UISET redirect.myaddr=70 | ||
+ | |||
+ | == Example: Weather Object == | ||
+ | In this example we will use a single [[TempMini]] object to display different sources. | ||
+ | In hsyco.ini we have an ioServer with 3 zones. | ||
+ | ioServers = bmne500 | ||
+ | ioServersType.bmne500 = MYHOME | ||
+ | ioServersOptions.bmne500 = tempzones=1;2;3 | ||
+ | |||
+ | In a project we place a [[TempMini]] and three [[User]] buttons. | ||
+ | On the TempMini parameters, we use two variables: mysid and myzone. | ||
+ | [[File:redirect_vars_01.png]] | ||
+ | |||
+ | Each [[User]] button will have "changetemp" as name and 1,2 or 3 respectively as param. | ||
+ | In [[JavaScript_Callback_Functions_API#userCommand|events]] we declare: | ||
+ | |||
+ | function userCommand(session, userid, name, param) : { | ||
+ | if (name == "changetemp") { | ||
+ | uiSet("redirect", "mysid", "bmne500"); | ||
+ | uiSet("redirect", "myzone", param); // address: "temp."+ myzone | ||
+ | } | ||
+ | } |
Revision as of 12:21, 26 September 2019
Redirect variables allow UI Objects to be linked dynamically to a source.
Variables can be used in: - any object's id - I/O Server Objects, in server id and address parameters - Button objects, in the address parameter
Syntax
Variables are defined with the following syntax:
[variable name]
E.g.
[myaddr]
Setting Values
Server UISets (from events or java) are used to set a redirect variable value. Each variable is a property of the "redirect" object. For example, a variable called "myaddr" can be set to "70" with a UISet command on events:
UISET redirect.myaddr=70
Example: Weather Object
In this example we will use a single TempMini object to display different sources. In hsyco.ini we have an ioServer with 3 zones.
ioServers = bmne500 ioServersType.bmne500 = MYHOME ioServersOptions.bmne500 = tempzones=1;2;3
In a project we place a TempMini and three User buttons. On the TempMini parameters, we use two variables: mysid and myzone.
Each User button will have "changetemp" as name and 1,2 or 3 respectively as param. In events we declare:
function userCommand(session, userid, name, param) : { if (name == "changetemp") { uiSet("redirect", "mysid", "bmne500"); uiSet("redirect", "myzone", param); // address: "temp."+ myzone } }