mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Replace home ID with config entry title in Z-Wave device Info (#9488)
This commit is contained in:
parent
b7fd7abe85
commit
12f7366968
@ -8,6 +8,10 @@ import {
|
||||
} from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
|
||||
import {
|
||||
ConfigEntry,
|
||||
getConfigEntries,
|
||||
} from "../../../../../../data/config_entries";
|
||||
import {
|
||||
fetchNodeStatus,
|
||||
getIdentifiersFromDevice,
|
||||
@ -26,9 +30,11 @@ export class HaDeviceInfoZWaveJS extends LitElement {
|
||||
|
||||
@state() private _entryId?: string;
|
||||
|
||||
@state() private _nodeId?: number;
|
||||
@state() private _configEntry?: ConfigEntry;
|
||||
|
||||
@state() private _homeId?: string;
|
||||
@state() private _multipleConfigEntries = false;
|
||||
|
||||
@state() private _nodeId?: number;
|
||||
|
||||
@state() private _node?: ZWaveJSNode;
|
||||
|
||||
@ -40,7 +46,6 @@ export class HaDeviceInfoZWaveJS extends LitElement {
|
||||
if (!identifiers) {
|
||||
return;
|
||||
}
|
||||
this._homeId = identifiers.home_id;
|
||||
this._nodeId = identifiers.node_id;
|
||||
this._entryId = this.device.config_entries[0];
|
||||
|
||||
@ -52,6 +57,25 @@ export class HaDeviceInfoZWaveJS extends LitElement {
|
||||
if (!this._nodeId || !this._entryId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const configEntries = await getConfigEntries(this.hass);
|
||||
let zwaveJsConfEntries = 0;
|
||||
for (const entry of configEntries) {
|
||||
if (entry.domain !== "zwave_js") {
|
||||
continue;
|
||||
}
|
||||
if (zwaveJsConfEntries) {
|
||||
this._multipleConfigEntries = true;
|
||||
}
|
||||
if (entry.entry_id === this._entryId) {
|
||||
this._configEntry = entry;
|
||||
}
|
||||
if (this._configEntry && this._multipleConfigEntries) {
|
||||
break;
|
||||
}
|
||||
zwaveJsConfEntries++;
|
||||
}
|
||||
|
||||
this._node = await fetchNodeStatus(this.hass, this._entryId, this._nodeId);
|
||||
}
|
||||
|
||||
@ -63,10 +87,14 @@ export class HaDeviceInfoZWaveJS extends LitElement {
|
||||
<h4>
|
||||
${this.hass.localize("ui.panel.config.zwave_js.device_info.zwave_info")}
|
||||
</h4>
|
||||
<div>
|
||||
${this.hass.localize("ui.panel.config.zwave_js.common.home_id")}:
|
||||
${this._homeId}
|
||||
</div>
|
||||
${this._multipleConfigEntries
|
||||
? html`
|
||||
<div>
|
||||
${this.hass.localize("ui.panel.config.zwave_js.common.source")}:
|
||||
${this._configEntry!.title}
|
||||
</div>
|
||||
`
|
||||
: ""}
|
||||
<div>
|
||||
${this.hass.localize("ui.panel.config.zwave_js.common.node_id")}:
|
||||
${this._node.node_id}
|
||||
|
@ -2593,6 +2593,7 @@
|
||||
"network": "Network",
|
||||
"node_id": "Node ID",
|
||||
"home_id": "Home ID",
|
||||
"source": "Source",
|
||||
"close": "Close",
|
||||
"add_node": "Add Node",
|
||||
"remove_node": "Remove Node",
|
||||
|
Loading…
x
Reference in New Issue
Block a user