From 7b38aea09c2e7ab053fcb093be42918807c0a7ea Mon Sep 17 00:00:00 2001 From: jemu75 Date: Wed, 31 Mar 2021 23:23:30 +0200 Subject: [PATCH] V3.4.0 --- README.md | 11 ++++++++++- src/App.vue | 2 +- src/plugins/fhem.js | 16 ++++++++++++---- www/fhemapp/index.html | 2 +- www/fhemapp/js/app.4e070eed.js | 1 - www/fhemapp/js/app.bc387fd0.js | 1 + 6 files changed, 25 insertions(+), 8 deletions(-) delete mode 100644 www/fhemapp/js/app.4e070eed.js create mode 100644 www/fhemapp/js/app.bc387fd0.js diff --git a/README.md b/README.md index 158cbeb3..8609f2e9 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ Das Attribut `appOptions` kann mit unterschiedlichen Parametern befüllt werden, "name": "string", - kann alternativ zum FHEM-Attribut 'alias' verwendet werden "room": "string", - kann alternativ zum FHEM-Attribut 'room' verwendet werden "group": "string", - kann alternativ zum FHEM-Attribut 'group' verwendet werden + "sortby": "string", - kann alternativ zum FHEM-Attribut 'sortby' verwendet werden "home": "true", - zeigt ein Device auf der Startseite an "dashboard": "true", - zeigt ein Device im Dashboard an "system": "true", - zeigt ein Device in den Systemeinstellungen an @@ -119,7 +120,15 @@ Das Attribut `appOptions` kann mit unterschiedlichen Parametern befüllt werden, Damit ein Gerät in der **FHEMApp** zur Verfügung steht, müsst ihr dem jeweiligen Device in FHEM einem *Template* zuordnen. In der **FHEMApp** stehen verschiedene [Templates](#übersicht-der-verfügbaren-templates) zur Verfügung. Dazu nutzt ihr das FHEM-Attribut `appOptions` und definiert ein *Template* über folgenden Parameter `{ "template": "switch" }` (Beispiel für einen Schalter) ### weitere FHEM Attribute verwenden -Nachdem ihr dem Device ein *Template* zugeordnet habt, könnt ihr defnieren unter welchem *Name* und in welchen *Menüpunkten* euer Device in **FHEMApp** angezeigt wird. Dazu nutzt ihr das FHEM-Attribut `alias` für den Name des Gerätes, das FHEM-Attribut `group` für die Anzeige im Menüpunkt *Gruppen* und das FHEM-Attribut `room` für die Anzeige im Menüpunkt *Bereiche*. Alternativ können diese Parameter auch über `appOptions` [siehe](#appoptions) definiert werden, wenn ihr die FHEM-Attribute `alias`, `group` bzw `room` in eurer FHEM-Installation anderweitig verwendet. +Nachdem ihr dem Device ein *Template* zugeordnet habt, könnt ihr defnieren unter welchem *Name* und in welchen *Menüpunkten* euer Device in **FHEMApp** angezeigt wird. Dazu nutzt ihr das FHEM-Attribut `alias` für den Name des Gerätes, das FHEM-Attribut `group` für die Anzeige im Menüpunkt *Gruppen* und das FHEM-Attribut `room` für die Anzeige im Menüpunkt *Bereiche*. Weiterhin könnt ihr das FHEM-Attribut `sortby` nutzen um die Reihenfolge der Templates in **FHEMApp** festzulegen. Alternativ können diese Parameter auch über `appOptions` [siehe](#appoptions) definiert werden, wenn ihr die FHEM-Attribute `alias`, `group`, `room` oder `sortby` in eurer FHEM-Installation anderweitig verwendet. +Wenn die FHEM-Attribute `room`, `group` oder `sortby` in **FHEMApp** komplett ignoriert werden sollen, dann muss dies in der Datei `config.json` unter dem Parameter `options` wie folgt eingestellt werden. +``` + "options": { + "ignoreFhemGroup": true, + "ignoreFhemRoom": true, + "ignoreFhemSortby": true + } +``` *Definition in FHEM*
![Definition in FHEM](./docs/media/template_switch_fhem.png) diff --git a/src/App.vue b/src/App.vue index 501dff7f..c41f6fb2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -114,7 +114,7 @@ groupList: [] } }, - version: 'v3.3.6', + version: 'v3.4.0', status: { color: 'secondary', icon: 'mdi-circle', diff --git a/src/plugins/fhem.js b/src/plugins/fhem.js index 11c48b79..8aa024d9 100644 --- a/src/plugins/fhem.js +++ b/src/plugins/fhem.js @@ -25,7 +25,10 @@ export default class Fhem extends EventEmitter { maxChartPoints: 100, updateProcess: false, logRecord: true, - logBuffer: 500 + logBuffer: 500, + ignoreFhemRoom: false, + ignoreFhemGroup: false, + ignoreFhemSortby: false }, templates: [], // only the fallback for v3.1 componentMap: [], @@ -269,7 +272,11 @@ export default class Fhem extends EventEmitter { for (const item of res.Results) { let options = await this.createOptions(item, true); - let defs = options[attr] || item.Attributes[attr]; + let defs = options[attr]; + let ignoreAttr = false; + if(this.app.options.ignoreFhemRoom && attr === 'room') ignoreAttr = true; + if(this.app.options.ignoreFhemGroup && attr === 'group') ignoreAttr = true; + if(!defs && !ignoreAttr) defs = item.Attributes[attr]; if(defs && options.template) { let vals = defs.split(','); @@ -534,7 +541,8 @@ export default class Fhem extends EventEmitter { if(options) { item.Options = options; - item.Options.order = item.Attributes.sortby || 'zzz'; + if(!item.Options.sortby && !this.app.options.ignoreFhemSortby) item.Options.sortby = item.Attributes.sortby; + if(!item.Options.sortby) item.Options.sortby = 'zzz'; if(fltr.match('FILTER=group') && item.Options.group) blockItem = true; if(fltr.match('FILTER=room') && item.Options.room) blockItem =true; @@ -545,7 +553,7 @@ export default class Fhem extends EventEmitter { if(!blockItem) target.push(item); if(idx === res.Results.length) { - target.sort((a,b) => (a.Options.order > b.Options.order) ? 1 : ((b.Options.order > a.Options.order) ? -1 : 0)); + target.sort((a,b) => (a.Options.sortby > b.Options.sortby) ? 1 : ((b.Options.sortby > a.Options.sortby) ? -1 : 0)); this.app.data.deviceList = Object.assign([], target); this.app.options.loading = false } diff --git a/www/fhemapp/index.html b/www/fhemapp/index.html index 57d23295..1fd2dc46 100644 --- a/www/fhemapp/index.html +++ b/www/fhemapp/index.html @@ -1 +1 @@ -fhemapp
\ No newline at end of file +fhemapp
\ No newline at end of file diff --git a/www/fhemapp/js/app.4e070eed.js b/www/fhemapp/js/app.4e070eed.js deleted file mode 100644 index 2e7faeff..00000000 --- a/www/fhemapp/js/app.4e070eed.js +++ /dev/null @@ -1 +0,0 @@ -(function(e){function t(t){for(var a,r,o=t[0],c=t[1],u=t[2],p=0,l=[];p0?(this.type=this.msgList[0].type,this.message=this.msgList[0].message,this.meta=this.msgList[0].meta,this.alert=!0):(this.alert=!1,this.type="info",this.message="",this.meta="")}},methods:{clearMessage:function(){this.msgList.length>0&&this.msgList.splice(0,1)}},mounted:function(){var e=this;this.$fhem.on("message",(function(t){var n={type:"warning",message:"no valid message received",meta:""};Object.assign(n,t),e.msgList.unshift(n)}))}}),p=u,l=n("2877"),h=n("6544"),f=n.n(h),d=n("0798"),m=n("8336"),v=n("62ad"),g=n("132d"),b=n("0fd9"),k=Object(l["a"])(p,o,c,!1,null,null,null),y=k.exports;f()(k,{VAlert:d["a"],VBtn:m["a"],VCol:v["a"],VIcon:g["a"],VRow:b["a"]});var O={data:function(){return{drawer:null,back:!1,app:{options:{loading:!1,clock:null},session:{connect:!1},data:{roomList:[],groupList:[]}},version:"v3.3.6",status:{color:"secondary",icon:"mdi-circle",text:"unbekannt",time:""}}},components:{Broadcaster:y},watch:{"app.session.connect":function(e){this.status.color=e?"success":"error",this.status.text=e?"online":"offline",this.status.time=this.$fhem.getDateTime()},$route:function(e){this.back="/"!==e.path}},computed:{showRooms:function(){return this.app.data.roomList.length>0},showGroups:function(){return this.app.data.groupList.length>0}},methods:{loadRoutes:function(){this.app.session.connect&&(this.$fhem.getRoutes("room"),this.$fhem.getRoutes("group"))},goTo:function(){this.$router.go(-1)}},mounted:function(){var e=this;this.app.session=this.$fhem.app.session,this.app.options=this.$fhem.app.options,this.app.data=this.$fhem.app.data,this.$fhem.on("connect",(function(){return e.loadRoutes()})),this.$fhem.init(),this.loadRoutes()}},w=O,j=n("7496"),x=n("40dc"),R=n("5bc1"),L=n("cc20"),C=n("a523"),_=n("ce7e"),P=n("adda"),E=n("8860"),S=n("56b0"),D=n("da13"),V=n("5d23"),A=n("34c3"),T=n("f6c4"),N=n("f774"),F=n("a797"),$=n("490a"),I=n("2fa4"),M=n("3a2f"),H=Object(l["a"])(w,s,i,!1,null,null,null),B=H.exports;f()(H,{VApp:j["a"],VAppBar:x["a"],VAppBarNavIcon:R["a"],VBtn:m["a"],VChip:L["a"],VContainer:C["a"],VDivider:_["a"],VIcon:g["a"],VImg:P["a"],VList:E["a"],VListGroup:S["a"],VListItem:D["a"],VListItemContent:V["a"],VListItemIcon:A["a"],VListItemSubtitle:V["b"],VListItemTitle:V["c"],VMain:T["a"],VNavigationDrawer:N["a"],VOverlay:F["a"],VProgressCircular:$["a"],VSpacer:I["a"],VTooltip:M["a"]});n("3ca3"),n("ddb0");var q=n("8c4f");r["a"].use(q["a"]);var U=[{path:"/",name:"Home",component:function(){return n.e("chunk-2d212bf1").then(n.bind(null,"aa72"))}},{path:"/system",name:"System",component:function(){return n.e("chunk-2d212bf1").then(n.bind(null,"aa72"))}},{path:"/dashboard",name:"Dashboard",component:function(){return n.e("chunk-2d212bf1").then(n.bind(null,"aa72"))}},{path:"/devices/:filter",name:"Devices",component:function(){return n.e("chunk-2d212bf1").then(n.bind(null,"aa72"))}},{path:"/edit-devices",name:"EditDevice",component:function(){return Promise.all([n.e("chunk-0458398b"),n.e("chunk-62d9ca09"),n.e("chunk-72c6e8d8"),n.e("chunk-f90907bc")]).then(n.bind(null,"f87a"))}},{path:"/syslog",name:"Syslog",component:function(){return Promise.all([n.e("chunk-0458398b"),n.e("chunk-62d9ca09"),n.e("chunk-72c6e8d8"),n.e("chunk-2c05d556")]).then(n.bind(null,"beee"))}}],J=new q["a"]({mode:"hash",base:"",routes:U}),z=J,G=n("f309"),X=n("0fe0"),W=n.n(X),K=n("fcf4");r["a"].use(G["a"]);var Y={lang:{locales:{de:W.a},current:"de"},theme:{dark:!0,themes:{dark:{primary:K["a"].grey.darken4,secondary:K["a"].grey.darken3,success:K["a"].green.accent2,accent:K["a"].green.accent2},light:{primary:K["a"].grey,secondary:K["a"].grey.lighten3,success:K["a"].green.accent3,accent:K["a"].green.accent3}}}},Q=new G["a"](Y),Z=n("b85c"),ee=n("1da1"),te=n("53ca"),ne=n("d4ec"),ae=n("bee2"),re=n("262e"),se=n("2caf"),ie=(n("96cf"),n("fb6a"),n("1276"),n("ac1f"),n("5319"),n("13d5"),n("159b"),n("466d"),n("d81d"),n("b680"),n("99af"),n("4d63"),n("25f0"),n("b64b"),n("b0c0"),n("07ac"),n("faa1")),oe=n.n(ie),ce=function(e){Object(re["a"])(n,e);var t=Object(se["a"])(n);function n(){var e;return Object(ne["a"])(this,n),e=t.call(this),e.app={connection:{location:window.location.protocol+"//"+window.location.hostname,port:window.location.port,path:"fhem"},socket:null,session:{connect:!1,csrf:null,restart:!1,logList:[],logLast:{}},options:{loading:!1,loadCount:0,clock:null,maxChartPoints:100,updateProcess:!1,logRecord:!0,logBuffer:500},templates:[],componentMap:[],data:{roomList:[],groupList:[],deviceList:[]}},e}return Object(ae["a"])(n,[{key:"loading",set:function(e){e&&this.app.options.loadCount++,!e&&this.app.options.loadCount>0&&this.app.options.loadCount--,this.app.options.loading=this.app.options.loadCount>0}},{key:"log",set:function(e){var t={type:"info",timestamp:Date.now(),timeFlag:null,message:"",icon:"",color:""};Object.assign(t,e);var n=new Date(t.timestamp).toLocaleTimeString("de-DE"),a=new Date(t.timestamp).getMilliseconds();t.timeFlag=n+":"+("000"+a).slice(-3),t.icon="error"===t.type?"mdi-alert":"info"===t.type?"mdi-information":"mdi-sync-circle",t.color=t.type,this.app.session.logLast=t,"error"===t.type&&this.emit("message",{type:t.type,message:t.message,meta:t.meta}),this.app.options.logRecord&&(this.app.session.logList.unshift(t),this.app.session.logList.length>this.app.options.logBuffer&&(this.app.session.logList.length=this.app.options.logBuffer))}},{key:"getDate",value:function(e){var t=e?parseInt(e):0;return function(e){return new Date(e.setDate(e.getDate()+t)).toISOString()}(new Date).split("T")[0]}},{key:"getDateTime",value:function(e){var t=e||Date.now();return new Date(t).toLocaleString("de-DE",{dateStyle:"short",timeStyle:"medium"}).replace(",","")}},{key:"getEl",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a0&&e.forEach((function(e){e.param&&e.value&&(s+=s?"&":"?",s+=e.param+"="+encodeURIComponent(e.value))})),n+a+r+s}},{key:"getCsrfToken",value:function(){var e=Object(ee["a"])(regeneratorRuntime.mark((function e(){var t,n=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return t=new Promise((function(e,t){n.request({},"csrf").then((function(t){return e(t)})).catch((function(e){return t(e)}))})),e.abrupt("return",t);case 2:case"end":return e.stop()}}),e)})));function t(){return e.apply(this,arguments)}return t}()},{key:"request",value:function(){var e=Object(ee["a"])(regeneratorRuntime.mark((function e(t,n,r){var s,i=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return s=new Promise((function(e,s){var o=[];"csrf"!=n&&o.push({param:"fwcsrf",value:i.app.session.csrf}),"json"!==n&&"csrf"!==n||o.push({param:"XHR",value:"1"}),"object"===Object(te["a"])(t)&&(t.length>0?o.push.apply(o,Object(a["a"])(t)):o.push(t)),"string"===typeof t&&o.push({param:"cmd",value:t});var c=i.createURL(o);i.log={type:"info",message:"Request: "+c},fetch(c).then((function(t){if(t.ok)if("csrf"===n){var a=t.headers.get("x-fhem-csrftoken");e("object"===Object(te["a"])(r)?Object.assign(r,{data:a}):a)}else"json"===n?t.json().then((function(t){e("object"===Object(te["a"])(r)?Object.assign(r,{data:t}):t)})):t.text().then((function(t){e("object"===Object(te["a"])(r)?Object.assign(r,{data:t}):t)}))})).catch((function(e){s({error:e,request:c})}))})),e.abrupt("return",s);case 2:case"end":return e.stop()}}),e)})));function t(t,n,a){return e.apply(this,arguments)}return t}()},{key:"handleLogData",value:function(e){var t=e.split("\n");t.length>3&&t.splice(-3,3);var n,a=[],r=t.length>this.app.options.maxChartPoints?parseInt(t.length/this.app.options.maxChartPoints):1,s=r,i=0,o=1,c=Object(Z["a"])(t);try{for(c.s();!(n=c.n()).done;){var u=n.value,p=u.split(" "),l=Date.parse(p[0].replace("_","T")),h=parseFloat(p[1]);i+=h,(o>=s||o===t.length)&&(o===t.length&&(r-=s-o),a.push({timestamp:l,value:i/r}),s+=r,i=0),o++}}catch(f){c.e(f)}finally{c.f()}return a}},{key:"readLogFile",value:function(){var e=Object(ee["a"])(regeneratorRuntime.mark((function e(t){var n,a=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=new Promise((function(e,n){t.defs&&t.defs.length>0?function(){var r,s=[],i=0,o=Object(Z["a"])(t.defs);try{for(o.s();!(r=o.n()).done;){var c=r.value,u=c.split(":"),p="get ";p+=u[0]?u[0]:t.deviceName,p+=t.from?" - - "+t.from:"",p+=t.to?" "+t.to:"",p+=u[1]?" 4:"+u[1]:"",a.request([{param:"cmd",value:p},{param:"XHR",value:"1"}],"text",{id:i}).then((function(n){s.push({id:n.id,data:a.handleLogData(n.data)}),s.length===t.defs.length&&(Object.assign(t,{data:s}),e(t))})).catch((function(e){a.log={type:"error",message:"Fetch data from FHEM Logfile failed.",meta:e},n()})),i++}}catch(l){o.e(l)}finally{o.f()}}():(a.log={type:"error",message:"No Definitions for Chart found.",meta:t},n())})),e.abrupt("return",n);case 2:case"end":return e.stop()}}),e)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"checkUpdate",value:function(){var e=Object(ee["a"])(regeneratorRuntime.mark((function e(){var t,n=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return t=new Promise((function(e,t){n.request([{param:"cmd",value:"update check"},{param:"XHR",value:"1"}]).then((function(t){var n,a=t.split("\n").splice(2),r=0,s=1,i=Object(Z["a"])(a);try{for(i.s();!(n=i.n()).done;){var o=n.value;o.match("UPD")&&!o.match("excluded")&&r++,s===a.length&&e(r>0),s++}}catch(c){i.e(c)}finally{i.f()}})).catch((function(e){n.log={type:"error",message:"FHEM check for Updates failed.",meta:e},t(e)}))})),e.abrupt("return",t);case 2:case"end":return e.stop()}}),e)})));function t(){return e.apply(this,arguments)}return t}()},{key:"getRoutes",value:function(e){var t=this;if(this.app.options.loading=!0,"room"===e||"group"===e){var n=e+"List",a=[];this.app.data[n].splice(0),this.request({param:"cmd",value:"jsonList2 appOptions!= appOptions "+e},"json").then(function(){var n=Object(ee["a"])(regeneratorRuntime.mark((function n(r){var s,i,o,c,u,p,l,h,f,d,m;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:s=1,i=Object(Z["a"])(r.Results),n.prev=2,i.s();case 4:if((o=i.n()).done){n.next=15;break}return c=o.value,n.next=8,t.createOptions(c,!0);case 8:if(u=n.sent,p=u[e]||c.Attributes[e],p&&u.template){l=p.split(","),h=Object(Z["a"])(l);try{for(h.s();!(f=h.n()).done;)d=f.value,m="/devices/"+e+"="+d.replaceAll(" ","\\s").replaceAll("&","."),u[e]&&(m+="&appOptions="+e),-1==a.map((function(e){return e.title})).indexOf(d)&&a.push({title:d,route:m})}catch(v){h.e(v)}finally{h.f()}}s===r.Results.length&&(a.sort((function(e,t){return e.title>t.title?1:t.title>e.title?-1:0})),t.app.data[e+"List"]=Object.assign([],a),t.app.options.loading=!1),s++;case 13:n.next=4;break;case 15:n.next=20;break;case 17:n.prev=17,n.t0=n["catch"](2),i.e(n.t0);case 20:return n.prev=20,i.f(),n.finish(20);case 23:case"end":return n.stop()}}),n,null,[[2,17,20,23]])})));return function(e){return n.apply(this,arguments)}}()).catch((function(n){t.log={type:"error",message:"Loading "+e+"s from FHEM failed.",meta:n},t.app.options.loading=!1}))}else this.log={type:"error",message:"Creating Routes failed.",meta:e},this.app.options.loading=!1}},{key:"replaceVals",value:function(e,t){for(var n=/[0-9]/.exec(t),a=[],r=2;r0){var r,s=Object(Z["a"])(t);try{for(s.s();!(r=s.n()).done;){var i=r.value,o=i.split(":");if(o.length>2){var c=o[0].match(/\./)?o[0].split("."):["Readings",o[0],"Value"],u=this.getEl.apply(this,[e].concat(Object(a["a"])(c)));if(u){var p=!1;if(isNaN(parseFloat(o[1])))RegExp(o[1]?o[1]:".").test(u)&&(p=!0);else{var l=/[0-9]/.exec(u);-1!=l.index&&parseFloat(u.slice(l.index))>=parseFloat(o[1])&&(p=!0)}if(p){n=this.replaceVals(o,u);break}}}}}catch(h){s.e(h)}finally{s.f()}}return n}},{key:"handleStates",value:function(e,t,n){var r=this.getEl(e,"Options","states")||n;if(r){var s,i=Object(Z["a"])(r);try{for(i.s();!(s=i.n()).done;){var o=s.value,c=o.split(":");if(c[0]){var u=c[0].match(/\./)?c[0].split("."):["Readings",c[0],"Value"],p=this.getEl.apply(this,[e].concat(Object(a["a"])(u)));if(p){var l=!1;if(isNaN(parseFloat(c[1]))?RegExp(c[1]?c[1]:".").test(p)&&(l=!0):parseFloat(p)>=parseFloat(c[1])&&(l=!0),l){var h={};c[2]&&(h.mainState=c[0]===c[2]?p:c[2]),c[3]&&(h.mainLevel=c[0]===c[3]?p:c[3]),c[4]&&(h.mainColor=c[4]),c[5]&&(h.systemIcon=c[5]),Object.assign(t,h);break}}}else this.log={type:"error",message:"Wrong Definition for Device-States.",meta:e}}}catch(f){i.e(f)}finally{i.f()}}return t}},{key:"createConnected",value:function(){var e=Object(ee["a"])(regeneratorRuntime.mark((function e(t){var n,a=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=new Promise((function(e,n){"connected"in t.Options?function(){for(var r=Object.keys(t.Options.connected),s={},i=1,o=function(){var o=u[c];a.request({param:"cmd",value:"jsonlist2 "+t.Options.connected[o]},"json").then(function(){var t=Object(ee["a"])(regeneratorRuntime.mark((function t(n){var c;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return s[o]=n.Results[0],"PossibleSets"in s[o]&&delete s[o].PossibleSets,"PossibleAttrs"in s[o]&&delete s[o].PossibleAttrs,t.next=5,a.createOptions(s[o]);case 5:c=t.sent,c&&(s[o].Options=c),i===r.length&&e(s),i++;case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).catch((function(e){return n(e)}))},c=0,u=r;c0)){n.next=21;break}i=Object(Z["a"])(a.Results),n.prev=4,c=regeneratorRuntime.mark((function n(){var i,c,u;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return i=o.value,"PossibleSets"in i&&delete i.PossibleSets,"PossibleAttrs"in i&&delete i.PossibleAttrs,c=!1,n.next=6,t.createOptions(i);case 6:u=n.sent,u?(i.Options=u,i.Options.order=i.Attributes.sortby||"zzz",e.match("FILTER=group")&&i.Options.group&&(c=!0),e.match("FILTER=room")&&i.Options.room&&(c=!0),t.createConnected(i).then((function(e){i.Connected=e,c||s.push(i),r===a.Results.length&&(s.sort((function(e,t){return e.Options.order>t.Options.order?1:t.Options.order>e.Options.order?-1:0})),t.app.data.deviceList=Object.assign([],s),t.app.options.loading=!1),r++})).catch((function(e){t.log={type:"error",message:"Add Connected Element failed.",meta:e},t.app.options.loading=!1}))):t.app.options.loading=!1;case 8:case"end":return n.stop()}}),n)})),i.s();case 7:if((o=i.n()).done){n.next=11;break}return n.delegateYield(c(),"t0",9);case 9:n.next=7;break;case 11:n.next=16;break;case 13:n.prev=13,n.t1=n["catch"](4),i.e(n.t1);case 16:return n.prev=16,i.f(),n.finish(16);case 19:n.next=22;break;case 21:t.app.options.loading=!1;case 22:case"end":return n.stop()}}),n,null,[[4,13,16,19]])})));return function(e){return n.apply(this,arguments)}}()).catch((function(e){t.log={type:"error",message:"Request to FHEM failed.",meta:e},t.app.options.loading=!1}))}},{key:"handleData",value:function(e){var t=JSON.parse(e),n=null;if(!t[2].match("0){var n=t.handleData(e);n&&t.app.data.deviceList.forEach((function(e,a){var r=t.app.data.deviceList[a],s=Object.assign({},r);e.Name===n.Name&&("Readings"===n.devicePart&&t.getEl(s,"Readings",n.param,n.paramPart)&&(s.Readings[n.param][n.paramPart]=n.value),"Attributes"===n.devicePart&&t.getEl(s,"Attributes",n.param)&&(s.Attributes[n.param]=n.value),t.app.data.deviceList.splice(a,1,s)),"Connected"in e&&Object.values(e.Connected).forEach((function(r,i){if(r.Name===n.Name){var o=Object.keys(e.Connected)[i];"Readings"===n.devicePart&&t.getEl(s.Connected[o],"Readings",n.param,n.paramPart)&&(s.Connected[o].Readings[n.param][n.paramPart]=n.value),"Attributes"===n.devicePart&&t.getEl(s.Connected[o],"Attributes",n.param)&&(s.Connected[o].Attributes[n.param]=n.value),t.app.data.deviceList.splice(a,1,s)}}))}))}}))}},{key:"connClose",value:function(){var e=this;this.app.session.connect=!1,this.app.session.csrf=null,this.app.session.socket=null,this.app.session.restart||(this.app.session.restart=!0,setTimeout((function(){e.app.session.restart=!1,e.init()}),3e3)),this.log={type:"info",message:"Connection with FHEM was closed. Try to Reconnect in 3 seconds..."}}},{key:"connOpen",value:function(){var e=this;this.app.options.loading=!0,this.getCsrfToken().then((function(t){e.app.session.csrf=t,e.app.session.connect=!0,e.emit("connect"),e.log={type:"info",message:"Connection with FHEM is opened.",meta:e.session},e.app.options.loading=!1})).catch((function(t){e.app.session.csrf=null,e.app.session.connect=!1,e.log={type:"error",message:"Retrieve csrf-Token failed.",meta:t}})).finally((function(){return e.app.options.loading=!1}))}},{key:"init",value:function(){var e=this,t=[{param:"inform",value:"type=status;filter=.*;fmt=JSON"},{param:"XHR",value:"1"}],n=this.createURL(t).replace("http","ws");this.app.socket=new WebSocket(n),this.app.socket.onopen=function(){return e.connOpen()},this.app.socket.onmessage=function(t){return e.doUpdate(t)},this.app.socket.onclose=function(){return e.connClose()},setInterval((function(){e.app.options.clock=(new Date).toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})}),1e3)}}]),n}(oe.a),ue=n("1321"),pe=n.n(ue);r["a"].use(pe.a),r["a"].component("apexchart",pe.a),r["a"].config.productionTip=!1,r["a"].prototype.$fhem=new ce,fetch("./cfg/config.json").then((function(e){return e.json()})).catch((function(e){r["a"].prototype.$fhem.log={type:"error",message:"Loading config.json failed.",meta:e}})).then((function(e){var t;e&&(e.connection&&Object.assign(r["a"].prototype.$fhem.app.connection,e.connection),e.options&&Object.assign(r["a"].prototype.$fhem.app.options,e.options),e.custom&&e.custom.length>0&&(t=r["a"].prototype.$fhem.app.templates).push.apply(t,Object(a["a"])(e.custom)),e.theme&&(-1!=e.theme.dark&&Object.assign(Q.framework.theme,{dark:e.theme.dark}),e.theme.themes&&(e.theme.themes.light&&Object.assign(Q.framework.theme.themes.light,e.theme.themes.light),e.theme.themes.dark&&Object.assign(Q.framework.theme.themes.dark,e.theme.themes.dark))));r["a"].prototype.$fhem.log={type:"info",message:"Config: "+JSON.stringify(e)},r["a"].prototype.$fhem.log={type:"info",message:"Connection: "+JSON.stringify(r["a"].prototype.$fhem.app.connection)},new r["a"]({vuetify:Q,router:z,render:function(e){return e(B)}}).$mount("#app")}))},c274:function(e,t,n){e.exports=n.p+"img/FHEM_Logo.2d0f7a38.png"}}); \ No newline at end of file diff --git a/www/fhemapp/js/app.bc387fd0.js b/www/fhemapp/js/app.bc387fd0.js new file mode 100644 index 00000000..1961dfac --- /dev/null +++ b/www/fhemapp/js/app.bc387fd0.js @@ -0,0 +1 @@ +(function(e){function t(t){for(var a,r,i=t[0],c=t[1],p=t[2],u=0,l=[];u0?(this.type=this.msgList[0].type,this.message=this.msgList[0].message,this.meta=this.msgList[0].meta,this.alert=!0):(this.alert=!1,this.type="info",this.message="",this.meta="")}},methods:{clearMessage:function(){this.msgList.length>0&&this.msgList.splice(0,1)}},mounted:function(){var e=this;this.$fhem.on("message",(function(t){var n={type:"warning",message:"no valid message received",meta:""};Object.assign(n,t),e.msgList.unshift(n)}))}}),u=p,l=n("2877"),h=n("6544"),f=n.n(h),d=n("0798"),m=n("8336"),g=n("62ad"),v=n("132d"),b=n("0fd9"),y=Object(l["a"])(u,i,c,!1,null,null,null),k=y.exports;f()(y,{VAlert:d["a"],VBtn:m["a"],VCol:g["a"],VIcon:v["a"],VRow:b["a"]});var O={data:function(){return{drawer:null,back:!1,app:{options:{loading:!1,clock:null},session:{connect:!1},data:{roomList:[],groupList:[]}},version:"v3.4.0",status:{color:"secondary",icon:"mdi-circle",text:"unbekannt",time:""}}},components:{Broadcaster:k},watch:{"app.session.connect":function(e){this.status.color=e?"success":"error",this.status.text=e?"online":"offline",this.status.time=this.$fhem.getDateTime()},$route:function(e){this.back="/"!==e.path}},computed:{showRooms:function(){return this.app.data.roomList.length>0},showGroups:function(){return this.app.data.groupList.length>0}},methods:{loadRoutes:function(){this.app.session.connect&&(this.$fhem.getRoutes("room"),this.$fhem.getRoutes("group"))},goTo:function(){this.$router.go(-1)}},mounted:function(){var e=this;this.app.session=this.$fhem.app.session,this.app.options=this.$fhem.app.options,this.app.data=this.$fhem.app.data,this.$fhem.on("connect",(function(){return e.loadRoutes()})),this.$fhem.init(),this.loadRoutes()}},w=O,j=n("7496"),x=n("40dc"),R=n("5bc1"),L=n("cc20"),C=n("a523"),_=n("ce7e"),P=n("adda"),E=n("8860"),S=n("56b0"),D=n("da13"),V=n("5d23"),F=n("34c3"),A=n("f6c4"),T=n("f774"),N=n("a797"),$=n("490a"),I=n("2fa4"),M=n("3a2f"),H=Object(l["a"])(w,s,o,!1,null,null,null),B=H.exports;f()(H,{VApp:j["a"],VAppBar:x["a"],VAppBarNavIcon:R["a"],VBtn:m["a"],VChip:L["a"],VContainer:C["a"],VDivider:_["a"],VIcon:v["a"],VImg:P["a"],VList:E["a"],VListGroup:S["a"],VListItem:D["a"],VListItemContent:V["a"],VListItemIcon:F["a"],VListItemSubtitle:V["b"],VListItemTitle:V["c"],VMain:A["a"],VNavigationDrawer:T["a"],VOverlay:N["a"],VProgressCircular:$["a"],VSpacer:I["a"],VTooltip:M["a"]});n("3ca3"),n("ddb0");var q=n("8c4f");r["a"].use(q["a"]);var U=[{path:"/",name:"Home",component:function(){return n.e("chunk-2d212bf1").then(n.bind(null,"aa72"))}},{path:"/system",name:"System",component:function(){return n.e("chunk-2d212bf1").then(n.bind(null,"aa72"))}},{path:"/dashboard",name:"Dashboard",component:function(){return n.e("chunk-2d212bf1").then(n.bind(null,"aa72"))}},{path:"/devices/:filter",name:"Devices",component:function(){return n.e("chunk-2d212bf1").then(n.bind(null,"aa72"))}},{path:"/edit-devices",name:"EditDevice",component:function(){return Promise.all([n.e("chunk-0458398b"),n.e("chunk-62d9ca09"),n.e("chunk-72c6e8d8"),n.e("chunk-f90907bc")]).then(n.bind(null,"f87a"))}},{path:"/syslog",name:"Syslog",component:function(){return Promise.all([n.e("chunk-0458398b"),n.e("chunk-62d9ca09"),n.e("chunk-72c6e8d8"),n.e("chunk-2c05d556")]).then(n.bind(null,"beee"))}}],J=new q["a"]({mode:"hash",base:"",routes:U}),G=J,z=n("f309"),X=n("0fe0"),W=n.n(X),K=n("fcf4");r["a"].use(z["a"]);var Y={lang:{locales:{de:W.a},current:"de"},theme:{dark:!0,themes:{dark:{primary:K["a"].grey.darken4,secondary:K["a"].grey.darken3,success:K["a"].green.accent2,accent:K["a"].green.accent2},light:{primary:K["a"].grey,secondary:K["a"].grey.lighten3,success:K["a"].green.accent3,accent:K["a"].green.accent3}}}},Q=new z["a"](Y),Z=n("b85c"),ee=n("1da1"),te=n("53ca"),ne=n("d4ec"),ae=n("bee2"),re=n("262e"),se=n("2caf"),oe=(n("96cf"),n("fb6a"),n("1276"),n("ac1f"),n("5319"),n("13d5"),n("159b"),n("466d"),n("d81d"),n("b680"),n("99af"),n("4d63"),n("25f0"),n("b64b"),n("b0c0"),n("07ac"),n("faa1")),ie=n.n(oe),ce=function(e){Object(re["a"])(n,e);var t=Object(se["a"])(n);function n(){var e;return Object(ne["a"])(this,n),e=t.call(this),e.app={connection:{location:window.location.protocol+"//"+window.location.hostname,port:window.location.port,path:"fhem"},socket:null,session:{connect:!1,csrf:null,restart:!1,logList:[],logLast:{}},options:{loading:!1,loadCount:0,clock:null,maxChartPoints:100,updateProcess:!1,logRecord:!0,logBuffer:500,ignoreFhemRoom:!1,ignoreFhemGroup:!1,ignoreFhemSortby:!1},templates:[],componentMap:[],data:{roomList:[],groupList:[],deviceList:[]}},e}return Object(ae["a"])(n,[{key:"loading",set:function(e){e&&this.app.options.loadCount++,!e&&this.app.options.loadCount>0&&this.app.options.loadCount--,this.app.options.loading=this.app.options.loadCount>0}},{key:"log",set:function(e){var t={type:"info",timestamp:Date.now(),timeFlag:null,message:"",icon:"",color:""};Object.assign(t,e);var n=new Date(t.timestamp).toLocaleTimeString("de-DE"),a=new Date(t.timestamp).getMilliseconds();t.timeFlag=n+":"+("000"+a).slice(-3),t.icon="error"===t.type?"mdi-alert":"info"===t.type?"mdi-information":"mdi-sync-circle",t.color=t.type,this.app.session.logLast=t,"error"===t.type&&this.emit("message",{type:t.type,message:t.message,meta:t.meta}),this.app.options.logRecord&&(this.app.session.logList.unshift(t),this.app.session.logList.length>this.app.options.logBuffer&&(this.app.session.logList.length=this.app.options.logBuffer))}},{key:"getDate",value:function(e){var t=e?parseInt(e):0;return function(e){return new Date(e.setDate(e.getDate()+t)).toISOString()}(new Date).split("T")[0]}},{key:"getDateTime",value:function(e){var t=e||Date.now();return new Date(t).toLocaleString("de-DE",{dateStyle:"short",timeStyle:"medium"}).replace(",","")}},{key:"getEl",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a0&&e.forEach((function(e){e.param&&e.value&&(s+=s?"&":"?",s+=e.param+"="+encodeURIComponent(e.value))})),n+a+r+s}},{key:"getCsrfToken",value:function(){var e=Object(ee["a"])(regeneratorRuntime.mark((function e(){var t,n=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return t=new Promise((function(e,t){n.request({},"csrf").then((function(t){return e(t)})).catch((function(e){return t(e)}))})),e.abrupt("return",t);case 2:case"end":return e.stop()}}),e)})));function t(){return e.apply(this,arguments)}return t}()},{key:"request",value:function(){var e=Object(ee["a"])(regeneratorRuntime.mark((function e(t,n,r){var s,o=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return s=new Promise((function(e,s){var i=[];"csrf"!=n&&i.push({param:"fwcsrf",value:o.app.session.csrf}),"json"!==n&&"csrf"!==n||i.push({param:"XHR",value:"1"}),"object"===Object(te["a"])(t)&&(t.length>0?i.push.apply(i,Object(a["a"])(t)):i.push(t)),"string"===typeof t&&i.push({param:"cmd",value:t});var c=o.createURL(i);o.log={type:"info",message:"Request: "+c},fetch(c).then((function(t){if(t.ok)if("csrf"===n){var a=t.headers.get("x-fhem-csrftoken");e("object"===Object(te["a"])(r)?Object.assign(r,{data:a}):a)}else"json"===n?t.json().then((function(t){e("object"===Object(te["a"])(r)?Object.assign(r,{data:t}):t)})):t.text().then((function(t){e("object"===Object(te["a"])(r)?Object.assign(r,{data:t}):t)}))})).catch((function(e){s({error:e,request:c})}))})),e.abrupt("return",s);case 2:case"end":return e.stop()}}),e)})));function t(t,n,a){return e.apply(this,arguments)}return t}()},{key:"handleLogData",value:function(e){var t=e.split("\n");t.length>3&&t.splice(-3,3);var n,a=[],r=t.length>this.app.options.maxChartPoints?parseInt(t.length/this.app.options.maxChartPoints):1,s=r,o=0,i=1,c=Object(Z["a"])(t);try{for(c.s();!(n=c.n()).done;){var p=n.value,u=p.split(" "),l=Date.parse(u[0].replace("_","T")),h=parseFloat(u[1]);o+=h,(i>=s||i===t.length)&&(i===t.length&&(r-=s-i),a.push({timestamp:l,value:o/r}),s+=r,o=0),i++}}catch(f){c.e(f)}finally{c.f()}return a}},{key:"readLogFile",value:function(){var e=Object(ee["a"])(regeneratorRuntime.mark((function e(t){var n,a=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=new Promise((function(e,n){t.defs&&t.defs.length>0?function(){var r,s=[],o=0,i=Object(Z["a"])(t.defs);try{for(i.s();!(r=i.n()).done;){var c=r.value,p=c.split(":"),u="get ";u+=p[0]?p[0]:t.deviceName,u+=t.from?" - - "+t.from:"",u+=t.to?" "+t.to:"",u+=p[1]?" 4:"+p[1]:"",a.request([{param:"cmd",value:u},{param:"XHR",value:"1"}],"text",{id:o}).then((function(n){s.push({id:n.id,data:a.handleLogData(n.data)}),s.length===t.defs.length&&(Object.assign(t,{data:s}),e(t))})).catch((function(e){a.log={type:"error",message:"Fetch data from FHEM Logfile failed.",meta:e},n()})),o++}}catch(l){i.e(l)}finally{i.f()}}():(a.log={type:"error",message:"No Definitions for Chart found.",meta:t},n())})),e.abrupt("return",n);case 2:case"end":return e.stop()}}),e)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"checkUpdate",value:function(){var e=Object(ee["a"])(regeneratorRuntime.mark((function e(){var t,n=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return t=new Promise((function(e,t){n.request([{param:"cmd",value:"update check"},{param:"XHR",value:"1"}]).then((function(t){var n,a=t.split("\n").splice(2),r=0,s=1,o=Object(Z["a"])(a);try{for(o.s();!(n=o.n()).done;){var i=n.value;i.match("UPD")&&!i.match("excluded")&&r++,s===a.length&&e(r>0),s++}}catch(c){o.e(c)}finally{o.f()}})).catch((function(e){n.log={type:"error",message:"FHEM check for Updates failed.",meta:e},t(e)}))})),e.abrupt("return",t);case 2:case"end":return e.stop()}}),e)})));function t(){return e.apply(this,arguments)}return t}()},{key:"getRoutes",value:function(e){var t=this;if(this.app.options.loading=!0,"room"===e||"group"===e){var n=e+"List",a=[];this.app.data[n].splice(0),this.request({param:"cmd",value:"jsonList2 appOptions!= appOptions "+e},"json").then(function(){var n=Object(ee["a"])(regeneratorRuntime.mark((function n(r){var s,o,i,c,p,u,l,h,f,d,m,g;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:s=1,o=Object(Z["a"])(r.Results),n.prev=2,o.s();case 4:if((i=o.n()).done){n.next=19;break}return c=i.value,n.next=8,t.createOptions(c,!0);case 8:if(p=n.sent,u=p[e],l=!1,t.app.options.ignoreFhemRoom&&"room"===e&&(l=!0),t.app.options.ignoreFhemGroup&&"group"===e&&(l=!0),u||l||(u=c.Attributes[e]),u&&p.template){h=u.split(","),f=Object(Z["a"])(h);try{for(f.s();!(d=f.n()).done;)m=d.value,g="/devices/"+e+"="+m.replaceAll(" ","\\s").replaceAll("&","."),p[e]&&(g+="&appOptions="+e),-1==a.map((function(e){return e.title})).indexOf(m)&&a.push({title:m,route:g})}catch(v){f.e(v)}finally{f.f()}}s===r.Results.length&&(a.sort((function(e,t){return e.title>t.title?1:t.title>e.title?-1:0})),t.app.data[e+"List"]=Object.assign([],a),t.app.options.loading=!1),s++;case 17:n.next=4;break;case 19:n.next=24;break;case 21:n.prev=21,n.t0=n["catch"](2),o.e(n.t0);case 24:return n.prev=24,o.f(),n.finish(24);case 27:case"end":return n.stop()}}),n,null,[[2,21,24,27]])})));return function(e){return n.apply(this,arguments)}}()).catch((function(n){t.log={type:"error",message:"Loading "+e+"s from FHEM failed.",meta:n},t.app.options.loading=!1}))}else this.log={type:"error",message:"Creating Routes failed.",meta:e},this.app.options.loading=!1}},{key:"replaceVals",value:function(e,t){for(var n=/[0-9]/.exec(t),a=[],r=2;r0){var r,s=Object(Z["a"])(t);try{for(s.s();!(r=s.n()).done;){var o=r.value,i=o.split(":");if(i.length>2){var c=i[0].match(/\./)?i[0].split("."):["Readings",i[0],"Value"],p=this.getEl.apply(this,[e].concat(Object(a["a"])(c)));if(p){var u=!1;if(isNaN(parseFloat(i[1])))RegExp(i[1]?i[1]:".").test(p)&&(u=!0);else{var l=/[0-9]/.exec(p);-1!=l.index&&parseFloat(p.slice(l.index))>=parseFloat(i[1])&&(u=!0)}if(u){n=this.replaceVals(i,p);break}}}}}catch(h){s.e(h)}finally{s.f()}}return n}},{key:"handleStates",value:function(e,t,n){var r=this.getEl(e,"Options","states")||n;if(r){var s,o=Object(Z["a"])(r);try{for(o.s();!(s=o.n()).done;){var i=s.value,c=i.split(":");if(c[0]){var p=c[0].match(/\./)?c[0].split("."):["Readings",c[0],"Value"],u=this.getEl.apply(this,[e].concat(Object(a["a"])(p)));if(u){var l=!1;if(isNaN(parseFloat(c[1]))?RegExp(c[1]?c[1]:".").test(u)&&(l=!0):parseFloat(u)>=parseFloat(c[1])&&(l=!0),l){var h={};c[2]&&(h.mainState=c[0]===c[2]?u:c[2]),c[3]&&(h.mainLevel=c[0]===c[3]?u:c[3]),c[4]&&(h.mainColor=c[4]),c[5]&&(h.systemIcon=c[5]),Object.assign(t,h);break}}}else this.log={type:"error",message:"Wrong Definition for Device-States.",meta:e}}}catch(f){o.e(f)}finally{o.f()}}return t}},{key:"createConnected",value:function(){var e=Object(ee["a"])(regeneratorRuntime.mark((function e(t){var n,a=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=new Promise((function(e,n){"connected"in t.Options?function(){for(var r=Object.keys(t.Options.connected),s={},o=1,i=function(){var i=p[c];a.request({param:"cmd",value:"jsonlist2 "+t.Options.connected[i]},"json").then(function(){var t=Object(ee["a"])(regeneratorRuntime.mark((function t(n){var c;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return s[i]=n.Results[0],"PossibleSets"in s[i]&&delete s[i].PossibleSets,"PossibleAttrs"in s[i]&&delete s[i].PossibleAttrs,t.next=5,a.createOptions(s[i]);case 5:c=t.sent,c&&(s[i].Options=c),o===r.length&&e(s),o++;case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).catch((function(e){return n(e)}))},c=0,p=r;c0)){n.next=21;break}o=Object(Z["a"])(a.Results),n.prev=4,c=regeneratorRuntime.mark((function n(){var o,c,p;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return o=i.value,"PossibleSets"in o&&delete o.PossibleSets,"PossibleAttrs"in o&&delete o.PossibleAttrs,c=!1,n.next=6,t.createOptions(o);case 6:p=n.sent,p?(o.Options=p,o.Options.sortby||t.app.options.ignoreFhemSortby||(o.Options.sortby=o.Attributes.sortby),o.Options.sortby||(o.Options.sortby="zzz"),e.match("FILTER=group")&&o.Options.group&&(c=!0),e.match("FILTER=room")&&o.Options.room&&(c=!0),t.createConnected(o).then((function(e){o.Connected=e,c||s.push(o),r===a.Results.length&&(s.sort((function(e,t){return e.Options.sortby>t.Options.sortby?1:t.Options.sortby>e.Options.sortby?-1:0})),t.app.data.deviceList=Object.assign([],s),t.app.options.loading=!1),r++})).catch((function(e){t.log={type:"error",message:"Add Connected Element failed.",meta:e},t.app.options.loading=!1}))):t.app.options.loading=!1;case 8:case"end":return n.stop()}}),n)})),o.s();case 7:if((i=o.n()).done){n.next=11;break}return n.delegateYield(c(),"t0",9);case 9:n.next=7;break;case 11:n.next=16;break;case 13:n.prev=13,n.t1=n["catch"](4),o.e(n.t1);case 16:return n.prev=16,o.f(),n.finish(16);case 19:n.next=22;break;case 21:t.app.options.loading=!1;case 22:case"end":return n.stop()}}),n,null,[[4,13,16,19]])})));return function(e){return n.apply(this,arguments)}}()).catch((function(e){t.log={type:"error",message:"Request to FHEM failed.",meta:e},t.app.options.loading=!1}))}},{key:"handleData",value:function(e){var t=JSON.parse(e),n=null;if(!t[2].match("0){var n=t.handleData(e);n&&t.app.data.deviceList.forEach((function(e,a){var r=t.app.data.deviceList[a],s=Object.assign({},r);e.Name===n.Name&&("Readings"===n.devicePart&&t.getEl(s,"Readings",n.param,n.paramPart)&&(s.Readings[n.param][n.paramPart]=n.value),"Attributes"===n.devicePart&&t.getEl(s,"Attributes",n.param)&&(s.Attributes[n.param]=n.value),t.app.data.deviceList.splice(a,1,s)),"Connected"in e&&Object.values(e.Connected).forEach((function(r,o){if(r.Name===n.Name){var i=Object.keys(e.Connected)[o];"Readings"===n.devicePart&&t.getEl(s.Connected[i],"Readings",n.param,n.paramPart)&&(s.Connected[i].Readings[n.param][n.paramPart]=n.value),"Attributes"===n.devicePart&&t.getEl(s.Connected[i],"Attributes",n.param)&&(s.Connected[i].Attributes[n.param]=n.value),t.app.data.deviceList.splice(a,1,s)}}))}))}}))}},{key:"connClose",value:function(){var e=this;this.app.session.connect=!1,this.app.session.csrf=null,this.app.session.socket=null,this.app.session.restart||(this.app.session.restart=!0,setTimeout((function(){e.app.session.restart=!1,e.init()}),3e3)),this.log={type:"info",message:"Connection with FHEM was closed. Try to Reconnect in 3 seconds..."}}},{key:"connOpen",value:function(){var e=this;this.app.options.loading=!0,this.getCsrfToken().then((function(t){e.app.session.csrf=t,e.app.session.connect=!0,e.emit("connect"),e.log={type:"info",message:"Connection with FHEM is opened.",meta:e.session},e.app.options.loading=!1})).catch((function(t){e.app.session.csrf=null,e.app.session.connect=!1,e.log={type:"error",message:"Retrieve csrf-Token failed.",meta:t}})).finally((function(){return e.app.options.loading=!1}))}},{key:"init",value:function(){var e=this,t=[{param:"inform",value:"type=status;filter=.*;fmt=JSON"},{param:"XHR",value:"1"}],n=this.createURL(t).replace("http","ws");this.app.socket=new WebSocket(n),this.app.socket.onopen=function(){return e.connOpen()},this.app.socket.onmessage=function(t){return e.doUpdate(t)},this.app.socket.onclose=function(){return e.connClose()},setInterval((function(){e.app.options.clock=(new Date).toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})}),1e3)}}]),n}(ie.a),pe=n("1321"),ue=n.n(pe);r["a"].use(ue.a),r["a"].component("apexchart",ue.a),r["a"].config.productionTip=!1,r["a"].prototype.$fhem=new ce,fetch("./cfg/config.json").then((function(e){return e.json()})).catch((function(e){r["a"].prototype.$fhem.log={type:"error",message:"Loading config.json failed.",meta:e}})).then((function(e){var t;e&&(e.connection&&Object.assign(r["a"].prototype.$fhem.app.connection,e.connection),e.options&&Object.assign(r["a"].prototype.$fhem.app.options,e.options),e.custom&&e.custom.length>0&&(t=r["a"].prototype.$fhem.app.templates).push.apply(t,Object(a["a"])(e.custom)),e.theme&&(-1!=e.theme.dark&&Object.assign(Q.framework.theme,{dark:e.theme.dark}),e.theme.themes&&(e.theme.themes.light&&Object.assign(Q.framework.theme.themes.light,e.theme.themes.light),e.theme.themes.dark&&Object.assign(Q.framework.theme.themes.dark,e.theme.themes.dark))));r["a"].prototype.$fhem.log={type:"info",message:"Config: "+JSON.stringify(e)},r["a"].prototype.$fhem.log={type:"info",message:"Connection: "+JSON.stringify(r["a"].prototype.$fhem.app.connection)},new r["a"]({vuetify:Q,router:G,render:function(e){return e(B)}}).$mount("#app")}))},c274:function(e,t,n){e.exports=n.p+"img/FHEM_Logo.2d0f7a38.png"}}); \ No newline at end of file