ISY-99i Series INSTEON:Networking:Tasker:GetISYvariables

From Universal Devices, Inc. Wiki
Revision as of 12:38, 20 August 2016 by MWareman (Talk | contribs)

Jump to: navigation, search

This is how to get the content of an ISY variable with Tasker - and store the results in Tasker Global Variables.

First, setup the Network Awareness section. This is so you get nice, fast API access on the same LAN as your ISY - but secure remote access (either directly, or via the ISY Portal) while away from home.

Master Variable Retrieval Task

First - a master task that will be called by others... I called mine 'ISY-GetStatus-Var'.

1. 'Anchor' - 'start_request'
2. 'HTTP Get' - Server:Port='%IsyUrl' - Path='/rest/vars/get/%par1/%par2' - Continue Task After Error='Checked'   (If direct and self signed cert, check 'Trust Any Certificate')
3. 'Wait' - 'Seconds'=2 - If %HTTPR eq -1
4. 'Goto' - Type='Action Label' - Label='start_request' - If %HTTPR eq -1
5. 'JavaScriptlet' - Paste the 'Code' from the next box...
6. 'Return' - Value='%varLastVal' - Stop=Checked

The content of the JavaScriptlet is:

var parser = new DOMParser();
var xmlDoc = parser.parseFromString(global('HTTPD'),"text/xml");
var varHeader = xmlDoc.getElementsByTagName("var")[0];

Retrieve value using master variable retrieval task

I have a variable I wish to retrieve... 'FR-Temp'. It is a 'State' variable with ID 124. On the Wiki, you can see State variables are type '2'.

This is the task you create to get this variable:

1. 'Perform Task' Name='ISY-GetStatus-Var' - Parameter 1='2' - Parameter 2='124' - Return Value Variable='%var_val'
2. 'Action Popup' Text='%var_val' Timeout='5'

Run the task - you'll get a popup with the current variable.

The Javascript sets variables (global in scope) for the properties of the variable.

%varLastVal - Last returned variable value
%varLastInit - Last returned variable Init value
%varLastSet - Date and time the variable was last set
%varLastID - ID of last returned variable
%varLastType - Type of last var (1=Integer, 2=State)

In any other task - you can 'Perform Task' 'ISY-GetStatus-Var' with %par1 being the type, and %par2 being the ID of the variable you need the value of. Then read the values of the call from variables...