Your comments

Hello

I am revisiting this project and still having issues. I am able to write the temperature value to a panel project text item, but I want to have this written to the server token I've created. I have been reading about IR.Log i.e. send the temperature to an IR.Log, then send that IR.Log to the server variable/token. How should I code that using the code above as an example? (tempreadout2 = the actual human readable temperature as 25.6ºC for example. 

Thank you for your help. The code works really well - it's a great snippet to build other ideas now:

IR.AddListener(IR.EVENT_ITEM_PRESS, IR.GetPopup("LabLink_Sources").GetItem("Receive_Lab1"), function()
{
var status = IR.GetVariable("Drivers.F10A-SERVER-01.LAB1-SIM");

if (status == 0)
{
IR.HideAllPopups("");
IR.ShowPopup("LabLink_Sources");
IR.ShowPopup("LabLink_NoAccess");
IR.Log("0");
}
if (status == 1)
{
IR.HideAllPopups("");
IR.ShowPopup("LabLink_Sources");
IR.ShowPopup("LabLink_Receive_Lab1");
IR.Log("1");
status = 0;

}
});

Thank you for this! I changed the code to request the status from the Server Feedback and will test tomorrow when I get to our labs. This is to allow our users to 'enable' or 'disable' the ability for other control panels in other labs to access video controls. If enabled, a user in another lab can then see a popup allowing them to route video content to a local projector. If disabled, they will see a popup advising they need to ask permission from the other lab. 

IR.GetDevice("FMHS-ALERTSPKR-01").Set("Lab1_Alert_Playlist", ""),	
	IR.GetDevice("FMHS-ALERTSPKR-01").Set("play_sound", ""),
function doSecondThing()
{		
	IR.GetDevice("FMHS-ALERTSPKR-02").Set("Lab1_Alert_Playlist", ""),
	IR.GetDevice("FMHS-ALERTSPKR-02").Set("play_sound", ""),
}
IR.SetTimeout(2000, doSecondThing);

Thank you - this is working beautifully. I inserted:

IR.SetTimeout(200, sendRequests);

However I am now finding it repeating the result every 200ms (display text, play a sound). Next task is to have it query the device and if nothing has changed since last time, do not issue a command. 

Please to share that a clever colleague has solved the parsing problem for me. Only thing left is for it to poll the bridge every 100ms for a status change.

IR.AddListener(IR.EVENT_START, 0, function()
   
{
   IR.GetDevice("hue");
   // ***get Hue driver***
   sendRequests();
   // ***send request for API***  
   // ***Code to go here to request status every 100ms regardless of active page or popup***         
});

function sendRequests()
{
   // ***request status of Sensor 14 - Buttons ¬ eventually these scripts will need to listen to 10x buttons***
   IR.GetDevice("hue").SendEx({ 
         Type: "GET",                                                                    
         Url:  "/api/4pIBQMqs2Nib6JgK9XtBsaACKKClGAUTKrOtjivg/sensors/14",      
         cbReceiveText:       function(text)  
         {
            var response = JSON.Parse(text);
            var buttonEvent = response.state["buttonevent"];
            var numberToString = buttonEvent.toString();
            var firstNumber = numberToString.charAt(0);
            // Takes the first number of the button event response which correlates to the button press.
            // This is then parsed allowing the button to trigger something in iRidium unstead.
            switch (firstNumber)
            {
              case '1':
                        IR.GetPage("Page 1").GetItem("buttonstate").Text = "number 1 has been pushed.";    
              break;
              case '2':
                     IR.GetPage("Page 1").GetItem("buttonstate").Text = "number 2 has been pushed.";
              
              break;
              case '3':
                     IR.GetPage("Page 1").GetItem("buttonstate").Text = "number 3 has been pushed.";
              
              break;
              case '4':
                     IR.GetPage("Page 1").GetItem("buttonstate").Text = "number 4 has been pushed.";
                            
              break;
              default:
                            
              break;
            }
              
         },
   
   });
}

// The current response without parsing is as follows. What is important
// is the first number after state > button event > XXXX

// *start of response from API for Sensor = 12*
//{
//    "state": {
//        "buttonevent": 4002,
//        "lastupdated": "2018-12-15T01:23:33"
//    },
//    "config": {
//        "on": true,
//        "battery": 100,
//        "reachable": true,
//        "pending": []
//    },
//    "name": "DimmerDemo",
//    "type": "ZLLSwitch",
//    "manufacturername": "Philips",
//    "swversion": "5.45.1.17846",
//    "uniqueid": "00:17:88:01:04:af:cb:12-02-fc00"
//}
// *end of response from API for Sensor = 12*

Hi Vladimir - thanks for your awesome support. I tried to insert this code but it either breaks my code, or it still shows the old results. I have attached my project for your reference. Hue Dimmer Button Demo

HI Vladimir

Focusing on the JSON stuff, I think I may have your syntax a bit wrong. Is this on the right track?

function sendRequests()
{
// ***request status of Sensor 12 - Buttons - eventually these scripts will need to listen to 10x buttons***
IR.GetDevice("hue").SendEx({
Type: "GET",
Url: "/api/a8CaS3oaTHN0mL-1IgKZgYRzXTLL3kIbJVApJukm/sensors/12",
cbReceiveText: function(text),
var tmp = '{"state": "buttonevent"}';
IR.Log("JSON.parse(tmp).buttonevent");
str.charAt(1);
}

{
switch (buttonevent)
// ***Code to go here to parse response data and extract state > buttonstate > XXXX***
IR.GetPage("Page 1").GetItem("buttonstate").Text = text;

Thanks Vladimir

I will try this now!

The bit from the JSON I need is

LEVEL 1 = 0

LEVEL 2 = state

LEVEL 3 = buttonevent: XXXX

Hello

I have been using inexpensive WIFI controllers with RGB strips and integrating with iRidium through a custom driver. I have setup presets for the colours I need and then just recall them via TCP. If you want more information I could put together a tutorial or send you the information.