UNPKG

zwave-js-ui

Version:

Z-Wave Control Panel and MQTT Gateway

5 lines (4 loc) 15 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./AssociationGroups-CQzQ4H1O.js","./index-CtTdmJsx.js","./index-2j-kvxFz.css","./HomeAssistant-3QCwv1El.js","./NodeDetails-DtPpxhvu.js","./NodeDetails-BVv96O7e.css","./DialogAdvanced-BqKvspGm.js","./DialogAdvanced-D5KZ1_3L.css","./StatisticsCard-gZOwl51N.js","./OTAUpdates-CcrOc58B.js","./UserCodeTable-ohPQgNBI.js"])))=>i.map(i=>d[i]); import{I as d,_ as i,m as u,u as r,P as c,a as p,ao as m,ap as v,j as h,K as f,n as _}from"./index-CtTdmJsx.js";const y={props:{actions:Array,headers:{type:Array,default:()=>[]},isMobile:Boolean,node:Object,socket:Object},mixins:[d],components:{AssociationGroups:()=>i(()=>import("./AssociationGroups-CQzQ4H1O.js"),__vite__mapDeps([0,1,2]),import.meta.url),HomeAssistant:()=>i(()=>import("./HomeAssistant-3QCwv1El.js"),__vite__mapDeps([3,1,2]),import.meta.url),NodeDetails:()=>i(()=>import("./NodeDetails-DtPpxhvu.js"),__vite__mapDeps([4,1,2,5]),import.meta.url),DialogAdvanced:()=>i(()=>import("./DialogAdvanced-BqKvspGm.js"),__vite__mapDeps([6,1,2,7]),import.meta.url),StatisticsCard:()=>i(()=>import("./StatisticsCard-gZOwl51N.js"),__vite__mapDeps([8,1,2]),import.meta.url),OTAUpdates:()=>i(()=>import("./OTAUpdates-CcrOc58B.js"),__vite__mapDeps([9,1,2]),import.meta.url),UserCodeTable:()=>i(()=>import("./UserCodeTable-ohPQgNBI.js"),__vite__mapDeps([10,1,2]),import.meta.url)},computed:{...u(r,["gateway","mqtt"]),isLongRange(){return this.node?this.node.protocol===c.ZWaveLongRange:!1},nodeMetadata(){var s;return(s=this.node.deviceConfig)==null?void 0:s.metadata},nodeComments(){var e;const s=((e=this.nodeMetadata)==null?void 0:e.comments)??[];return Array.isArray(s)?s:[s]},metaKeys(){const s=["manual","inclusion","exclusion","reset","wakeup"];return(this.nodeMetadata?Object.keys(this.nodeMetadata):[]).filter(t=>s.includes(t))},nodeJson(){return JSON.stringify(this.node,null,2)},showHass(){return!this.mqtt.disabled&&this.gateway.hassDiscovery&&this.node.hassDevices&&Object.keys(this.node.hassDevices).length>0},statisticsOpeningIndicator(){return this.showStatistics?"arrow_drop_up":"arrow_drop_down"},statsBorderColor(){return this.showStatistics?"border-primary":""},filteredNodeEvents(){return this.node.eventsQueue.filter(s=>!this.searchEvents||JSON.stringify(s).toLowerCase().includes(this.searchEvents.toLowerCase())).sort((s,e)=>(s=new Date(s.time),e=new Date(e.time),this.inverseSort?e-s:s-e))},advancedActions(){const s=this.node.isControllerNode?[]:[{text:"Firmware update",options:[{name:"Begin",action:"updateFirmware"},{name:"Abort",action:"abortFirmwareUpdate"}],icon:"update",desc:"Start/Stop a firmware update"},{text:"Refresh Values",options:[{name:"Refresh",action:"refreshValues",args:{confirm:"Are you sure you want to refresh values of this node? This action increases network traffic"}}],icon:"cached",desc:"Update all CC values and metadata. Use only when many values seems stale"},{text:"Re-interview Node",options:[{name:"Interview",action:"refreshInfo"}],icon:"history",desc:"Clear all info about this node and make a new full interview. Use when the node has wrong or missing capabilities"},{text:"Failed Nodes",options:[{name:"Remove",action:"removeFailedNode"},{name:"Replace",action:"replaceFailedNode"}],icon:"dangerous",desc:"Manage nodes that are dead and/or marked as failed with the controller"}];this.node.protocol!==c.ZWaveLongRange&&s.splice(1,0,{text:"Rebuild Routes",options:[{name:"Rebuild",action:"rebuildNodeRoutes",args:{confirm:"Rebuilding node routes causes a lot of traffic, can take minutes up to hours and you can expect degraded performance while it is going on"}}],icon:"healing",desc:"Discover and assign new routes from node to the controller and other nodes."});const e=this.node.isControllerNode?[]:[{name:"Clear",action:"removeAllAssociations",args:{confirm:"This action will remove all associations of this node. This will also clear lifeline association with controller node, the node won't report state changes until that is set up again"}}],t=[];return this.node.supportsTime&&t.push({text:"Set Date and Time",options:[{name:"Sync",action:"syncNodeDateAndTime"}],icon:"schedule",desc:"Set date and time of this node to current time"}),[{text:"Export json",options:[{name:"UI",action:"exportNode"},{name:"Driver",action:"dumpNode"}],icon:"get_app",desc:"Export this node in a json file"},{text:"Clear Retained",options:[{name:"Clear",action:"removeNodeRetained",args:{mqtt:!0,confirm:"Are you sure you want to remove all retained messages?"}}],icon:"clear",desc:"All retained messages of this node will be removed from broker"},{text:"Update topics",options:[{name:"Update",action:"updateNodeTopics",args:{mqtt:!0,confirm:"Are you sure you want to update all topics?"}}],icon:"update",desc:"Update all node topics. Useful when name/location has changed"},...s,{text:"Associations",options:[...e,{name:"Remove",action:"removeNodeFromAllAssociations",args:{confirm:"All direct associations to this node will be removed. Battery-powered nodes need to be woken up to edit their associations."}}],icon:"link_off",desc:"Clear all node associations / Remove node from all associations"},...t]}},watch:{"node.eventsQueue"(){this.scrollBottom()},currentTab(){this.scrollBottom()},inverseSort(){this.savePreferences()},autoScroll(){this.savePreferences()}},data(){return{currentTab:0,autoScroll:!0,inverseSort:!0,searchEvents:"",advancedShowDialog:!1,showStatistics:!1}},mounted(){const s=r().getPreference("eventsList",{inverseSort:!0,autoScroll:!0});this.inverseSort=s.inverseSort,this.autoScroll=s.autoScroll},methods:{...p(r,["showSnackbar","setValue","getDateTimeString"]),savePreferences(){r().savePreferences({eventsList:{inverseSort:this.inverseSort,autoScroll:this.autoScroll}})},async updateValue(s,e){if(s){s.toUpdate=!0,s.type==="number"&&(s.newValue=Number(s.newValue)),s.type==="boolean"&&!s.readable&&(s.newValue=!0),e!==void 0&&(s.newValue=e),this.setValue(s);const t=await this.app.apiRequest("writeValue",[{nodeId:s.nodeId,commandClass:s.commandClass,endpoint:s.endpoint,property:s.property,propertyKey:s.propertyKey},s.newValue,this.options]);if(s.toUpdate=!1,t.success){const o=t.result;if(m(o))this.showSnackbar("Value updated","success");else{let a=o.message;!a&&o.status===v.NoDeviceSupport&&(a="No device support"),this.showSnackbar("Value update failed"+(a?": "+a:""),"error")}}else this.showSnackbar(`Error updating value${t.message?": "+t.message:""}`,"error")}},prettyPrintEventArg(s,e){return` Arg ${e}: `+h(s,void 0,1)},linkify(s){var e=/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/gi;return s.replace(e,function(t){return'<a target="_blank" href="'+t+'">'+t+"</a>"})},copyText(){this.$refs.nodeJsonContent.$el.querySelector("textarea").select(),document.execCommand("copy")},nodeAction(s,e={}){s==="exportNode"?this.exportNode():e.mqtt?this.sendMqttAction(s,e.confirm):this.sendAction(s,{...e,nodeId:this.node.id})},exportNode(){this.app.exportConfiguration(this.node,"node_"+this.node.id,"json")},async sendMqttAction(s,e){if(this.node){let t=!0;if(e&&(t=await this.app.confirm("Info",e,"info",{confirmText:"Ok"})),t){const o=[this.node.id],n={api:s,args:o};this.socket.emit(f.mqtt,n,a=>{a.success?this.showSnackbar(`Node ${this.node.id}: ${s} successfully sent `,"success"):this.showSnackbar(`Error sending ${s} to node ${this.node.id}: ${a.message}`,"error")})}}},toggleStatistics(){this.showStatistics=!this.showStatistics},openLink(s){window.open(s,"_blank")},toggleAutoScroll(){this.autoScroll=!this.autoScroll},toggleSort(){this.inverseSort=!this.inverseSort},async scrollBottom(){if(!this.autoScroll||this.inverseSort)return;const s=this.$refs.eventsList;s&&(await this.$nextTick(),s.scrollTop=s.scrollHeight)}}};var g=function(){var e=this,t=e._self._c;return e.node?t("div",{style:`max-width: calc(100vw - ${e.$vuetify.breakpoint.lgAndUp?120:70}px)`},[t("v-row",{staticClass:"mt-2",attrs:{align:"center"}},[t("v-col",{staticClass:"ml-4",staticStyle:{"min-width":"200px"}},[t("span",{staticClass:"title grey--text"},[e._v("Device ")]),t("br"),t("span",{staticClass:"subtitle font-weight-bold font-monospace"},[e._v(" "+e._s(e.node.hexId)+" ")]),t("v-icon",{staticClass:"ml-2",on:{click:function(o){return e.openLink(e.node.dbLink)}}},[e._v(" open_in_new ")]),t("br"),e.$vuetify.breakpoint.smAndDown?t("span",{staticClass:"comment font-weight-bold primary--text"},[e._v(" "+e._s(`${e.node.manufacturer||""}${e.node.productDescription?" - "+e.node.productDescription:""}`)+" ")]):e._e()],1),t("v-col",{class:e.$vuetify.breakpoint.smAndDown?"text-center":"text-end"},[t("v-item-group",{staticClass:"v-btn-toggle"},[t("v-btn",{attrs:{color:"primary",outlined:""},on:{click:e.toggleStatistics}},[t("v-icon",{attrs:{left:""}},[e._v(" "+e._s(e.statisticsOpeningIndicator)+" ")]),e._v(" Statistics "),t("v-icon",{attrs:{color:"primary",right:""}},[e._v(" multiline_chart ")])],1),e.node.isControllerNode?e._e():t("v-btn",{attrs:{dark:"",color:"primary",depressed:""},on:{click:function(o){return o.stopPropagation(),e.pingNode(e.node)}}},[e._v(" Ping ")]),t("v-btn",{attrs:{dark:"",color:"green",depressed:""},on:{click:function(o){e.advancedShowDialog=!0}}},[e._v(" Advanced ")])],1)],1)],1),e.nodeComments.length>0?t("v-row",[t("v-col",e._l(e.nodeComments,function(o){return t("v-alert",{key:o.level,staticStyle:{"white-space":"break-spaces"},attrs:{text:"",type:o.level}},[t("span",{domProps:{innerHTML:e._s(e.linkify(o.text))}})])}),1)],1):e._e(),t("v-row",{attrs:{"no-gutters":""}},[e.showStatistics?t("v-sheet",{staticClass:"my-4",attrs:{outlined:"",rounded:""}},[t("statistics-card",{attrs:{title:"Statistics",node:e.node}})],1):e._e()],1),t("v-divider",{staticClass:"my-4"}),t("v-tabs",{staticClass:"transparent mb-4",attrs:{"show-arrows":"",vertical:e.$vuetify.breakpoint.mdAndUp},model:{value:e.currentTab,callback:function(o){e.currentTab=o},expression:"currentTab"}},[t("v-tab",{key:"node",staticClass:"justify-start"},[t("v-icon",{attrs:{small:"",left:""}},[e._v("widgets")]),e._v(" Node ")],1),e.nodeMetadata?t("v-tab",{key:"manual",staticClass:"justify-start"},[t("v-icon",{attrs:{small:"",left:""}},[e._v("help")]),e._v(" Help ")],1):e._e(),e.showHass?t("v-tab",{key:"homeassistant",staticClass:"justify-start"},[t("v-icon",{attrs:{small:"",left:""}},[e._v("home")]),e._v(" Home Assistant ")],1):e._e(),t("v-tab",{key:"groups",staticClass:"justify-start"},[t("v-icon",{attrs:{small:"",left:""}},[e._v("device_hub")]),e._v(" Groups ")],1),e.node.schedule?t("v-tab",{key:"users",staticClass:"justify-start"},[t("v-icon",{attrs:{small:"",left:""}},[e._v("group")]),e._v(" Users ")],1):e._e(),e.node.isControllerNode?e._e():t("v-tab",{key:"ota",staticClass:"justify-start"},[t("v-icon",{attrs:{small:"",left:""}},[e._v("auto_mode")]),e._v(" OTA Updates ")],1),t("v-tab",{key:"events",staticClass:"justify-start"},[t("v-icon",{attrs:{small:"",left:""}},[e._v("list_alt")]),e._v(" Events ")],1),e.$vuetify.breakpoint.mdAndUp?t("v-tab",{key:"debug",staticClass:"justify-start"},[t("v-icon",{attrs:{small:"",left:""}},[e._v("bug_report")]),e._v(" Debug Info ")],1):e._e(),t("v-tabs-items",{staticStyle:{background:"transparent","padding-bottom":"10px"},attrs:{touchless:""},model:{value:e.currentTab,callback:function(o){e.currentTab=o},expression:"currentTab"}},[t("v-tab-item",{key:"node",attrs:{transition:"slide-y-transition"}},[t("node-details",{ref:"nodeDetails",attrs:{headers:e.headers,node:e.node},on:{updateValue:e.updateValue}})],1),e.nodeMetadata?t("v-tab-item",{key:"manual",attrs:{transition:"slide-y-transition"}},e._l(e.metaKeys,function(o){return t("section",{key:`tab-${o}`,staticClass:"px-8 py-4"},[t("h1",{staticClass:"text-uppercase"},[e._v(e._s(o))]),t("p",{staticClass:"caption"},[o==="manual"?t("v-btn",{attrs:{href:e.nodeMetadata[o],color:"primary"}},[e._v(" DOWNLOAD ")]):t("span",[e._v(" "+e._s(e.nodeMetadata[o])+" ")])],1)])}),0):e._e(),e.showHass?t("v-tab-item",{key:"homeassistant",attrs:{transition:"slide-y-transition"}},[t("home-assistant",{attrs:{node:e.node,socket:e.socket}})],1):e._e(),t("v-tab-item",{key:"groups",attrs:{transition:"slide-y-transition"}},[t("association-groups",{attrs:{node:e.node}})],1),e.node.schedule?t("v-tab-item",{key:"users",attrs:{transition:"slide-y-transition"}},[t("user-code-table",{attrs:{node:e.node},on:{updateValue:e.updateValue}})],1):e._e(),e.node.isControllerNode?e._e():t("v-tab-item",{key:"ota",attrs:{transition:"slide-y-transition"}},[t("OTAUpdates",{attrs:{node:e.node,socket:e.socket}})],1),t("v-tab-item",{key:"events",attrs:{transition:"slide-y-transition"}},[t("v-container",{attrs:{"grid-list-md":""}},[t("v-text-field",{staticClass:"pa-3",staticStyle:{"max-width":"300px"},attrs:{"prepend-icon":"search",label:"Search","single-line":"","hide-details":"",clearable:""},model:{value:e.searchEvents,callback:function(o){e.searchEvents=o},expression:"searchEvents"}},[t("template",{slot:"append-outer"},[e.inverseSort?e._e():t("v-tooltip",{attrs:{bottom:""},scopedSlots:e._u([{key:"activator",fn:function({on:o,attrs:n}){return[t("v-btn",e._g(e._b({class:e.autoScroll?"border-primary":"",attrs:{icon:"",color:e.autoScroll?"primary":""},on:{click:function(a){return e.toggleAutoScroll()}}},"v-btn",n,!1),o),[t("v-icon",[e._v("autorenew")])],1)]}}],null,!1,4134759629)},[t("span",[e._v("Enable/Disable auto scroll")])]),t("v-tooltip",{attrs:{bottom:""},scopedSlots:e._u([{key:"activator",fn:function({on:o,attrs:n}){return[t("v-btn",e._g(e._b({class:e.inverseSort?"border-primary":"",attrs:{icon:"",color:e.inverseSort?"primary":""},on:{click:function(a){return e.toggleSort()}}},"v-btn",n,!1),o),[t("v-icon",[e._v("swap_vert")])],1)]}}],null,!1,189129518)},[t("span",[e._v("Inverse Sort")])])],1)],2),t("v-col",{ref:"eventsList",staticClass:"pa-5 events-list"},e._l(e.filteredNodeEvents,function(o,n){return t("div",{key:"event_"+n+o.time,staticClass:"log-row font-monospace"},[t("span",[t("i",[e._v(e._s(e.getDateTimeString(o.time)))])]),e._v(" - "),t("strong",{staticClass:"text-uppercase"},[e._v(e._s(o.event))]),e._l(o.args,function(a,l){return t("span",{key:"arg_"+l,staticStyle:{"white-space":"pre","font-size":"0.75rem"}},[e._v(e._s(e.prettyPrintEventArg(a,l)))])})],2)}),0)],1)],1),e.$vuetify.breakpoint.mdAndUp?t("v-tab-item",{key:"debug",attrs:{transition:"slide-y-transition"}},[t("v-container",{attrs:{"grid-list-md":""}},[t("v-textarea",{ref:"nodeJsonContent",staticClass:"debug-content font-monospace mx-2",attrs:{"append-icon":"content_copy",readonly:"","hide-details":"","no-resize":"",rows:"37"},on:{"click:append":e.copyText},model:{value:e.nodeJson,callback:function(o){e.nodeJson=o},expression:"nodeJson"}})],1)],1):e._e()],1)],1),t("DialogAdvanced",{attrs:{actions:e.advancedActions},on:{close:function(o){e.advancedShowDialog=!1},action:e.nodeAction},model:{value:e.advancedShowDialog,callback:function(o){e.advancedShowDialog=o},expression:"advancedShowDialog"}})],1):e._e()},b=[],w=_(y,g,b,!1,null,null);const S=w.exports;export{S as default};