iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 10.4 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[58679],{11244:function(e,i,s){s.d(i,{c:function(){return o},q:function(){return t}});const t=(e,i,s,t)=>e.connection.subscribeMessage(s,{type:"mqtt/subscribe",topic:i,qos:t}),o=(e,i)=>e.callWS({type:"mqtt/device/debug_info",device_id:i})},3338:function(e,i,s){s.a(e,async function(e,t){try{s.r(i);s(18111),s(61701),s(3362),s(62953);var o=s(40445),a=s(5124),d=s(67576),r=s(37981),l=s(28978),n=s(1087),h=(s(93444),s(6),s(59646)),p=s(72554),c=s(18350),g=s(11244),m=s(14503),y=(s(60415),s(86428)),_=e([h,p,c,y]);[h,p,c,y]=_.then?(await _)():_;let u,f,v,$,b,w,x,q,z,C,A=e=>e;class T extends a.WF{async showDialog(e){this._params=e,this._open=!0,(0,g.c)(this.hass,e.device.id).then(e=>{this._debugInfo=e})}render(){return this._params&&this._debugInfo?(0,a.qy)(u||(u=A` <ha-dialog .open="${0}" width="large" header-title="${0}" ="${0}"> <h4> ${0} </h4> <div> <ha-formfield .label="${0}"> <ha-switch .checked="${0}" ="${0}" autofocus> </ha-switch> </ha-formfield> </div> <div> <ha-formfield .label="${0}"> <ha-switch .checked="${0}" ="${0}"> </ha-switch> </ha-formfield> </div> <h4> ${0} </h4> <ul class="entitylist"> ${0} </ul> <h4> ${0} </h4> <ul class="triggerlist"> ${0} </ul> <ha-dialog-footer slot="footer"> <ha-button slot="primaryAction" ="${0}"> ${0} </ha-button> </ha-dialog-footer> </ha-dialog> `),this._open,this.hass.localize("ui.dialogs.mqtt_device_debug_info.title",{device:(0,r.T)(this._params.device,this.hass.localize,this.hass.states)}),this._dialogClosed,this.hass.localize("ui.dialogs.mqtt_device_debug_info.payload_display"),this.hass.localize("ui.dialogs.mqtt_device_debug_info.deserialize"),this._showDeserialized,this._showDeserializedChanged,this.hass.localize("ui.dialogs.mqtt_device_debug_info.show_as_yaml"),this._showAsYaml,this._showAsYamlChanged,this.hass.localize("ui.dialogs.mqtt_device_debug_info.entities"),this._debugInfo.entities.length?this._renderEntities():(0,a.qy)(f||(f=A` ${0} `),this.hass.localize("ui.dialogs.mqtt_device_debug_info.no_entity_debug_info")),this.hass.localize("ui.dialogs.mqtt_device_debug_info.triggers"),this._debugInfo.triggers.length?this._renderTriggers():(0,a.qy)(v||(v=A` ${0} `),this.hass.localize("ui.dialogs.mqtt_device_debug_info.no_trigger_debug_info")),this._close,this.hass.localize("ui.common.close")):a.s6}_close(){this._open=!1}_dialogClosed(){this._params=void 0,this._debugInfo=void 0,(0,n.r)(this,"dialog-closed",{dialog:this.localName})}_showAsYamlChanged(e){this._showAsYaml=e.target.checked}_showDeserializedChanged(e){this._showDeserialized=e.target.checked}_renderEntities(){return(0,a.qy)($||($=A` ${0} `),this._debugInfo.entities.map(e=>(0,a.qy)(b||(b=A` <li class="entitylistitem"> ${0} (<code>${0}</code>) <br>MQTT discovery data: <ul class="discoverydata"> <li> Topic: <code>${0}</code> </li> <li> <mqtt-discovery-payload .hass="${0}" .payload="${0}" .showAsYaml="${0}" .summary="${0}"> </mqtt-discovery-payload> </li> </ul> Subscribed topics: <ul> ${0} </ul> Transmitted messages: <ul> ${0} </ul> </li> `),(0,l.u)(this.hass.states[e.entity_id]),e.entity_id,e.discovery_data.topic,this.hass,e.discovery_data.payload,this._showAsYaml,"Payload",e.subscriptions.map(e=>(0,a.qy)(w||(w=A` <li> <code>${0}</code> <mqtt-messages .hass="${0}" direction="Received" .messages="${0}" .showDeserialized="${0}" .showAsYaml="${0}" .subscribedTopic="${0}" .summary="${0}"> </mqtt-messages> </li> `),e.topic,this.hass,e.messages,this._showDeserialized,this._showAsYaml,e.topic,this.hass.localize("ui.dialogs.mqtt_device_debug_info.recent_messages",{n:e.messages.length}))),e.transmitted.map(e=>(0,a.qy)(x||(x=A` <li> <code>${0}</code> <mqtt-messages .hass="${0}" direction="Transmitted" .messages="${0}" .showDeserialized="${0}" .showAsYaml="${0}" .subscribedTopic="${0}" .summary="${0}"> </mqtt-messages> </li> `),e.topic,this.hass,e.messages,this._showDeserialized,this._showAsYaml,e.topic,this.hass.localize("ui.dialogs.mqtt_device_debug_info.recent_tx_messages",{n:e.messages.length}))))))}_renderTriggers(){return(0,a.qy)(q||(q=A` ${0} `),this._debugInfo.triggers.map(e=>(0,a.qy)(z||(z=A` <li class="triggerlistitem"> MQTT discovery data: <ul class="discoverydata"> <li> Topic: <code>${0}</code> </li> <li> <mqtt-discovery-payload .hass="${0}" .payload="${0}" .showAsYaml="${0}" .summary="${0}"> </mqtt-discovery-payload> </li> </ul> </li> `),e.discovery_data.topic,this.hass,e.discovery_data.payload,this._showAsYaml,"Payload")))}static get styles(){return[m.nA,(0,a.AH)(C||(C=A`ha-switch{margin:16px}.discoverydata{list-style-type:none;margin:4px;padding-left:16px;padding-inline-start:16px;padding-inline-end:initial}.entitylistitem{margin-bottom:12px}.triggerlistitem{margin-bottom:12px}`))]}constructor(...e){super(...e),this._open=!1,this._showAsYaml=!0,this._showDeserialized=!0}}(0,o.Cg)([(0,d.wk)()],T.prototype,"_params",void 0),(0,o.Cg)([(0,d.wk)()],T.prototype,"_debugInfo",void 0),(0,o.Cg)([(0,d.wk)()],T.prototype,"_open",void 0),(0,o.Cg)([(0,d.wk)()],T.prototype,"_showAsYaml",void 0),(0,o.Cg)([(0,d.wk)()],T.prototype,"_showDeserialized",void 0),T=(0,o.Cg)([(0,d.EM)("dialog-mqtt-device-debug-info")],T),t()}catch(u){t(u)}})},60415:function(e,i,s){s(33110),s(62953);var t=s(40445),o=s(53289),a=s(5124),d=s(67576),r=s(6412);let l,n,h,p,c,g,m=e=>e;class y extends a.WF{render(){return(0,a.qy)(l||(l=m` <div class="expander ${0}" ="${0}"> ${0} </div> ${0} `),(0,r.H)({open:this._open}),this._handleToggle,this.summary,this._open?(0,a.qy)(n||(n=m` <div class="payload">${0}</div>`),this._renderPayload()):"")}_renderPayload(){const e=this.payload;return(0,a.qy)(h||(h=m` ${0} `),this.showAsYaml?(0,a.qy)(p||(p=m` <pre>${0}</pre> `),(0,o.dump)(e)):(0,a.qy)(c||(c=m` <pre>${0}</pre> `),JSON.stringify(e,null,2)))}_handleToggle(){this._open=!this._open}constructor(...e){super(...e),this.showAsYaml=!1,this._open=!1}}y.styles=(0,a.AH)(g||(g=m`.expander{cursor:pointer;position:relative;padding:8px;padding-left:29px;padding-inline-start:29px;padding-inline-end:initial;border:1px solid var(--divider-color)}.expander:before{content:"";position:absolute;border-right:2px solid var(--primary-text-color);border-bottom:2px solid var(--primary-text-color);width:5px;height:5px;top:50%;left:12px;transform:translateY(-50%) rotate(-45deg)}.expander.open:before{transform:translateY(-50%) rotate(45deg)}.payload{border:1px solid var(--divider-color);border-top:0;padding-left:16px;padding-inline-start:16px;padding-inline-end:initial}pre{display:inline-block;font-size:.9em;padding-left:4px;padding-right:4px;padding-inline-start:4px;padding-inline-end:4px;font-family:var(--ha-font-family-code)}`)),(0,t.Cg)([(0,d.MZ)({attribute:!1})],y.prototype,"payload",void 0),(0,t.Cg)([(0,d.MZ)({attribute:"show-as-yaml",type:Boolean})],y.prototype,"showAsYaml",void 0),(0,t.Cg)([(0,d.MZ)()],y.prototype,"summary",void 0),(0,t.Cg)([(0,d.wk)()],y.prototype,"_open",void 0),y=(0,t.Cg)([(0,d.EM)("mqtt-discovery-payload")],y)},86428:function(e,i,s){s.a(e,async function(e,i){try{s(18111),s(7588),s(61701),s(69112),s(33110),s(88454),s(29452),s(62953);var t=s(40445),o=s(53289),a=s(5124),d=s(67576),r=s(6412),l=s(30162),n=e([l]);l=(n.then?(await n)():n)[0];let h,p,c,g,m,y,_,u,f,v,$=e=>e;class b extends a.WF{firstUpdated(){this.messages.forEach(e=>{this.subscribedTopic!==e.topic&&(this._showTopic=!0)})}render(){return(0,a.qy)(h||(h=$` <div class="expander ${0}" ="${0}"> ${0} </div> ${0} `),(0,r.H)({open:this._open}),this._handleToggle,this.summary,this._open?(0,a.qy)(p||(p=$` <ul class="message-list"> ${0} </ul> `),this.messages.map(e=>(0,a.qy)(c||(c=$` <li class="message"> <div class="time"> ${0} ${0} </div> ${0} </li> `),this.direction,(0,l.ie)(new Date(e.time),this.hass.locale,this.hass.config),this._renderSingleMessage(e)))):"")}_renderSingleMessage(e){const i=e.topic;return(0,a.qy)(g||(g=$` <ul class="message-with-topic"> ${0} <li>QoS: ${0}${0}</li> <li>Payload: ${0}</li> </ul> `),this._showTopic?(0,a.qy)(m||(m=$` <li>Topic: <code>${0}</code></li> `),i):"",e.qos,e.retain?", Retained":"",this._renderSinglePayload(e))}_renderSinglePayload(e){let i;return this.showDeserialized&&(this._payloadsJson.has(e)?i=this._payloadsJson.get(e):(i=this._tryParseJson(e.payload),this._payloadsJson.set(e,i))),i?(0,a.qy)(y||(y=$` ${0} `),this.showAsYaml?(0,a.qy)(_||(_=$` <pre>${0}</pre> `),(0,o.dump)(i)):(0,a.qy)(u||(u=$` <pre>${0}</pre> `),JSON.stringify(i,null,2))):(0,a.qy)(f||(f=$` <code>${0}</code> `),e.payload)}_tryParseJson(e){let i=null,s=e;if("string"==typeof e)try{s=JSON.parse(e)}catch(t){s=null}return s&&"object"==typeof s&&(i=s),i}_handleToggle(){this._open=!this._open}constructor(...e){super(...e),this.showAsYaml=!1,this.showDeserialized=!1,this._open=!1,this._payloadsJson=new WeakMap,this._showTopic=!1}}b.styles=(0,a.AH)(v||(v=$`.expander{cursor:pointer;position:relative;padding:8px;padding-left:29px;padding-inline-start:29px padding-inline-end: initial;border:1px solid var(--divider-color)}.expander:before{content:"";position:absolute;border-right:2px solid var(--primary-text-color);border-bottom:2px solid var(--primary-text-color);width:5px;height:5px;top:50%;left:12px;transform:translateY(-50%) rotate(-45deg)}.expander.open:before{transform:translateY(-50%) rotate(45deg)}.message{font-size:.9em;margin-bottom:12px}.message-list{border:1px solid var(--divider-color);border-top:0;padding-left:28px;padding-inline-start:28px;padding-inline-end:initial;margin:0}pre{display:inline-block;font-size:.9em;margin:0;padding-left:4px;padding-right:4px;padding-inline-start:4px;padding-inline-end:4px;font-family:var(--ha-font-family-code)}`)),(0,t.Cg)([(0,d.MZ)({attribute:!1})],b.prototype,"messages",void 0),(0,t.Cg)([(0,d.MZ)()],b.prototype,"direction",void 0),(0,t.Cg)([(0,d.MZ)({attribute:"show-as-yaml",type:Boolean})],b.prototype,"showAsYaml",void 0),(0,t.Cg)([(0,d.MZ)({attribute:"show-deserialized",type:Boolean})],b.prototype,"showDeserialized",void 0),(0,t.Cg)([(0,d.MZ)({attribute:!1})],b.prototype,"subscribedTopic",void 0),(0,t.Cg)([(0,d.MZ)()],b.prototype,"summary",void 0),(0,t.Cg)([(0,d.wk)()],b.prototype,"_open",void 0),(0,t.Cg)([(0,d.wk)()],b.prototype,"_payloadsJson",void 0),(0,t.Cg)([(0,d.wk)()],b.prototype,"_showTopic",void 0),b=(0,t.Cg)([(0,d.EM)("mqtt-messages")],b),i()}catch(h){i(h)}})}}]);