diff --git a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts index 90b440dcfffe..7d5b1e46d5b8 100644 --- a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts +++ b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts @@ -6,19 +6,18 @@ import { mdiCloseCircle, mdiProgressClock, } from "@mdi/js"; -import { UnsubscribeFunc } from "home-assistant-js-websocket"; import { - css, CSSResultGroup, - html, LitElement, - nothing, PropertyValues, TemplateResult, + css, + html, + nothing, } from "lit"; import { customElement, property, state } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; -import memoizeOne from "memoize-one"; +import { groupBy } from "../../../../../common/util/group-by"; import "../../../../../components/ha-alert"; import "../../../../../components/ha-card"; import "../../../../../components/ha-icon-next"; @@ -27,25 +26,19 @@ import "../../../../../components/ha-settings-row"; import "../../../../../components/ha-svg-icon"; import "../../../../../components/ha-switch"; import "../../../../../components/ha-textfield"; -import { groupBy } from "../../../../../common/util/group-by"; -import { - computeDeviceName, - DeviceRegistryEntry, - subscribeDeviceRegistry, -} from "../../../../../data/device_registry"; +import { computeDeviceName } from "../../../../../data/device_registry"; import { - fetchZwaveNodeConfigParameters, - fetchZwaveNodeMetadata, - setZwaveNodeConfigParameter, ZWaveJSNodeConfigParam, ZWaveJSNodeConfigParams, - ZwaveJSNodeMetadata, ZWaveJSSetConfigParamResult, + ZwaveJSNodeMetadata, + fetchZwaveNodeConfigParameters, + fetchZwaveNodeMetadata, + setZwaveNodeConfigParameter, } from "../../../../../data/zwave_js"; import "../../../../../layouts/hass-error-screen"; import "../../../../../layouts/hass-loading-screen"; import "../../../../../layouts/hass-tabs-subpage"; -import { SubscribeMixin } from "../../../../../mixins/subscribe-mixin"; import { haStyle } from "../../../../../resources/styles"; import type { HomeAssistant, Route } from "../../../../../types"; import "../../../ha-config-section"; @@ -57,16 +50,8 @@ const icons = { error: mdiCloseCircle, }; -const getDevice = memoizeOne( - ( - deviceId: string, - entries?: DeviceRegistryEntry[] - ): DeviceRegistryEntry | undefined => - entries?.find((device) => device.id === deviceId) -); - @customElement("zwave_js-node-config") -class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) { +class ZWaveJSNodeConfig extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; @property({ attribute: false }) public route!: Route; @@ -79,8 +64,6 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) { @property() public deviceId!: string; - @state() private _deviceRegistryEntries?: DeviceRegistryEntry[]; - @state() private _nodeMetadata?: ZwaveJSNodeMetadata; @state() private _config?: ZWaveJSNodeConfigParams; @@ -94,19 +77,8 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) { this.deviceId = this.route.path.substr(1); } - public hassSubscribe(): UnsubscribeFunc[] { - return [ - subscribeDeviceRegistry(this.hass.connection, (entries) => { - this._deviceRegistryEntries = entries; - }), - ]; - } - protected updated(changedProps: PropertyValues): void { - if ( - (!this._config || changedProps.has("deviceId")) && - changedProps.has("_deviceRegistryEntries") - ) { + if (!this._config || changedProps.has("deviceId")) { this._fetchData(); } } @@ -125,7 +97,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) { return html``; } - const device = this._device!; + const device = this.hass.devices[this.deviceId]; return html`