/*! phoscon-app 2024-10-07 */

function sensorsSync(method,collection,options){return Backbone.sync(method,collection,options)}function filterByTypes(obj,objtypes){for(let i=0;i<objtypes.length;i++){var elementType=objtypes[i];if(obj.type==elementType)return!0}return!1}function parseSensors(response,options){const arr=[];for(let i in response)filterByTypes(response[i],["ZHASwitch","ZHALightLevel","ZHAPresence","ZHATemperature","CLIPPresence"])&&(response[i].id=i,arr.push(response[i]));return _.map(arr,function(sensor,sid){return sensor.manufacturername=sensor.manufacturername||"Unknown",sensor})}function parsePirControlResource(response,options){const arr=[];for(i in console.log("parsing"),response)filterByClassID(response[i],[3030])&&(console.log(response[i]),response[i].id=i,arr.push(response[i]));return arr}var sensorModel=Backbone.Model.extend({sync:sensorSync,url:function(){return this.id?"//"+app.session.gw+"/api/"+app.apikey+"/sensors/"+this.id:"//"+app.session.gw+"/api/"+app.apikey+"/sensors"}}),Sensor_Collection=Backbone.Collection.extend({model:sensorModel,url:"//"+app.session.gw+"/api/"+app.apikey+"/sensors/",parse:parseSensors,sync:sensorsSync}),pirControlResource=Backbone.Model.extend({validate:function(attrs){return attrs.classid?attrs.links?void 0:"Links missing":"ClassID missing"}}),PirControlResources=Backbone.Collection.extend({model:pirControlResource,url:"//"+app.session.gw+"/api/"+app.apikey+"/resourcelinks",parse:parsePirControlResource});function loadControlInfo(sensiControls,sensors){return new Promise((resolve,reject)=>{restGetResource(sensiControls).then(rsp=>{console.log("loaded one"),restGetResource(sensors).then(rsp2=>{console.log("loaded two"),resolve(1)}).catch(err2=>{reject(-1)})}).catch(err=>{reject(-1)})})}