var reject = 0; // it locks the condition when the value not really changes IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetDevice("Modbus (TCP)"), function(name,value) { if (name == "Feedback 1" && value == 0) // feedback changes from 1 to 0 { reject = 0; } else if (name == "Command 2" && value == 1 && reject == 0) // feedback changes from 0 to 1 or it stays 1 for some time { IR.ShowPopup('Popup 1'); reject = 1; } });
var deviceName = "KNX"; // Driver Name var ChannelBuff = ['Dimmer', 'f32', 'u32', 's32', 'u16', 's16']; // List of Feedbacks var projectToken = "MyProjectToken"; // Project Token name function CheckChannels(DeviceID, _ChannelBuff, _Token) { DeviceID = IR.GetDevice(DeviceID); // Get the device ID for (var i = 0; i <= _ChannelBuff.length - 1; i++) // Check the Feedbacks if(DeviceID.GetFeedback(_ChannelBuff[i]) > 0) // If the Feedback > 0, then write 1 to Project Token IR.SetVariable("Global." + projectToken, 1) } IR.AddListener(IR.EVENT_TAG_CHANGE , IR.GetDevice(deviceName), function(name,value) { IR.SetVariable("Global." + projectToken, 0); CheckChannels(deviceName, ChannelBuff, projectToken); })
if (condition1 && condition2) { <action> };
IR.AddListener(IR.EVENT_TAG_CHANGE , IR.GetDevice("MyDriver"), function(name,value) { <action> });
IR.AddListener(IR.EVENT_TAG_CHANGE , IR.GetDevice("MyDriver"), function(name,value) { if (name == "Feedback 1" && value == 100) { IR.Log("got 100 from Feedback 1"); IR.GetItem("Page 1").GetItem("Item 1").Value = 1; //got 100 but set 1 in Item } else if () { IR.Log("got something else"); } });
device.Send(['PUT,/api\r\n\HTTP/1.1,' + JSON.Stringify(request) + ',\r\n\r\n']);
IR.AddListener(IR.EVENT_CHANNEL_SET,that.device,function(name) { that.Msg = IR.GetVariable("Drivers."+that.DriverName+".Telegram"); //Msg string will be "7F F2 FA 00 01 00 BD 67 FA FF FE 06 87 0D" IR.Log("Driver: Msg = "+ that.Msg); that.device.Send([that.Msg]); });
var value = parseInt("FF", 16);
for(var cnt=0;cnt { partMSG=telegram.substring(cnt,cnt+2); partTel = parseInt(partMSG, 16); that.device.Send([partTel]); }
IR.GetDevice("DEVICE").Send(['GET,getverion\r\n HTTP 1.1', '\r\n\r\n']); IR.GetDevice("DEVICE").Send(['PUT,getverion\r\n HTTP 1.1', '\r\n\r\n']); IR.GetDevice("DEVICE").Send(['POST,getverion\r\n HTTP 1.1', '\r\n\r\n']);
Device.Send(['GET,/data/path/data.xml,']);use "," for end of string
/***** online notification ****/ IR.AddListener(IR.EVENT_OFFLINE, IR.GetDevice("My Driver"), function() { IR.GetItem("Page 1").GetItem("Item 1").Text = IR.GetVariable("System.Time.24") + " System Offline"; // notification IR.GetItem("Page 1").GetItem("Item 1").GetState(0).TextColor = 0xFF0000FF; // text color });3. Automatic opening of the popup when activating a channel
/***** event notification (Tag Change) ****/ var old_value1 = -1; // do not show notification if the previous state is the same var old_value2 = -1; IR.AddListener(IR.EVENT_START, 0, function() { IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetDevice("My Driver"), function(name, value) { if (name == 'Channel 10' && value == 1 && value != old_value1){ // Check the Value = 1 in Feedback "Channel 10" IR.ShowPopup("Notify_danger"); IR.GetItem("Popup 1").GetItem("Item_Display").Text = IR.GetVariable("System.Time.24") + " Lamp in Garden broken"; old_value1 = value; } else if (name == 'Channel 10' && value == 2 && value != old_value2){ // Check the feedback "Channel 10'" IR.ShowPopup("Notify_important"); IR.GetItem("Popup 1").GetItem("Item_Display").Text = IR.GetVariable("System.Time.24") + " Lamp in Garden Response Failed. Please Check"; old_value2 = value; } });4. Play a sound at channel activation
/***** event notification (Tag Change) ****/ IR.AddListener(IR.EVENT_START, 0, function() { IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetDevice("My Driver"), function(name, value) { if (name == 'Channel 11' && value == 1){ // Check the Value = 1 in Feedback "Channel 11" IR.PlaySound('BEEP1.WAV',1,70); // Play Sound ('name',slot,volume) IR.GetItem("Page 1").GetItem("Item 5").Text = IR.GetVariable("System.Time.24") + " Incoming Call"; } });
Hi everybody,
I decided to write this post as I haven't found any clear solutions for the tasks I met. Writing a driver for Autonomic Mirage Media Server (MMS) I faced the necessity to provide a good way for the user to manage content of the media server so that the user could find and select the media to include into 'now playing' list. Imagine the following situation. A user wants to find a content to play by genre. I want to show on the popup both the list of genres as well as the list of albums related to the selected genre. Once the user choose a specific album, I want to show both the list of albums, related to the selected genre, as well as the list of songs within the selected album. Of course there are a number of ways how to organize that but I didn't want to have a mess of popups and I wanted the user to clearly understand the 'chain'.
Thus I decided to do the following. A created a popup with a static list of 'list' popups. At once only two 'list' popups are visible. Once the user chooses the item in the left list within the 'list' popup, I scroll the static list so that the right 'list' popup becomes the left one and the third 'list' popup becomes visible... I didn't use the practice to populate a single list with different data as in a real life so called 'list popups' will have completely different layout.
One more thing to be mentioned: I wanted to distinguish a single tap on the list item from a double tap and do different things. For instance I wanted to show special popup on the double tap on the item so that the user could choose whether to play the album/song immediately or just add it to the playlist.
In the attached project there are both technics are shown. Probably there is an easier way to do the same or I reinvented the wheel...
Vladimir Makarov