zwave-js-ui
Version:
Z-Wave Control Panel and MQTT Gateway
7 lines (6 loc) • 16 kB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ValueId-9SzBH8cQ.js","./index-CtTdmJsx.js","./index-2j-kvxFz.css","./ValueId-DQh_tBTf.css"])))=>i.map(i=>d[i]);
import{_ as B,I as E,b as T,m as F,u as P,a as V,ax as A,n as q}from"./index-CtTdmJsx.js";function $(n){return Object.prototype.toString.call(n)==="[object Object]"}var p;(function(n){n[n.NoSupport=0]="NoSupport",n[n.Working=1]="Working",n[n.Fail=2]="Fail",n[n.Success=255]="Success"})(p||(p={}));function G(n){return $(n)&&"status"in n&&typeof p[n.status]=="string"}function M(n){return G(n)&&(n.status===p.Success||n.status===p.Working)}function H(n){return!n||M(n)}const c=Object.freeze({UInt8:Object.freeze({min:0,max:255}),UInt16:Object.freeze({min:0,max:65535}),UInt24:Object.freeze({min:0,max:16777215}),UInt32:Object.freeze({min:0,max:4294967295}),Int8:Object.freeze({min:-128,max:127}),Int16:Object.freeze({min:-32768,max:32767}),Int24:Object.freeze({min:-8388608,max:8388607}),Int32:Object.freeze({min:-2147483648,max:2147483647})}),d=()=>n=>n,m=d(),o=d(),O=d(),u=d(),g=d(),C=d();var f;(function(n){n[n.SignedInteger=0]="SignedInteger",n[n.UnsignedInteger=1]="UnsignedInteger",n[n.Enumerated=2]="Enumerated",n[n.BitField=3]="BitField"})(f||(f={}));const r=m({type:"any",readable:!0,writeable:!0}),i={writeable:!1},l={readable:!1},X=m({...r}),Y=m({...r,...i}),K=m({...r,...l}),x=O({...r,type:"boolean"}),J=O({...x,...i}),Q=O({...x,...l}),w=o({...r,type:"number"}),Z=o({...w,...i}),ee=o({...w,...l}),v=o({...r,type:"number",...c.UInt8}),te=o({...v,...i}),ne=o({...v,...l}),R=o({...r,type:"number",...c.UInt16}),se=o({...R,...i}),oe=o({...R,...l}),I=o({...r,type:"number",...c.UInt24}),ae=o({...I,...i}),re=o({...I,...l}),_=o({...r,type:"number",...c.UInt32}),ie=o({..._,...i}),le=o({..._,...l}),z=o({...r,type:"number",...c.Int8}),ce=o({...z,...i}),de=o({...z,...l}),k=o({...r,type:"number",...c.Int16}),ue=o({...k,...i}),fe=o({...k,...l}),j=o({...r,type:"number",...c.Int24}),pe=o({...j,...i}),me=o({...j,...l}),S=o({...r,type:"number",...c.Int32}),ve=o({...S,...i}),he=o({...S,...l}),h=u({...r,type:"string"}),be=u({...h,...i}),ye=u({...h,...l}),L=u({...h,type:"color"}),Oe=u({...L,...i}),ge=u({...L,...l}),N=o({...v,max:99}),Ce=o({...N,...i}),xe=o({...N,...l}),U=C({...r,type:"duration"}),we=C({...U,...i}),Re=C({...U,...l}),W=g({...r,type:"buffer"}),Ie=g({...W,...i}),_e=g({...W,...l});Object.freeze(X),Object.freeze(Y),Object.freeze(K),Object.freeze(w),Object.freeze(Z),Object.freeze(ee),Object.freeze(v),Object.freeze(R),Object.freeze(I),Object.freeze(_),Object.freeze(z),Object.freeze(k),Object.freeze(j),Object.freeze(S),Object.freeze(te),Object.freeze(se),Object.freeze(ae),Object.freeze(ie),Object.freeze(ce),Object.freeze(ue),Object.freeze(pe),Object.freeze(ve),Object.freeze(ne),Object.freeze(oe),Object.freeze(re),Object.freeze(le),Object.freeze(de),Object.freeze(fe),Object.freeze(me),Object.freeze(he),Object.freeze(N),Object.freeze(Ce),Object.freeze(xe),Object.freeze(x),Object.freeze(J),Object.freeze(Q),Object.freeze(h),Object.freeze(be),Object.freeze(ye),Object.freeze(L),Object.freeze(Oe),Object.freeze(ge),Object.freeze(U),Object.freeze(we),Object.freeze(Re),Object.freeze(W),Object.freeze(Ie),Object.freeze(_e);const ze={props:{headers:Array,node:Object},components:{ValueID:()=>B(()=>import("./ValueId-9SzBH8cQ.js"),__vite__mapDeps([0,1,2,3]),import.meta.url)},mixins:[E],data(){return{locError:null,nameError:null,options:{},maxLRPowerLevels:T,newName:this.node.name,newLoc:this.node.loc,configCCValueFormats:[{text:"Signed",value:f.SignedInteger},{text:"Unsigned",value:f.UnsignedInteger}],configCC:{value:0,valueSize:1,parameter:1,valueFormat:f.UnsignedInteger}}},computed:{...F(P,["mqtt"]),commandGroups(){if(this.node){const n={};let e=!0;for(const t of this.node.values){const s=t.commandClassName+" v"+t.commandClassVersion;n[s]||(t.commandClassName==="Configuration"&&(e=!1),n[s]=[]),n[s].push(t)}return e&&(n.Configuration=[]),n}else return{}}},watch:{node(){this.newName=this.node.name,this.newLoc=this.node.loc},newLoc(n){this.locError=this.validateTopic(n)},newName(n){this.nameError=this.validateTopic(n)}},mounted(){this.options={transitionDuration:this.node.defaultTransitionDuration,volume:this.node.defaultVolume}},methods:{...V(P,["showSnackbar"]),async setDefaults(n){let e="";switch(n){case"transitionDuration":e="defaultTransitionDuration";break;case"volume":e="defaultVolume";break}if(!e)return;(await this.app.apiRequest("setNodeDefaultSetValueOptions",[this.node.id,{[e]:this.options[n]}])).success&&this.showSnackbar(`Default node ${n} updated successffully`,"success")},async updateControllerNodeProp(n){(await this.app.apiRequest("updateControllerNodeProps",[null,[n]])).success&&this.showSnackbar("Powerlevel updated","success")},canResetConfig(n){return n&&n.commandClass===112&&n.commandClassVersion>3},async resetAllConfig(){await this.app.confirm("Attention","Are you sure you want to reset all configurations to default?","alert")&&(await this.app.apiRequest("sendCommand",[{nodeId:this.node.id,commandClass:112},"resetAll",[]])).success&&this.showSnackbar("All config values resetted","success")},async resetConfig(){(await this.app.apiRequest("sendCommand",[{nodeId:this.node.id,commandClass:112},"reset",[this.configCC.parameter]])).success&&this.showSnackbar(`Parameter ${this.configCC.parameter}: resetted`,"success")},async refreshCCValues(n){(await this.app.apiRequest("refreshCCValues",[this.node.id,n])).success&&this.showSnackbar(`Values of CC ${n} refreshed`,"success")},async configurationGet(){const n=await this.app.apiRequest("sendCommand",[{nodeId:this.node.id,commandClass:112},"get",[this.configCC.parameter]]);n.success&&this.showSnackbar(`Parameter ${this.configCC.parameter}: ${n.result}`,"success")},async configurationSet(){const n=await this.app.apiRequest("sendCommand",[{nodeId:this.node.id,commandClass:112},"set",[{parameter:this.configCC.parameter,value:this.configCC.value,valueSize:this.configCC.valueSize,valueFormat:this.configCC.valueFormat}]]);n.success&&(H(n.result)?this.showSnackbar(`Parameter ${this.configCC.parameter} set successfully`,"success"):this.showSnackbar(`Parameter ${this.configCC.parameter} set failed`,"error"))},getValue(n){return this.node&&this.node.values?this.node.values.find(e=>e.id===n.id):null},resetLocation(){setTimeout(()=>{this.newLoc=this.node.loc},10)},resetName(){setTimeout(()=>{this.newName=this.node.name},10)},async updatePowerLevel(){if(this.node){const n=[this.node.powerlevel,this.node.measured0dBm];(await this.app.apiRequest("setPowerlevel",n)).success&&this.showSnackbar("Powerlevel updated","success")}},async updateRFRegion(){if(this.node){const n=[this.node.RFRegion];(await this.app.apiRequest("setRFRegion",n)).success&&this.showSnackbar("RF Region updated","success")}},async updateMaxLRPowerLevel(){if(this.node){const n=[this.node.maxLongRangePowerlevel];(await this.app.apiRequest("setMaxLRPowerLevel",n)).success&&this.showSnackbar("Maximum LR power level updated","success")}},async updateLoc(){this.node&&!this.locError&&(await this.app.apiRequest("setNodeLocation",[this.node.id,this.newLoc])).success&&this.showSnackbar("Node location updated","success")},async updateName(){this.node&&!this.nameError&&(await this.app.apiRequest("setNodeName",[this.node.id,this.newName])).success&&this.showSnackbar("Node name updated","success")},updateValue(n,e){this.$emit("updateValue",n,e)},validateTopic(n){const e=this.mqtt.disabled?"":A(n);return typeof e=="string"?e:""}}};var ke=function(){var e=this,t=e._self._c;return t("v-container",{attrs:{fluid:""}},[t("v-row",[t("v-col",{staticStyle:{"max-width":"300px"},attrs:{cols:"12",sm:"6"}},[t("v-text-field",{attrs:{label:"Name","append-outer-icon":"send",error:!!e.nameError,"error-messages":e.nameError,clearable:"","clear-icon":"refresh"},on:{"click:clear":e.resetName,"click:append-outer":e.updateName},model:{value:e.newName,callback:function(s){e.newName=typeof s=="string"?s.trim():s},expression:"newName"}})],1),t("v-col",{staticStyle:{"max-width":"300px"},attrs:{cols:"12",sm:"6"}},[t("v-text-field",{attrs:{label:"Location","append-outer-icon":"send",error:!!e.locError,"error-messages":e.locError,clearable:"","clear-icon":"refresh"},on:{"click:clear":e.resetLocation,"click:append-outer":e.updateLoc},model:{value:e.newLoc,callback:function(s){e.newLoc=typeof s=="string"?s.trim():s},expression:"newLoc"}})],1)],1),e.node.isControllerNode?[t("v-subheader",{staticClass:"title",staticStyle:{padding:"0"}},[e._v("Controller Options")]),t("v-row",[t("v-col",{staticStyle:{"max-width":"300px"},attrs:{cols:"12"}},[t("v-select",{attrs:{label:"RF Region",items:e.node.rfRegions},scopedSlots:e._u([{key:"append-outer",fn:function(){return[t("v-btn",{attrs:{color:"primary",small:"",icon:""},on:{click:function(s){return e.updateControllerNodeProp("RFRegion")}}},[t("v-icon",[e._v("refresh")])],1),t("v-btn",{attrs:{color:"primary",small:"",icon:""},on:{click:e.updateRFRegion}},[t("v-icon",[e._v("send")])],1)]},proxy:!0}],null,!1,3815849893),model:{value:e.node.RFRegion,callback:function(s){e.$set(e.node,"RFRegion",s)},expression:"node.RFRegion"}})],1)],1),t("v-row",[t("v-col",{staticStyle:{"max-width":"300px"},attrs:{cols:"12",sm:"6"}},[t("v-text-field",{attrs:{label:"Normal Power Level",min:-10,max:20,step:.1,suffix:"dBm",type:"number"},model:{value:e.node.powerlevel,callback:function(s){e.$set(e.node,"powerlevel",e._n(s))},expression:"node.powerlevel"}})],1),t("v-col",{staticStyle:{"max-width":"300px"},attrs:{cols:"12",sm:"6"}},[t("v-text-field",{attrs:{label:"Measured output power at 0 dBm","append-outer-icon":"send",min:-10,max:10,step:.1,suffix:"dBm",type:"number"},scopedSlots:e._u([{key:"append-outer",fn:function(){return[t("v-btn",{attrs:{color:"primary",small:"",icon:""},on:{click:function(s){return e.updateControllerNodeProp("powerlevel")}}},[t("v-icon",[e._v("refresh")])],1),t("v-btn",{attrs:{color:"primary",small:"",icon:""},on:{click:e.updatePowerLevel}},[t("v-icon",[e._v("send")])],1)]},proxy:!0}],null,!1,8418117),model:{value:e.node.measured0dBm,callback:function(s){e.$set(e.node,"measured0dBm",e._n(s))},expression:"node.measured0dBm"}})],1)],1),e.node.supportsLongRange?t("v-row",[t("v-col",{staticStyle:{"max-width":"300px"},attrs:{cols:"12"}},[t("v-select",{attrs:{label:"Maximum LR Power Level",items:e.maxLRPowerLevels},scopedSlots:e._u([{key:"append-outer",fn:function(){return[t("v-btn",{attrs:{color:"primary",small:"",icon:""},on:{click:function(s){return e.updateControllerNodeProp("maxLongRangePowerlevel")}}},[t("v-icon",[e._v("refresh")])],1),t("v-btn",{attrs:{color:"primary",small:"",icon:""},on:{click:e.updateMaxLRPowerLevel}},[t("v-icon",[e._v("send")])],1)]},proxy:!0}],null,!1,2435772331),model:{value:e.node.maxLongRangePowerlevel,callback:function(s){e.$set(e.node,"maxLongRangePowerlevel",s)},expression:"node.maxLongRangePowerlevel"}})],1)],1):e._e(),t("v-col",{staticStyle:{"max-width":"700px"},attrs:{dense:""}},[t("v-alert",{attrs:{text:"",type:"warning"}},[t("strong",[e._v("DO NOT CHANGE THESE VALUES UNLESS YOU KNOW WHAT YOU ARE DOING ")]),t("small",[e._v("Increasing the TX power (normal power level) may be "),t("b",[e._v("illegal")]),e._v(", depending on where you are located. ")]),t("small",[e._v('Increasing the TX power will only make the nodes "hear" the controller better, but not vice versa')])]),t("v-alert",{staticClass:"pb-0",staticStyle:{"white-space":"break-spaces"},attrs:{text:"",type:"info"}},[t("small",[e._v(e._s("Please consult the manufacturer for the default values, as these can vary between different sticks.")+" ")])])],1)]:e._e(),e.node.isControllerNode?e._e():t("div",[t("v-subheader",{staticClass:"title",staticStyle:{padding:"0"}},[e._v("Send Options")]),t("v-row",{staticClass:"mt-0"},[t("v-col",{staticStyle:{"max-width":"300px","padding-top":"0"},attrs:{cols:"12",sm:"6"}},[t("v-text-field",{attrs:{label:"Transition duration",hint:"Ex: '10s' (10 seconds)","persistent-hint":"","append-icon":"clear","append-outer-icon":"save"},on:{"click:append":function(s){e.options.transitionDuration=e.node.defaultTransitionDuration||""},"click:append-outer":function(s){return e.setDefaults("transitionDuration")}},model:{value:e.options.transitionDuration,callback:function(s){e.$set(e.options,"transitionDuration",typeof s=="string"?s.trim():s)},expression:"options.transitionDuration"}})],1),t("v-col",{staticStyle:{"max-width":"300px","padding-top":"0"},attrs:{cols:"12",sm:"6"}},[t("v-text-field",{attrs:{label:"Volume",hint:"The volume (for the Sound Switch CC)","persistent-hint":"","append-icon":"clear","append-outer-icon":"save"},on:{"click:append":function(s){e.options.volume=e.node.defaultVolume||""},"click:append-outer":function(s){return e.setDefaults("volume")}},model:{value:e.options.volume,callback:function(s){e.$set(e.options,"volume",typeof s=="string"?s.trim():s)},expression:"options.volume"}})],1)],1),t("v-row",[t("v-subheader",{staticClass:"title"},[e._v("Values")]),t("v-expansion-panels",{staticClass:"expansion-panels-outlined",attrs:{accordion:"",multiple:"",flat:""}},e._l(e.commandGroups,function(s,b){return t("v-expansion-panel",{key:b},[t("v-expansion-panel-header",[t("v-row",{attrs:{"no-gutters":""}},[t("v-col",{attrs:{"align-self":"center"}},[e._v(" "+e._s(b)+" ")]),t("v-col",{staticClass:"text-right"},[e.canResetConfig(s[0])?t("v-btn",{staticClass:"mb-1 mr-3",attrs:{color:"error",outlined:"","x-small":""},on:{click:function(a){return a.stopPropagation(),e.resetAllConfig()}}},[e._v(" Reset "),t("v-icon",{attrs:{"x-small":"",right:""}},[e._v("clear")])],1):e._e(),s[0]?t("v-btn",{staticClass:"mb-1",attrs:{color:"primary",outlined:"","x-small":""},on:{click:function(a){return a.stopPropagation(),e.refreshCCValues(s[0].commandClass)}}},[e._v(" Refresh "),t("v-icon",{attrs:{"x-small":"",right:""}},[e._v("refresh")])],1):e._e()],1)],1)],1),t("v-expansion-panel-content",[t("v-row",e._l(s,function(a,y){return t("v-col",{key:y,attrs:{cols:"12",sm:"6",md:"4"}},[t("ValueID",{attrs:{node:e.node},on:{updateValue:e.updateValue},model:{value:s[y],callback:function(D){e.$set(s,y,D)},expression:"group[index]"}})],1)}),1),t("v-row",[b.startsWith("Configuration")?t("v-col",{attrs:{cols:"12",sm:"6",md:"4"}},[t("v-subheader",{staticClass:"valueid-label"},[e._v("Custom Configuration ")]),t("v-row",[t("v-col",{attrs:{cols:"3"}},[t("v-text-field",{attrs:{label:"Parameter","hide-details":""},model:{value:e.configCC.parameter,callback:function(a){e.$set(e.configCC,"parameter",e._n(a))},expression:`
configCC.parameter
`}})],1),t("v-col",{attrs:{cols:"3"}},[t("v-select",{attrs:{label:"Size","hide-details":"",items:[1,2,3,4]},model:{value:e.configCC.valueSize,callback:function(a){e.$set(e.configCC,"valueSize",e._n(a))},expression:`
configCC.valueSize
`}})],1),t("v-col",{attrs:{cols:"3"}},[t("v-text-field",{attrs:{label:"Value","hide-details":""},model:{value:e.configCC.value,callback:function(a){e.$set(e.configCC,"value",e._n(a))},expression:"configCC.value"}})],1),t("v-col",{attrs:{cols:e.$vuetify.breakpoint.xsOnly?4:3}},[t("v-select",{attrs:{label:"Format","hide-details":"",items:e.configCCValueFormats},model:{value:e.configCC.valueFormat,callback:function(a){e.$set(e.configCC,"valueFormat",a)},expression:"configCC.valueFormat"}})],1),t("v-col",{staticClass:"d-flex",staticStyle:{gap:"10px"}},[t("v-btn",{attrs:{width:"60px",color:"green","x-small":"",dark:""},on:{click:function(a){return a.stopPropagation(),e.configurationGet()}}},[e._v(" GET ")]),t("v-btn",{attrs:{width:"60px",color:"primary","x-small":""},on:{click:function(a){return a.stopPropagation(),e.configurationSet()}}},[e._v(" SET ")]),e.canResetConfig(s[0])?t("v-btn",{attrs:{width:"60px","x-small":"",color:"error"},on:{click:function(a){return a.stopPropagation(),e.resetConfig.apply(null,arguments)}}},[e._v("Reset")]):e._e()],1)],1)],1):e._e()],1)],1),t("v-divider")],1)}),1)],1)],1)],2)},je=[],Se=q(ze,ke,je,!1,null,null);const Ne=Se.exports;export{Ne as default};