From 8f9d0fceada77e12ba7cadead809317ef4f4b85c Mon Sep 17 00:00:00 2001 From: imbrianj Date: Sat, 31 Dec 2016 02:53:03 -0800 Subject: [PATCH] Prevent recursive device calls for hallLightHome. Fix bad object prop in smartthingsModeChange --- apps/hallLightHome.js | 13 +++++++++---- apps/smartthingsModeChange.js | 2 +- cache/version.txt | 2 +- js/combo.min.js | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/hallLightHome.js b/apps/hallLightHome.js index 7360af8..0b1df3e 100644 --- a/apps/hallLightHome.js +++ b/apps/hallLightHome.js @@ -31,9 +31,9 @@ module.exports = (function () { 'use strict'; return { - version : 20161101, + version : 20161231, - lastEvents : { presence : 0, open : 0 }, + lastEvents : { acted : 0, presence : 0, open : 0 }, hallLightHome : function (deviceId, command, controllers, values, config) { var deviceState = require(__dirname + '/../lib/deviceState'), @@ -68,7 +68,7 @@ module.exports = (function () { this.lastEvents.open = now; } - if ((now < delay + this.lastEvents.presence) && (now < delay + this.lastEvents.open)) { + if ((now > delay + this.lastEvents.acted) && (now < delay + this.lastEvents.presence) && (now < delay + this.lastEvents.open)) { if (config.macro) { for (macro in rawMacro) { if (rawMacro.hasOwnProperty(macro)) { @@ -88,12 +88,17 @@ module.exports = (function () { case 'raspberryRemote' : currentDeviceState = deviceState.getDeviceState(currDevice); break; + + default : + currentDeviceState = null; } if ((currentDeviceState.value) && (currentDeviceState.value.devices)) { for (subdevice in currentDeviceState.value.devices) { if (config.action.indexOf(currentDeviceState.value.devices[subdevice].label) !== -1) { - runCommand.runCommand(currDevice, 'subdevice-' + currentDeviceState.value.devices[subdevice].label + '-on'); + this.lastEvents.acted = now; + + runCommand.runCommand(currDevice, 'subdevice-' + currentDeviceState.value.devices[subdevice].label + '-on', currDevice); } } } diff --git a/apps/smartthingsModeChange.js b/apps/smartthingsModeChange.js index bb2fe74..c186682 100644 --- a/apps/smartthingsModeChange.js +++ b/apps/smartthingsModeChange.js @@ -60,7 +60,7 @@ module.exports = (function () { // If you have a macro assigned to this specific Mode, we'll act // upon it. - if (config[SmartthingsMode[deviceId]]) { + if (config[newMode]) { runCommand = require(__dirname + '/../lib/runCommand'); rawMacro = config[newMode].split(';'); diff --git a/cache/version.txt b/cache/version.txt index 47a7032..aa2bd79 100644 --- a/cache/version.txt +++ b/cache/version.txt @@ -1 +1 @@ -1483166364855 \ No newline at end of file +1483181551680 \ No newline at end of file diff --git a/js/combo.min.js b/js/combo.min.js index 556721e..88de3c1 100644 --- a/js/combo.min.js +++ b/js/combo.min.js @@ -1,3 +1,3 @@ -/* 20161230 */ +/* 20161231 */ SB=function(){"use strict";return{version:20160329,cancelBubble:function(a){a=a||window.event,a.cancelBubble=!0,a.stopPropagation&&a.stopPropagation()},isChildOf:function(a,b){if(b===a)return!1;for(;a&&a!==b&&a!==document.body;)a=a.parentNode;return a===b},event:{list:[],add:function(a,b,c,d){d=d||!1,a.addEventListener?a.addEventListener(b,c,d):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c,SB.event.list.push([a,b,c])},remove:function(a,b,c,d){d=d||!1;var e=0;for(a.removeEventListener?a.removeEventListener(b,c,d):a.detachEvent?a.detachEvent("on"+b,c):a["on"+b]=null,e;e=0;b-=1)SB.event.list[b]&&(SB.event.list[b][0]!==a&&a!==document||SB.event.remove(SB.event.list[b][0],SB.event.list[b][1],SB.event.list[b][2]))}},getTarget:function(a){return a=a||window.event,a.target?a.target:a.srcElement},hasAttribute:function(a,b,c){if(a[b])return!!a[b].match(new RegExp("(\\s|^)"+c+"(\\s|$)"))},hasClass:function(a,b){var c=!1;return a&&a.className&&(c=!!SB.hasAttribute(a,"className",b)),c},addClass:function(a,b){a&&b&&(SB.hasClass(a,b)||(a.className=SB.trim(a.className+" "+b)))},removeClass:function(a,b){SB.hasClass(a,b)&&(a.className=a.className.replace(new RegExp("(\\s|^)"+b+"(\\s|$)")," "),a.className=SB.trim(a.className))},toggleClass:function(a,b){SB.hasClass(a,b)?SB.removeClass(a,b):SB.addClass(a,b)},setFocus:function(a){"function"==typeof a.setActive?a.setActive():"function"==typeof a.focus&&a.focus()},get:function(a){return document.getElementById(a)},getByTag:function(a,b){return b=b||document,b.getElementsByTagName(a)},getByClass:function(a,b,c){var d=[],e=[],f=0,g=0;if(b=b||document,c=c.toLowerCase()||"*","*"===c&&document.getElementsByClassName)return b.getElementsByClassName(a);if(b.getElementsByClassName)if(e=b.getElementsByClassName(a),c&&e.length)for(f in e)e[f].tagName&&e[f].tagName.toLowerCase()===c&&(d[g]=e[f],g+=1);else d=e;else{e=SB.getByTag(c,b);for(f in e)SB.hasClass(e[f],a)&&(d[g]=e[f],g+=1)}return d},getText:function(a){return a.textContent?a.textContent:a.innerText?a.innerText:a.text?a.text:a.innerHTML},putText:function(a,b){a.textContent?a.textContent=b:a.innerText?a.innerText=b:a.text?a.text=b:a.innerHTML=b},stripUnits:function(a){var b="";return b="string"==typeof a?parseInt(a.replace(new RegExp("(%|px|em)"),""),10):a},trim:function(a){return a=a||"",a.toString().replace(/^\s\s*/,"").replace(/\s\s*$/,"")},replaceAll:function(a,b,c){var d=a;return"string"==typeof a&&(d=a.replace(new RegExp(b,"g"),c)),d},decode:function(a){var b="";return"object"==typeof JSON&&(b=JSON.parse(a)),b},encode:function(a){var b="";return"object"==typeof JSON&&(b=JSON.stringify(a)),b},log:function(a,b,c){var d=new Date,e="color: white";if("object"==typeof console&&"function"==typeof console.log)if(b&&"object"!=typeof a){switch(a="%c"+b+"%c: "+a+" ("+d.getHours()+":"+(d.getMinutes()<10?"0":"")+d.getMinutes()+")",c){case"success":e="color: green";break;case"info":e="color: aqua";break;case"error":e="color: red"}console.log(a,"background: black; "+e,"background: black; color: white")}else console.log(a)},vibrate:function(a){a=a||20,window.navigator&&window.navigator.vibrate?window.navigator.vibrate(a):SB.log("Not supported","Vibrate","error")},notify:function(a,b,c){var d,e;return"function"==typeof Notification&&("granted"===Notification.permission?(d=new Notification(a,b),setTimeout(function(){d.close(),SB.event.remove(d,"click",e)},1e4),e=function(a){window.focus(),c(a),SB.event.remove(d,"click",e)},SB.event.add(d,"click",e)):SB.notifyAsk()),d},notifyAsk:function(){"function"==typeof Notification&&"denied"!==Notification.permission&&Notification.requestPermission(function(a){Notification.permission!==a&&(Notification.permission=a)})},sound:{sounds:{},play:function(a){"function"==typeof Audio&&(SB.sound.sounds[a]||(SB.sound.sounds[a]=new Audio(a)),SB.sound.sounds[a].play())}},speak:function(a,b,c){var d,e;window.speechSynthesis?(d=new SpeechSynthesisUtterance,e=window.speechSynthesis.getVoices(),d.text=a,d.lang=b||"en-US",e&&e[10]&&"Alex"===e[10].name&&(d.voice=e[10],"female"===c&&(d.voice=e[30])),window.speechSynthesis.speak(d)):SB.log("Not supported","Speak","error")},transcribe:function(a){var b,c;return"webkitSpeechRecognition"in window?(SB.log("Supported","Transcribe","info"),b=new webkitSpeechRecognition,c=function(b){a(b.results[0][0].transcript,b.results[0][0].confidence),SB.event.remove(document,"result",c)},SB.event.add(b,"result",c)):SB.log("Not supported","Transcribe","error"),b},storage:function(a,b){var c;return a&&("undefined"!=typeof localStorage?(void 0!==b&&("object"==typeof b&&(b=SB.encode(b)),localStorage.setItem(a,b)),c=localStorage.getItem(a)):SB.log("Not supported","Local Storage","error")),c},ajax:{request:function(a){a.method=a.method||"GET",a.onStart=a.onStart||function(){},a.onComplete=a.onComplete||function(){};var b,c,d="?";if(c=function(){switch(a.onStart(),typeof a.onComplete){case"object":a.onComplete.value?a.onComplete.value=a.response:a.onComplete.childNodes[0]&&SB.putText(a.onComplete,a.response);break;case"function":a.onComplete()}},window.XMLHttpRequest)b=new XMLHttpRequest;else{if(!window.ActiveXObject)return!1;b=new ActiveXObject("Microsoft.XMLHTTP")}"GET"===a.method&&(a.path.indexOf("?")===-1&&a.param.indexOf("?")===-1||(d="&"),a.path=a.path+d+a.param,a.param=""),b.open(a.method.toUpperCase(),a.path,!0),"POST"===a.method&&b.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),b.setRequestHeader("rest","true"),SB.event.add(b,"readystatechange",function(){if(4===b.readyState){if(200!==b.status)return!1;a.response=b.responseText,c()}}),b.send(a.param)}},init:function(){SB.spec&&SB.spec.init&&SB.spec.init(),SB.addClass(document.body,"rich")}}}(),document.addEventListener&&document.addEventListener("DOMContentLoaded",SB.init,!1),SB.event.add(window,"load",function(){"use strict";document.addEventListener||SB.init()}),SB.event.add(window,"unload",function(){"use strict";SB.event.removeAll()}),"object"==typeof module&&(module.exports=SB),SB.spec=function(){"use strict";return{version:20161230,state:{},parsers:{},templates:{},strings:{},socket:{},uiComponents:{header:{},body:{},indicator:{},templates:[]},ariaDevice:function(){var a=SB.getByClass("selected",SB.spec.uiComponents.header,"li")[0],b=SB.getByTag("h2",SB.spec.uiComponents.header)[0],c=SB.spec.strings.CURRENT.split("{{DEVICE}}").join(SB.getText(a));SB.putText(b,c)},navChange:function(a){var b=SB.getByClass(a,SB.spec.uiComponents.header,"li")[0],c=SB.get(a),d=SB.getByClass("selected",SB.spec.uiComponents.header,"li")[0],e=SB.getByClass("selected",SB.spec.uiComponents.body,"section")[0];b&&!SB.hasClass(b,"selected")&&(SB.removeClass(d,"selected"),SB.removeClass(e,"selected"),SB.spec.lazyLoad(a),SB.storage("selected",a),SB.addClass(b,"selected"),SB.addClass(c,"selected"),SB.spec.lazyUnLoad(e),SB.spec.ariaDevice())},updateTemplate:function(a){var b,c,d,e,f=SB.get(a.deviceId),g=SB.spec.parsers[a.typeClass],h=a.value,i=a.state,j=document.createElement("div");SB.spec.state[a.deviceId]=a,SB.log("Updated",a.deviceId,"success"),f&&(d=SB.spec.uiComponents.templates[a.typeClass].markup,c=SB.hasClass(f,"selected")?" selected":"",e=f.cloneNode(!0),b=SB.getByTag("h1",e)[0],b.parentNode.removeChild(b),e=e.innerHTML,g&&(d=g(a.deviceId,d,i,h,SB.spec.uiComponents.templates[a.typeClass].fragments)),"ok"===i?(d=d.split("{{DEVICE_ACTIVE}}").join(SB.spec.strings.ACTIVE),SB.hasClass(f,"device-off")&&(SB.removeClass(f,"device-off"),SB.addClass(f,"device-on"),SB.putText(SB.getByTag("em",SB.getByTag("h1",f)[0])[0],SB.spec.strings.ACTIVE))):(d=d.split("{{DEVICE_ACTIVE}}").join(SB.spec.strings.INACTIVE),SB.hasClass(f,"device-on")&&(SB.removeClass(f,"device-on"),SB.addClass(f,"device-off"),SB.putText(SB.getByTag("em",SB.getByTag("h1",f)[0])[0],SB.spec.strings.INACTIVE))),f&&d&&a&&(SB.storage("state",SB.spec.state),d=d.split("{{DEVICE_ID}}").join(a.deviceId),d=d.split("{{DEVICE_TYPE}}").join(a.typeClass),d=d.split("{{DEVICE_SELECTED}}").join(c),d="ok"===a.state?d.split("{{DEVICE_STATE}}").join(" device-on"):d.split("{{DEVICE_STATE}}").join(" device-off"),d=c?d.split("{{LAZY_LOAD_IMAGE}}").join("src"):d.split("{{LAZY_LOAD_IMAGE}}").join("data-src")),d&&(j.innerHTML=d,j=SB.getByTag("section",j)[0],b=SB.getByTag("h1",j)[0],b.parentNode.removeChild(b),j.innerHTML!==e&&(f.outerHTML=d)))},buildIndicator:function(){var a;SB.get("indicator")||(a=document.createElement("span"),a.id="indicator",SB.addClass(a,"connecting"),SB.putText(a,SB.spec.strings.CONNECTING),SB.spec.uiComponents.indicator=a,SB.spec.uiComponents.header.appendChild(a))},checkConnection:function(){var a=SB.spec.socket.readyState<=1;return a||(SB.spec.socketConnect(0),a=SB.spec.socket.readyState<=1),a},socketConnect:function(a){var b,c,d,e,f,g,h="https:"===window.location.protocol?"wss":"ws";SB.spec.socket.readyState&&3!==SB.spec.socket.readyState||(SB.log("Connecting","WebSocket","info"),SB.spec.socket=new WebSocket(h+"://"+window.location.host,"echo-protocol"),a+=1,b=function(){var b=Math.round(Math.min(Math.max(a*(15*Math.random()),10),60));SB.log("Retrying in "+b+"s","WebSocket","info"),SB.spec.uiComponents.indicator.className="disconnected",SB.putText(SB.spec.uiComponents.indicator,SB.spec.strings.DISCONNECTED),setTimeout(function(){SB.spec.socketConnect(a)},1e3*b)}),c=function(){var a="disconnected"===SB.spec.uiComponents.indicator.className;SB.spec.uiComponents.indicator.className="connected",SB.putText(SB.spec.uiComponents.indicator,SB.spec.strings.CONNECTED),SB.log("Connected","WebSocket","success"),a&&(SB.spec.socket.send("fetch state"),SB.log("Reconnected","WebSocket","success")),SB.event.add(SB.spec.socket,"close",f)},d=function(a){var b,c,d=SB.decode(a.data),e={};if("string"==typeof d.speech)d.speech&&(SB.log(d.speech,"Speech","success"),SB.speak(d.speech,d.language,d.voice));else if("string"==typeof d.sound)SB.log(d.sound,"Sound","success"),SB.sound.play("/mp3/"+d.sound+".mp3");else if("string"==typeof d.vibrate)SB.log(d.vibrate,"Vibrate","success"),SB.vibrate(100*d.vibrate);else if("string"==typeof d.title)c=function(){d.deviceId&&SB.spec.navChange(d.deviceId)},b=SB.notify(d.title,d.options,c);else if("string"==typeof d.deviceId)SB.spec.updateTemplate(d);else if("object"==typeof d){for(e in d)if(d.hasOwnProperty(e))break;if(d[e]&&d[e].deviceId){SB.log("Received","State","success");for(e in d)d.hasOwnProperty(e)&&SB.spec.updateTemplate(d[e])}else d[e]&&d[e].markup&&(SB.spec.uiComponents.templates=d,SB.storage("templates",SB.spec.uiComponents.templates))}},f=function(){SB.event.remove(SB.spec.socket,"close",f),SB.log("Disconnected","WebSocket","error"),b()},e=function(){SB.event.remove(SB.spec.socket,"error",f),SB.log("Error","WebSocket","error"),b()},g=function(){SB.event.remove(SB.spec.socket,"open",c),SB.event.remove(SB.spec.socket,"message",d),SB.event.remove(SB.spec.socket,"error",e),SB.event.remove(SB.spec.socket,"close",g)},SB.event.add(SB.spec.socket,"open",c),SB.event.add(SB.spec.socket,"message",d),SB.event.add(SB.spec.socket,"error",e),SB.event.add(SB.spec.socket,"close",g)},statePoller:function(){var a;SB.log("not supported - using polling","WebSockets","error"),a={path:"/templates/",param:"ts="+(new Date).getTime(),method:"GET",onComplete:function(){SB.spec.uiComponents.templates=SB.decode(a.response),SB.storage("templates",SB.spec.uiComponents.templates)}},SB.ajax.request(a),setInterval(function(){var a={path:"/state/",param:"ts="+(new Date).getTime(),method:"GET",onComplete:function(){var b,c=SB.decode(a.response);if(c){SB.spec.uiComponents.indicator.className="connected",SB.putText(SB.spec.uiComponents.indicator,SB.spec.strings.CONNECTED),setTimeout(function(){SB.spec.uiComponents.indicator.className="connecting",SB.putText(SB.spec.uiComponents.indicator,SB.spec.strings.CONNECTIG)},1e3);for(b in c)c.hasOwnProperty(b)&&SB.spec.updateTemplate(c[b])}else SB.spec.uiComponents.indicator.className="disconnected",SB.putText(SB.spec.uiComponents.indicator,SB.spec.strings.DISCONNECTED)}};SB.ajax.request(a)},1e4)},lazyLoad:function(a){var b,c,d,e,f=0;if(SB.get(a))for(b=SB.get(a),c=Array.prototype.slice.call(SB.getByTag("img",b)),d=Array.prototype.slice.call(SB.getByTag("iframe",b)),e=c.concat(d),f;f3&&(d=650),c>10&&(d=500),c+=1,setTimeout(q,d))},r=function(a,c){var d,e=p(a);c?(SB.vibrate(),b=SB.getTarget(a).parentNode.parentNode.id,l=SB.transcribe(o),l.start()):e&&!g&&("external"===e.rel?(d=window.open(),d.opener=null,d.location=e.href):SB.hasClass(e,"modal")?SB.spec.openModal(e):SB.hasClass(e,"close-modal")||SB.hasClass(e,"curtain")?SB.spec.closeModal(e):(b=e.href,q()))};"ontouchstart"in document.documentElement&&(SB.log("Enabled","Touch Events","info"),SB.event.add(SB.spec.uiComponents.body,"touchstart",function(a){e=!0,f=!0,h=!1,p(a)&&(g=!1,i=parseInt(a.changedTouches[0].clientX,10),j=parseInt(a.changedTouches[0].clientY,10),setTimeout(function(){h||(e=!1,r(a))},m))}),SB.event.add(SB.spec.uiComponents.body,"contextmenu",function(a){a.preventDefault()}),SB.event.add(SB.spec.uiComponents.body,"touchend",function(a){!SB.hasClass(SB.getTarget(a).parentNode,"emoji")&&e&&(h=!0,r(a)),n(a)}),SB.event.add(SB.spec.uiComponents.body,"touchmove",function(a){f&&(Math.abs(parseInt(a.changedTouches[0].clientX,10)-i)>k||Math.abs(parseInt(a.changedTouches[0].clientY,10)-j)>k)&&n(a)}),SB.event.add(SB.spec.uiComponents.body,"touchcancel",function(a){n(a)})),SB.event.add(SB.spec.uiComponents.body,"mousedown",function(a){SB.hasClass(SB.getTarget(a).parentNode,"emoji")?r(a,!0):f===!1&&e===!1&&(g=!1,r(a)),e=!1}),SB.event.add(SB.spec.uiComponents.body,"mouseup",function(a){SB.hasClass(SB.getTarget(a).parentNode,"emoji")||n(a)}),SB.event.add(SB.spec.uiComponents.body,"click",function(a){p(a)&&a.preventDefault()}),SB.event.add(SB.spec.uiComponents.body,"keyup",function(a){13===a.keyCode&&p(a)&&(g=!1,r(a),setTimeout(function(){g=!0},d/2))})},sendInput:function(a){var b=SB.getByTag("input",a,"input")[0],c=b.value,d=b.name,e=SB.getByClass("input-type",a,"input")[0].value;"text"===b.type&&(b.value=""),SB.spec.sendTextInput(c,d,e)},sendTextInput:function(a,b,c){var d,e=(new Date).getTime();c=c||"text",SB.spec.socket?SB.spec.checkConnection()&&(SB.log("Issued","Text Command","success"),SB.spec.socket.send("/?"+b+"="+c+"-"+a)):(d={path:"/",param:b+"="+c+"-"+a+"&ts="+e,method:"POST",onComplete:function(){SB.log(d.response)}},SB.ajax.request(d))},formInput:function(a){SB.event.add(SB.spec.uiComponents.body,"submit",function(b){var c=SB.getTarget(b);b.preventDefault(),a?SB.log("Issued","Demo Text Command","success"):SB.spec.sendInput(c)}),SB.event.add(SB.spec.uiComponents.body,"change",function(b){var c,d,e=SB.getTarget(b),f=e.type;("range"===f||"number"===f&&void 0!==e.max&&void 0!==e.min)&&("range"===f?(d=e.previousElementSibling,"number"===d.type&&(d.value=e.value)):"number"===f&&(c=e.nextElementSibling,"range"===c.type&&(c.value=e.value)),a?SB.log("Issued","Demo Form Command","success"):SB.spec.sendInput(e.form))})},nav:function(){SB.event.add(SB.spec.uiComponents.header,"click",function(a){var b=SB.getTarget(a).parentNode,c=b.tagName.toLowerCase();"li"===c?(a.preventDefault(),SB.spec.navChange(b.className),SB.vibrate(),SB.notifyAsk()):"indicator"===SB.getTarget(a).id&&SB.hasClass(SB.getTarget(a),"disconnected")&&SB.spec.socketConnect(0)})},init:function(){var a,b,c,d=!1,e=SB.storage("selected"),f=SB.storage("templates"),g=SB.storage("state");if(SB.spec.uiComponents.header=SB.getByTag("header")[0],SB.spec.uiComponents.body=SB.getByTag("main")[0],SB.spec.buildIndicator(),b=SB.spec.uiComponents.header.dataset,c=SB.spec.uiComponents.body.dataset,SB.spec.strings={CURRENT:b.stringCurrent,CONNECTED:b.stringConnected,CONNECTING:b.stringConnecting,DISCONNECTED:b.stringDisconnected,ACTIVE:c.stringActive,INACTIVE:c.stringInactive,ON:c.stringOn,OFF:c.stringOff,CLOSE:c.stringClose,AM:c.stringAm,PM:c.stringPm,SUN:c.stringSun,MON:c.stringMon,TUE:c.stringTue,WED:c.stringWed,THUR:c.stringThur,FRI:c.stringFri,SAT:c.stringSat},e&&SB.spec.navChange(e),f&&g){SB.spec.uiComponents.templates=SB.decode(f),g=SB.decode(g);for(a in g)g.hasOwnProperty(a)&&SB.spec.updateTemplate(g[a])}d||("function"==typeof WebSocket||"object"==typeof WebSocket?SB.spec.socketConnect(0):SB.spec.statePoller()),SB.spec.lazyLoad(e||document.body.className),SB.spec.command(d),SB.spec.formInput(d),SB.spec.nav(),SB.spec.ariaDevice()}}}(),function(a){"use strict";a.activeBuilding=function(a,b,c,d,e){var f="",g="",h="",i="",j=function(a){var b;return"object"==typeof SB&&"object"==typeof SB.util?a=SB.util.translate(a,"activeBuilding"):(b=require(__dirname+"/../../lib/sharedUtil").util,a=b.translate(a,"activeBuilding",e)),a},k=function(a){var b,c="";return"object"==typeof SB&&"object"==typeof SB.util?c=SB.util.arrayList(a,"activeBuilding",e):(b=require(__dirname+"/../../lib/sharedUtil").util,c=b.arrayList(a,"activeBuilding",e)),c};return c&&d&&(i=k(d)),d&&0!==d.length?1===d.length?(g="ok",h="tag",f=j("SINGLE_PACKAGE")):d.length>1&&(g="ok",h="tags",f=j("PLURAL_PACKAGES")):(g="err",h="times",f=j("NO_PACKAGES")),f=f.split("{{SENDERS}}").join(i),b=b.replace("{{ACTIVEBUILDING_STATE}}",g),b=b.replace("{{ACTIVEBUILDING_ICON}}",h),b=b.replace("{{ACTIVEBUILDING_DYNAMIC}}",f)}}("undefined"==typeof exports?this.SB.spec.parsers:exports),function(a){"use strict";a.debug=function(a,b,c,d,e,f){var g=(new Date).getTime(),h="",i="",j=0,k=0,l=0,m=0,n=0,o=function(a){var b;return"object"==typeof SB&&"object"==typeof SB.util?a=SB.util.translate(a,"debug"):(b=require(__dirname+"/../../lib/sharedUtil").util,a=b.translate(a,"debug",f)),a},p=function(a){var b,c;return"object"==typeof SB&&"object"==typeof SB.util?c=SB.util.displayTime(a,o):(b=require(__dirname+"/../../lib/sharedUtil").util,c=b.displayTime(a,o)),c},q=function(a){var b,c;return"object"==typeof SB&&"object"==typeof SB.util?c=SB.util.displayRelativeTime(a):(b=require(__dirname+"/../../lib/sharedUtil").util,c=b.displayRelativeTime(a)),c},r=o("NA");return d&&(h=q(d.uptime),i=q((g-d.startup)/1e3),j=d.memoryUsed,k=d.totalMemory,l=d.percentMemory,m=Math.round(100*d.cpuLoad[0]),n=d.clientCount,r=d.temperature?d.temperature:r),b=b.replace("{{DEBUG_UPDATE}}",p(g)),b=b.replace("{{DEBUG_UPTIME}}",h),b=b.replace("{{DEBUG_RUNTIME}}",i),b=b.replace("{{DEBUG_MEMORY_USED}}",j),b=b.replace("{{DEBUG_SYSTEM_MEMORY}}",k),b=b.replace("{{DEBUG_MEMORY_PERCENT}}",l),b=b.replace("{{DEBUG_CPU}}",m),b=b.replace("{{DEBUG_CLIENT_TEMP}}",r),b=b.replace("{{DEBUG_CLIENT_COUNT}}",n)}}("undefined"==typeof exports?this.SB.spec.parsers:exports),function(a){"use strict";a.denon=function(a,b,c,d){return d&&(b=b.split("{{DEVICE_POWER}}").join(d.power),d.ZONE1&&(b=b.split("{{DEVICE_Z1_INPUT}}").join(d.ZONE1.input),b=b.split("{{DEVICE_Z1_POWER}}").join(d.ZONE1.power),b=b.split("{{DEVICE_Z1_MUTE}}").join(d.ZONE1.mute),b=b.split("{{DEVICE_Z1_MODE}}").join(d.ZONE1.mode),b=b.split("{{DEVICE_Z1_VOLUME}}").join(d.ZONE1.volume),b=b.split("{{DEVICE_Z1_MAXVOLUME}}").join(d.ZONE1.maxvolume)),d.ZONE2&&(b=b.split("{{DEVICE_Z2_POWER}}").join(d.ZONE2.power),b=b.split("{{DEVICE_Z2_INPUT}}").join(d.ZONE2.input),b=b.split("{{DEVICE_Z2_VOLUME}}").join(d.ZONE2.volume)),d.ZONE3&&(b=b.split("{{DEVICE_Z3_POWER}}").join(d.ZONE3.power),b=b.split("{{DEVICE_Z3_INPUT}}").join(d.ZONE3.input),b=b.split("{{DEVICE_Z3_VOLUME}}").join(d.ZONE3.volume))),b=b.split("{{DEVICE_POWER}}").join(""),b=b.split("{{DEVICE_Z1_POWER}}").join(""),b=b.split("{{DEVICE_Z1_INPUT}}").join(""),b=b.split("{{DEVICE_Z1_MUTE}}").join(""),b=b.split("{{DEVICE_Z1_MODE}}").join(""),b=b.split("{{DEVICE_Z1_VOLUME}}").join(""),b=b.split("{{DEVICE_Z1_MAXVOLUME}}").join(""),b=b.split("{{DEVICE_Z2_POWER}}").join(""),b=b.split("{{DEVICE_Z2_INPUT}}").join(""),b=b.split("{{DEVICE_Z2_VOLUME}}").join(""),b=b.split("{{DEVICE_Z3_POWER}}").join(""),b=b.split("{{DEVICE_Z3_INPUT}}").join(""),b=b.split("{{DEVICE_Z3_VOLUME}}").join("")}}("undefined"==typeof exports?this.SB.spec.parsers:exports),function(a){"use strict";a.foscam=function(a,b,c,d,e,f){var g,h,i,j,k,l,m,n=e.photo,o=e.photos,p=e.video,q=e.videos,r=e.thumb,s="",t="",u="",v="",w="",x=0,y=0,z=function(a){var b;return"object"==typeof SB&&"object"==typeof SB.util?a=SB.util.translate(a,"foscam"):(b=require(__dirname+"/../../lib/sharedUtil").util,a=b.translate(a,"foscam",f)),a};if(d=d||{},"on"===d.alarm?(s=" device-active",u=z("CAMERA_ARMED")):"off"===d.alarm&&(t=" device-active",u=z("CAMERA_DISARMED")),b=b.split("{{DEVICE_STATE_ON}}").join(s),b=b.split("{{DEVICE_STATE_OFF}}").join(t),b=b.split("{{ARMED_STATUS}}").join(u),b=b.split("{{DISARMED_STATUS}}").join(u),b=b.split("{{SCREENSHOT}}").join(z("SCREENSHOT")),b=b.split("{{THUMBNAIL}}").join(z("THUMBNAIL")),b=b.split("{{VIDEO}}").join(z("VIDEO")),d.photos&&d.photos.length){for(x;x]+)>)/gi,""):a},stripControl:function(a){return"string"==typeof a?a.replace(new RegExp("[\0-]+","g"),""):a},sanitize:function(b){return a.util.stripTags(a.util.stripControl(b))},encodeName:function(a){return a&&"string"==typeof a&&(a=a.replace(/[\s!@#$%^&*()"'\\<>,;.:\/+]/g,"_").toLowerCase()),a},translate:function(a,b,c){var d,e="";return a&&"string"==typeof a?(a=a.toUpperCase(),"object"==typeof SB?(c=document.documentElement.getAttribute("lang"),d=function(a,b){var c=SB.getByClass(b,SB.getByTag("main")[0],"section")[0];return a=a.replace("{{i18n_","").replace("}}",""),c.dataset&&c.dataset["string"+a.charAt(0)+a.substr(1).toLowerCase()]?a=c.dataset["string"+a.charAt(0)+a.substr(1).toLowerCase()]:SB.spec.strings[a]&&(a=SB.spec.strings[a]),a}):d=require(__dirname+"/translate").translate,e=d("{{i18n_"+a+"}}",b,c)):e=a,e},arrayList:function(b,c,d){var e="",f=0;for(f;f=c[b]&&(d[b]=Math.floor(a/c[b]),d[b]<10&&(d[b]="0"+d[b]),a-=d[b]*c[b]);return d.day+" "+d.hour+":"+d.minute+":"+d.second},displayTime:function(a,b,c,d){var e=d||new Date(a),f=e.getDate(),g=e.getDay(),h={0:"sun",1:"mon",2:"tue",3:"wed",4:"thur",5:"fri",6:"sat"},i=e.getHours(),j=e.getMinutes(),k=b("am"),l="";switch(i>12&&(i-=12,k=b("pm")),i=0===i?12:i,j<10&&(j="0"+j),g=b(h[g]),c){case"long":l=g+" "+f+" @ "+i+":"+j+k;break;default:l=g+" @ "+i+":"+j+k}return l}}}("undefined"==typeof exports?this.SB:exports); \ No newline at end of file