From 3d5cfc029b66502c2b0342ae4b9bededc56283c2 Mon Sep 17 00:00:00 2001 From: jemu75 Date: Fri, 2 Apr 2021 17:50:36 +0200 Subject: [PATCH] V3.5.0 --- README.md | 18 ++++++++++++++---- src/App.vue | 11 ++++++++--- src/plugins/fhem.js | 12 ++++++++---- src/views/Devices.vue | 18 +++++++++++++++++- www/fhemapp/index.html | 2 +- www/fhemapp/js/app.bc387fd0.js | 1 - www/fhemapp/js/app.f4160953.js | 1 + www/fhemapp/js/chunk-2d212bf1.846db353.js | 1 + www/fhemapp/js/chunk-2d212bf1.b3f4869b.js | 1 - 9 files changed, 50 insertions(+), 15 deletions(-) delete mode 100644 www/fhemapp/js/app.bc387fd0.js create mode 100644 www/fhemapp/js/app.f4160953.js create mode 100644 www/fhemapp/js/chunk-2d212bf1.846db353.js delete mode 100644 www/fhemapp/js/chunk-2d212bf1.b3f4869b.js diff --git a/README.md b/README.md index 8609f2e9..61e9b187 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,14 @@ Wenn ihr in **FHEMApp** Daten aus FHEM-Logs in Charts darstellt, ist es ggf. sin }, ``` +### Anzeigeeinstellungen fürFHEMApp (optional) +Wenn ihr in **FHEMApp** bei der mobilen Ansicht (1-spaltiges Layout) im Header sehen wollt, in welcher Bereich bzw. in welche Gruppe euch gerade befindet, dann könnt ihr unter Options den Paremeter `mobileHeader` setzen. +``` +"options": { + "mobileHeader": true +}, +``` + ### Themeneinstellungen für FHEMApp (optional) Zusätzlich könnt ihr das Farbschema von **FHEMApp** individuell anpassen. Grundsätzlich könnt ihr zwischen einem *dunklen* und einem *hellen* Layout über den Parameter `dark` (`true` bzw. `false`) wechseln. Weiterhin könnt ihr die einzelnen Farben für die beiden Farbschemen unter dem Parameter `themes` individuell anpassen. Siehe dazu auch [(Vuetify Customizing)](https://vuetifyjs.com/en/features/theme/#customizing) ``` @@ -76,7 +84,7 @@ Zusätzlich könnt ihr das Farbschema von **FHEMApp** individuell anpassen. Grun ![](./docs/media/fhemapp_theme_teal_light.png)*Beispiel für helles Layout* # Grundeinstellung in FHEM -Bevor ihr die gewünschten Geräte für die Anzeige in der **FHEMApp** konfiguriert sind zwei Grundeinstellungen in FHEM notwendig. +Bevor ihr die gewünschten Geräte für die Anzeige in der **FHEMApp** konfiguriert sind sind folgende Grundeinstellungen in FHEM notwendig. 1. Müsst ihr in eurem *FHEM-Device* `FHEMWEB` die beiden Attribute `CORS` auf `1` und `longpoll` auf `websocket` setzen. [(siehe auch)](https://fhem.de/commandref_DE.html#FHEMWEB) Das folgende Beispiel zeigt einen Auszug aus der Datei *fhem.cfg* nachdem die Grundeinstellung vorgenommen wurde. ``` define WEB FHEMWEB 8083 global @@ -682,14 +690,16 @@ Im FHEM-Device muss im Attribut `appOptions` folgendes eingetragen werden. ### Konfiguration von Charts Über den Parameter `chartDef` legt ihr fest, welche Daten im Chart angezeigt werden. Jede Linie entspricht dabei einer Definition. Folgende Eigenschaften stehen zur Verfügung: ``` -"chartDef": ["logfile:reading:text:präfix:axis"], +"chartDef": ["logsource:reading:text:präfix:axis"], ``` -1. **logfile** - dieser Parameter kann freigelassen werden. Wenn ihr in eurem Chart jedoch Daten aus verschiedenen *FileLog-Devices* anzeigen wollt, dann könnt ihr hier den Name des jeweiligen *FileLog-Device* eintragen. -2. **reading** - bezeichnet das Reading aus dem *FileLog* welches ihr anzeigen wollt. (z.B. measured-temp) +1. **logsource** - dieser Parameter enthält entweder den Name des *FileLog-Devices* oder den Name eures *DbLog-Devices*. +2. **reading** - wenn ihr auf ein *FileLog-Device* zugreift, genügt hier im Normalfall der Name des *Readings* welches dargestellt werden soll. Wenn euer *FileLog* Readings in mehreren Spalten enthält, dann müsst ihr den Parameter in runde Klammern setzen und ** angeben z.B. `(4:temperature)`. Wenn Daten von einem *DbLog-Device* anzeigen wollt, dann müsst ihr den Parameter in runde Klammern setzen und *:* angeben z.B. `(myTempSensor:temperature)` 3. **text** - hier tragt iht den gewünschten Achsenname ein. (z.B. Temperatur) 4. **präfix** - hier tragt ihr die Einheit der Werte ein. (z.B. °C) 5. **axis** - wenn dieser Parameter weggelassen wird, dann bezieht sich die Linie im Chart auf die linke Achse. Tragt ihr hier **secondary** ein, so bezieht sich die Linie im Chart auf die rechte Achse. Das ist z.B. sinnvoll, wenn ihr in einem Chart die Temperatur und die Luftfeuchte auf unterschiedlichen Skalen anzeigen wollt. +| Hinweis: Wenn ihr eure Daten über *DbLog* erfasst, dann habt ihr in FHEM dafür im Normalfall nur ein Device angelegt. Damit ihr verschiedene Charts in **FHEMApp** anzeigen könnt, empfielt es sich, je Chart ein *dummy* in FHEM anzulegen und hier die entsprechenden `appOptions` für das Chart zu hinterlegen. Wenn ihr eure Daten in einzelnen *FileLog-Dateien* erfasst, dann könnt ihr `appOptions` an dem jeweiligen *FileLog-Device* hinterlegen. + ### Beispiel für eine Chartkonfiguration Es wird ein Chart im Menüpunkt *Dashboard* angezeigt. Aus dem Logfile werden die Readings *humidity* (rechte Achse) und *measured-temp* (linke Achse) im Chart dargestellt. ``` diff --git a/src/App.vue b/src/App.vue index c41f6fb2..45fe08b1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -14,9 +14,13 @@

{{ app.options.clock }}

+
+ {{ app.data.header }} +
+
@@ -111,10 +115,11 @@ }, data: { roomList: [], - groupList: [] + groupList: [], + header: '' } }, - version: 'v3.4.0', + version: 'v3.5.0', status: { color: 'secondary', icon: 'mdi-circle', diff --git a/src/plugins/fhem.js b/src/plugins/fhem.js index 8aa024d9..7fdade37 100644 --- a/src/plugins/fhem.js +++ b/src/plugins/fhem.js @@ -28,14 +28,16 @@ export default class Fhem extends EventEmitter { logBuffer: 500, ignoreFhemRoom: false, ignoreFhemGroup: false, - ignoreFhemSortby: false + ignoreFhemSortby: false, + mobileHeader: false }, templates: [], // only the fallback for v3.1 componentMap: [], data: { roomList: [], groupList: [], - deviceList: [] + deviceList: [], + header: '' } } } @@ -199,13 +201,15 @@ export default class Fhem extends EventEmitter { let idx = 0; for(const def of obj.defs) { - let defPart = def.split(':'); // definiton [ file : regex : name : suffix : axis ] + let select = /\(.*\)/.exec(def); + if(select) def.replace(select[0],'_'); + let defPart = def.split(':'); // definiton [ source : (regex) : name : suffix : axis ] let cmd = 'get '; cmd += defPart[0] ? defPart[0] : obj.deviceName; cmd += obj.from ? ' - - ' + obj.from : ''; cmd += obj.to ? ' ' + obj.to : ''; - cmd += defPart[1] ? ' 4:' + defPart[1] : ''; + cmd += select ? ' ' + select[0].replace(/\(|\)/g,'') : ' 4:' + defPart[1]; this.request([{ param: 'cmd', value: cmd }, { param: 'XHR', value: '1' }],'text', { id: idx }) .then((res) => { diff --git a/src/views/Devices.vue b/src/views/Devices.vue index e9759080..0102b5df 100644 --- a/src/views/Devices.vue +++ b/src/views/Devices.vue @@ -14,8 +14,12 @@ export default { session: { connect: false }, + options: { + mobileHeader: false + }, data: { - deviceList: [] + deviceList: [], + header: '' } } }), @@ -38,6 +42,17 @@ export default { }, methods: { + setHeader() { + if(this.app.options.mobileHeader) { + if(this.$route.name === 'Devices') { + let part = this.$route.params.filter.split('&')[0].split('=')[1]; + this.app.data.header = part.replace(/\\s.\\s/g,' & '); + } else { + this.app.data.header = this.$route.name; + } + } + }, + subscribe() { if(!this.app.session.connect) return; let fltr = 'appOptions!=:FILTER='; @@ -56,6 +71,7 @@ export default { if(this.$route.name == 'System') fltr = 'appOptions=.*system.:..true.*'; if(this.$route.name == 'Home') fltr = 'appOptions=.*home.:..true.*'; + this.setHeader(); this.$fhem.getDevices(fltr); } }, diff --git a/www/fhemapp/index.html b/www/fhemapp/index.html index 1fd2dc46..672fef9c 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.bc387fd0.js b/www/fhemapp/js/app.bc387fd0.js deleted file mode 100644 index 1961dfac..00000000 --- a/www/fhemapp/js/app.bc387fd0.js +++ /dev/null @@ -1 +0,0 @@ -(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 diff --git a/www/fhemapp/js/app.f4160953.js b/www/fhemapp/js/app.f4160953.js new file mode 100644 index 00000000..cee414b4 --- /dev/null +++ b/www/fhemapp/js/app.f4160953.js @@ -0,0 +1 @@ +(function(e){function t(t){for(var a,r,o=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"),d=n.n(h),f=n("0798"),m=n("8336"),g=n("62ad"),v=n("132d"),b=n("0fd9"),y=Object(l["a"])(u,o,c,!1,null,null,null),k=y.exports;d()(y,{VAlert:f["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:[],header:""}},version:"v3.5.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,i,!1,null,null,null),B=H.exports;d()(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"),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,ignoreFhemRoom:!1,ignoreFhemGroup:!1,ignoreFhemSortby:!1,mobileHeader:!1},templates:[],componentMap:[],data:{roomList:[],groupList:[],deviceList:[],header:""}},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 p=n.value,u=p.split(" "),l=Date.parse(u[0].replace("_","T")),h=parseFloat(u[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(d){c.e(d)}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,p=/\(.*\)/.exec(c);p&&c.replace(p[0],"_");var u=c.split(":"),l="get ";l+=u[0]?u[0]:t.deviceName,l+=t.from?" - - "+t.from:"",l+=t.to?" "+t.to:"",l+=p?" "+p[0].replace(/\(|\)/g,""):" 4:"+u[1],a.request([{param:"cmd",value:l},{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(h){o.e(h)}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,p,u,l,h,d,f,m,g;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=19;break}return c=o.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(","),d=Object(Z["a"])(h);try{for(d.s();!(f=d.n()).done;)m=f.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){d.e(v)}finally{d.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),i.e(n.t0);case 24:return n.prev=24,i.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 i=r.value,o=i.split(":");if(o.length>2){var c=o[0].match(/\./)?o[0].split("."):["Readings",o[0],"Value"],p=this.getEl.apply(this,[e].concat(Object(a["a"])(c)));if(p){var u=!1;if(isNaN(parseFloat(o[1])))RegExp(o[1]?o[1]:".").test(p)&&(u=!0);else{var l=/[0-9]/.exec(p);-1!=l.index&&parseFloat(p.slice(l.index))>=parseFloat(o[1])&&(u=!0)}if(u){n=this.replaceVals(o,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,i=Object(Z["a"])(r);try{for(i.s();!(s=i.n()).done;){var o=s.value,c=o.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(d){i.e(d)}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=p[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,p=r;c0)){n.next=21;break}i=Object(Z["a"])(a.Results),n.prev=4,c=regeneratorRuntime.mark((function n(){var i,c,p;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:p=n.sent,p?(i.Options=p,i.Options.sortby||t.app.options.ignoreFhemSortby||(i.Options.sortby=i.Attributes.sortby),i.Options.sortby||(i.Options.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.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)})),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),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 diff --git a/www/fhemapp/js/chunk-2d212bf1.846db353.js b/www/fhemapp/js/chunk-2d212bf1.846db353.js new file mode 100644 index 00000000..334ef011 --- /dev/null +++ b/www/fhemapp/js/chunk-2d212bf1.846db353.js @@ -0,0 +1 @@ +(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d212bf1"],{aa72:function(e,n,t){"use strict";t.r(n);var s=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("div",[t("v-row",e._l(e.app.data.deviceList,(function(e){return t(e.Options.component,{key:e.Internals.FUUID,tag:"component",attrs:{item:e}})})),1)],1)},a=[],o=(t("d3b7"),t("3ca3"),t("ddb0"),t("b0c0"),t("1276"),t("ac1f"),t("4de4"),t("5319"),{name:"Devices",data:function(){return{app:{session:{connect:!1},options:{mobileHeader:!1},data:{deviceList:[],header:""}}}},components:{templ_default:function(){return Promise.all([t.e("chunk-0458398b"),t.e("chunk-83618c9a")]).then(t.bind(null,"121f"))},templ_panel:function(){return t.e("chunk-58038582").then(t.bind(null,"5d11"))},templ_chart:function(){return Promise.all([t.e("chunk-0458398b"),t.e("chunk-62d9ca09"),t.e("chunk-d584b056")]).then(t.bind(null,"b009"))},templ_weather:function(){return t.e("chunk-03454508").then(t.bind(null,"1de8"))},templ_scenes:function(){return t.e("chunk-098d33d4").then(t.bind(null,"09fe"))},templ_sonos:function(){return Promise.all([t.e("chunk-0458398b"),t.e("chunk-57a6c555")]).then(t.bind(null,"dd08"))},templ_sysmon:function(){return t.e("chunk-27250ed3").then(t.bind(null,"86eb"))},templ_hmlan:function(){return t.e("chunk-15fa718e").then(t.bind(null,"fca9"))}},watch:{$route:function(){this.subscribe()}},methods:{setHeader:function(){if(this.app.options.mobileHeader)if("Devices"===this.$route.name){var e=this.$route.params.filter.split("&")[0].split("=")[1];this.app.data.header=e.replace(/\\s.\\s/g," & ")}else this.app.data.header=this.$route.name},subscribe:function(){if(this.app.session.connect){var e="appOptions!=:FILTER=";if(this.$route.params.filter){var n=this.$route.params.filter.split("&");-1!=n.indexOf("appOptions=room")||-1!=n.indexOf("appOptions=group")?e="appOptions=.*"+n[0].replace("=",".:..")+".*":e+=n[0]}"Dashboard"==this.$route.name&&(e="appOptions=.*dashboard.:..true.*"),"System"==this.$route.name&&(e="appOptions=.*system.:..true.*"),"Home"==this.$route.name&&(e="appOptions=.*home.:..true.*"),this.setHeader(),this.$fhem.getDevices(e)}}},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.app.componentMap=[{name:"panel",component:"templ_panel"},{name:"chart",component:"templ_chart"},{name:"weather",component:"templ_weather"},{name:"sysmon",component:"templ_sysmon"},{name:"hmlan",component:"templ_hmlan"},{name:"sonos",component:"templ_sonos"},{name:"scenes",component:"templ_scenes"}],this.$fhem.on("connect",(function(){return e.subscribe()})),this.subscribe()}}),i=o,p=t("2877"),r=t("6544"),c=t.n(r),u=t("0fd9"),h=Object(p["a"])(i,s,a,!1,null,null,null);n["default"]=h.exports;c()(h,{VRow:u["a"]})}}]); \ No newline at end of file diff --git a/www/fhemapp/js/chunk-2d212bf1.b3f4869b.js b/www/fhemapp/js/chunk-2d212bf1.b3f4869b.js deleted file mode 100644 index 145ebe6c..00000000 --- a/www/fhemapp/js/chunk-2d212bf1.b3f4869b.js +++ /dev/null @@ -1 +0,0 @@ -(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d212bf1"],{aa72:function(n,e,t){"use strict";t.r(e);var s=function(){var n=this,e=n.$createElement,t=n._self._c||e;return t("div",[t("v-row",n._l(n.app.data.deviceList,(function(n){return t(n.Options.component,{key:n.Internals.FUUID,tag:"component",attrs:{item:n}})})),1)],1)},o=[],a=(t("d3b7"),t("3ca3"),t("ddb0"),t("4de4"),t("1276"),t("ac1f"),t("5319"),t("b0c0"),{name:"Devices",data:function(){return{app:{session:{connect:!1},data:{deviceList:[]}}}},components:{templ_default:function(){return Promise.all([t.e("chunk-0458398b"),t.e("chunk-83618c9a")]).then(t.bind(null,"121f"))},templ_panel:function(){return t.e("chunk-58038582").then(t.bind(null,"5d11"))},templ_chart:function(){return Promise.all([t.e("chunk-0458398b"),t.e("chunk-62d9ca09"),t.e("chunk-d584b056")]).then(t.bind(null,"b009"))},templ_weather:function(){return t.e("chunk-03454508").then(t.bind(null,"1de8"))},templ_scenes:function(){return t.e("chunk-098d33d4").then(t.bind(null,"09fe"))},templ_sonos:function(){return Promise.all([t.e("chunk-0458398b"),t.e("chunk-57a6c555")]).then(t.bind(null,"dd08"))},templ_sysmon:function(){return t.e("chunk-27250ed3").then(t.bind(null,"86eb"))},templ_hmlan:function(){return t.e("chunk-15fa718e").then(t.bind(null,"fca9"))}},watch:{$route:function(){this.subscribe()}},methods:{subscribe:function(){if(this.app.session.connect){var n="appOptions!=:FILTER=";if(this.$route.params.filter){var e=this.$route.params.filter.split("&");-1!=e.indexOf("appOptions=room")||-1!=e.indexOf("appOptions=group")?n="appOptions=.*"+e[0].replace("=",".:..")+".*":n+=e[0]}"Dashboard"==this.$route.name&&(n="appOptions=.*dashboard.:..true.*"),"System"==this.$route.name&&(n="appOptions=.*system.:..true.*"),"Home"==this.$route.name&&(n="appOptions=.*home.:..true.*"),this.$fhem.getDevices(n)}}},mounted:function(){var n=this;this.app.session=this.$fhem.app.session,this.app.options=this.$fhem.app.options,this.app.data=this.$fhem.app.data,this.$fhem.app.componentMap=[{name:"panel",component:"templ_panel"},{name:"chart",component:"templ_chart"},{name:"weather",component:"templ_weather"},{name:"sysmon",component:"templ_sysmon"},{name:"hmlan",component:"templ_hmlan"},{name:"sonos",component:"templ_sonos"},{name:"scenes",component:"templ_scenes"}],this.$fhem.on("connect",(function(){return n.subscribe()})),this.subscribe()}}),p=a,i=t("2877"),c=t("6544"),u=t.n(c),r=t("0fd9"),m=Object(i["a"])(p,s,o,!1,null,null,null);e["default"]=m.exports;u()(m,{VRow:r["a"]})}}]); \ No newline at end of file