-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add controller statistics to zwave_js config dashboard #12668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b2e6d50
8f72d99
3519c3b
2e8a62d
75a5cb5
2c5c6c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import "@material/mwc-button/mwc-button"; | ||
| import "@material/mwc-list/mwc-list"; | ||
| import "@material/mwc-list/mwc-list-item"; | ||
| import { | ||
| mdiAlertCircle, | ||
| mdiCheckCircle, | ||
|
|
@@ -11,9 +12,12 @@ import { customElement, property, state } from "lit/decorators"; | |
| import { classMap } from "lit/directives/class-map"; | ||
| import "../../../../../components/ha-card"; | ||
| import "../../../../../components/ha-icon-button"; | ||
| import "../../../../../components/ha-expansion-panel"; | ||
| import "../../../../../components/ha-fab"; | ||
| import "../../../../../components/ha-help-tooltip"; | ||
| import "../../../../../components/ha-icon-next"; | ||
| import "../../../../../components/ha-svg-icon"; | ||
| import { UnsubscribeFunc } from "home-assistant-js-websocket"; | ||
| import { | ||
| fetchZwaveDataCollectionStatus, | ||
| fetchZwaveNetworkStatus, | ||
|
|
@@ -22,7 +26,9 @@ import { | |
| setZwaveDataCollectionPreference, | ||
| stopZwaveExclusion, | ||
| stopZwaveInclusion, | ||
| subscribeZwaveControllerStatistics, | ||
| ZWaveJSClient, | ||
| ZWaveJSControllerStatisticsUpdatedMessage, | ||
| ZWaveJSNetwork, | ||
| ZwaveJSProvisioningEntry, | ||
| } from "../../../../../data/zwave_js"; | ||
|
|
@@ -41,9 +47,10 @@ import { showZWaveJSRemoveNodeDialog } from "./show-dialog-zwave_js-remove-node" | |
| import { configTabs } from "./zwave_js-config-router"; | ||
| import { showOptionsFlowDialog } from "../../../../../dialogs/config-flow/show-dialog-options-flow"; | ||
| import { computeRTL } from "../../../../../common/util/compute_rtl"; | ||
| import { SubscribeMixin } from "../../../../../mixins/subscribe-mixin"; | ||
|
|
||
| @customElement("zwave_js-config-dashboard") | ||
| class ZWaveJSConfigDashboard extends LitElement { | ||
| class ZWaveJSConfigDashboard extends SubscribeMixin(LitElement) { | ||
| @property({ type: Object }) public hass!: HomeAssistant; | ||
|
|
||
| @property({ type: Object }) public route!: Route; | ||
|
|
@@ -52,7 +59,7 @@ class ZWaveJSConfigDashboard extends LitElement { | |
|
|
||
| @property({ type: Boolean }) public isWide!: boolean; | ||
|
|
||
| @property() public configEntryId?: string; | ||
| @property() public configEntryId!: string; | ||
|
|
||
| @state() private _configEntry?: ConfigEntry; | ||
|
|
||
|
|
@@ -66,12 +73,30 @@ class ZWaveJSConfigDashboard extends LitElement { | |
|
|
||
| @state() private _dataCollectionOptIn?: boolean; | ||
|
|
||
| @state() | ||
| private _statistics?: ZWaveJSControllerStatisticsUpdatedMessage; | ||
|
|
||
| protected firstUpdated() { | ||
| if (this.hass) { | ||
| this._fetchData(); | ||
| } | ||
| } | ||
|
|
||
| public hassSubscribe(): Array<UnsubscribeFunc | Promise<UnsubscribeFunc>> { | ||
| return [ | ||
| subscribeZwaveControllerStatistics( | ||
| this.hass, | ||
| this.configEntryId, | ||
| (message) => { | ||
| if (!this.hasUpdated) { | ||
| return; | ||
| } | ||
| this._statistics = message; | ||
| } | ||
| ), | ||
| ]; | ||
| } | ||
|
|
||
| protected render(): TemplateResult { | ||
| if (!this._configEntry) { | ||
| return html``; | ||
|
|
@@ -211,22 +236,178 @@ class ZWaveJSConfigDashboard extends LitElement { | |
| </ha-card> | ||
| <ha-card header="Diagnostics"> | ||
| <div class="card-content"> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.driver_version" | ||
| )}: | ||
| ${this._network.client.driver_version}<br /> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.server_version" | ||
| )}: | ||
| ${this._network.client.server_version}<br /> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.home_id" | ||
| )}: | ||
| ${this._network.controller.home_id}<br /> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.server_url" | ||
| )}: | ||
| ${this._network.client.ws_server_url}<br /> | ||
| <div class="row"> | ||
|
raman325 marked this conversation as resolved.
|
||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.driver_version" | ||
| )}: | ||
| </span> | ||
| <span>${this._network.client.driver_version}</span> | ||
| </div> | ||
|
Comment on lines
+240
to
+246
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we use the list items for the top part too?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the reason I didn't make that change is because the mwc-list makes it harder to copy and paste the information out of there. Maybe this isn't an issue now that we have diagnostics
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, let's keep it as you have it for now then 😄 |
||
| <div class="row"> | ||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.server_version" | ||
| )}: | ||
| </span> | ||
| <span>${this._network.client.server_version}</span> | ||
| </div> | ||
| <div class="row"> | ||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.home_id" | ||
| )}: | ||
| </span> | ||
| <span>${this._network.controller.home_id}</span> | ||
| </div> | ||
| <div class="row"> | ||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.server_url" | ||
| )}: | ||
| </span> | ||
| <span>${this._network.client.ws_server_url}</span> | ||
| </div> | ||
| <br /> | ||
| <ha-expansion-panel | ||
| .header=${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.title" | ||
| )} | ||
| > | ||
| <mwc-list noninteractive> | ||
| <mwc-list-item twoline hasmeta> | ||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.messages_tx.label" | ||
| )} | ||
| </span> | ||
| <span slot="secondary"> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.messages_tx.tooltip" | ||
| )} | ||
| </span> | ||
| <span slot="meta" | ||
| >${this._statistics?.messages_tx ?? 0}</span | ||
| > | ||
| </mwc-list-item> | ||
| <mwc-list-item twoline hasmeta> | ||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.messages_rx.label" | ||
| )} | ||
| </span> | ||
| <span slot="secondary"> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.messages_rx.tooltip" | ||
| )} | ||
| </span> | ||
| <span slot="meta" | ||
| >${this._statistics?.messages_rx ?? 0}</span | ||
| > | ||
| </mwc-list-item> | ||
| <mwc-list-item twoline hasmeta> | ||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.messages_dropped_tx.label" | ||
| )} | ||
| </span> | ||
| <span slot="secondary"> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.messages_dropped_tx.tooltip" | ||
| )} | ||
| </span> | ||
| <span slot="meta" | ||
| >${this._statistics?.messages_dropped_tx ?? 0}</span | ||
| > | ||
| </mwc-list-item> | ||
| <mwc-list-item twoline hasmeta> | ||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.messages_dropped_rx.label" | ||
| )} | ||
| </span> | ||
| <span slot="secondary"> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.messages_dropped_rx.tooltip" | ||
| )} | ||
| </span> | ||
| <span slot="meta" | ||
| >${this._statistics?.messages_dropped_rx ?? 0}</span | ||
| > | ||
| </mwc-list-item> | ||
| <mwc-list-item twoline hasmeta> | ||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.nak.label" | ||
| )} | ||
| </span> | ||
| <span slot="secondary"> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.nak.tooltip" | ||
| )} | ||
| </span> | ||
| <span slot="meta">${this._statistics?.nak ?? 0}</span> | ||
| </mwc-list-item> | ||
| <mwc-list-item twoline hasmeta> | ||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.can.label" | ||
| )} | ||
| </span> | ||
| <span slot="secondary"> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.can.tooltip" | ||
| )} | ||
| </span> | ||
| <span slot="meta">${this._statistics?.can ?? 0}</span> | ||
| </mwc-list-item> | ||
| <mwc-list-item twoline hasmeta> | ||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.timeout_ack.label" | ||
| )} | ||
| </span> | ||
| <span slot="secondary"> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.timeout_ack.tooltip" | ||
| )} | ||
| </span> | ||
| <span slot="meta" | ||
| >${this._statistics?.timeout_ack ?? 0}</span | ||
| > | ||
| </mwc-list-item> | ||
| <mwc-list-item twoline hasmeta> | ||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.timeout_response.label" | ||
| )} | ||
| </span> | ||
| <span slot="secondary"> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.timeout_response.tooltip" | ||
| )} | ||
| </span> | ||
| <span slot="meta" | ||
| >${this._statistics?.timeout_response ?? 0}</span | ||
| > | ||
| </mwc-list-item> | ||
| <mwc-list-item twoline hasmeta> | ||
| <span> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.timeout_callback.label" | ||
| )} | ||
| </span> | ||
| <span slot="secondary"> | ||
| ${this.hass.localize( | ||
| "ui.panel.config.zwave_js.dashboard.statistics.timeout_callback.tooltip" | ||
| )} | ||
| </span> | ||
| <span slot="meta" | ||
| >${this._statistics?.timeout_callback ?? 0}</span | ||
| > | ||
| </mwc-list-item> | ||
| </mwc-list> | ||
| </ha-expansion-panel> | ||
| </div> | ||
| <div class="card-actions"> | ||
| <mwc-button | ||
|
|
@@ -383,7 +564,7 @@ class ZWaveJSConfigDashboard extends LitElement { | |
| domain: "zwave_js", | ||
| }); | ||
| this._configEntry = configEntries.find( | ||
| (entry) => entry.entry_id === this.configEntryId! | ||
| (entry) => entry.entry_id === this.configEntryId | ||
| ); | ||
|
|
||
| if (ERROR_STATES.includes(this._configEntry!.state)) { | ||
|
|
@@ -508,6 +689,11 @@ class ZWaveJSConfigDashboard extends LitElement { | |
| padding-right: 40px; | ||
| } | ||
|
|
||
| .row { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| } | ||
|
|
||
| .network-status div.heading { | ||
| display: flex; | ||
| align-items: center; | ||
|
|
@@ -530,6 +716,10 @@ class ZWaveJSConfigDashboard extends LitElement { | |
| font-size: 1rem; | ||
| } | ||
|
|
||
| mwc-list-item { | ||
| height: 60px; | ||
| } | ||
|
|
||
| .card-header { | ||
| display: flex; | ||
| } | ||
|
|
@@ -546,12 +736,6 @@ class ZWaveJSConfigDashboard extends LitElement { | |
| max-width: 600px; | ||
| } | ||
|
|
||
| button.dump { | ||
| width: 100%; | ||
| text-align: center; | ||
| color: var(--secondary-text-color); | ||
| } | ||
|
|
||
| [hidden] { | ||
| display: none; | ||
| } | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.