mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16:36 +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";
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
|
import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
|
||||||
|
import {
|
||||||
|
ConfigEntry,
|
||||||
|
getConfigEntries,
|
||||||
|
} from "../../../../../../data/config_entries";
|
||||||
import {
|
import {
|
||||||
fetchNodeStatus,
|
fetchNodeStatus,
|
||||||
getIdentifiersFromDevice,
|
getIdentifiersFromDevice,
|
||||||
@ -26,9 +30,11 @@ export class HaDeviceInfoZWaveJS extends LitElement {
|
|||||||
|
|
||||||
@state() private _entryId?: string;
|
@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;
|
@state() private _node?: ZWaveJSNode;
|
||||||
|
|
||||||
@ -40,7 +46,6 @@ export class HaDeviceInfoZWaveJS extends LitElement {
|
|||||||
if (!identifiers) {
|
if (!identifiers) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._homeId = identifiers.home_id;
|
|
||||||
this._nodeId = identifiers.node_id;
|
this._nodeId = identifiers.node_id;
|
||||||
this._entryId = this.device.config_entries[0];
|
this._entryId = this.device.config_entries[0];
|
||||||
|
|
||||||
@ -52,6 +57,25 @@ export class HaDeviceInfoZWaveJS extends LitElement {
|
|||||||
if (!this._nodeId || !this._entryId) {
|
if (!this._nodeId || !this._entryId) {
|
||||||
return;
|
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);
|
this._node = await fetchNodeStatus(this.hass, this._entryId, this._nodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,10 +87,14 @@ export class HaDeviceInfoZWaveJS extends LitElement {
|
|||||||
<h4>
|
<h4>
|
||||||
${this.hass.localize("ui.panel.config.zwave_js.device_info.zwave_info")}
|
${this.hass.localize("ui.panel.config.zwave_js.device_info.zwave_info")}
|
||||||
</h4>
|
</h4>
|
||||||
|
${this._multipleConfigEntries
|
||||||
|
? html`
|
||||||
<div>
|
<div>
|
||||||
${this.hass.localize("ui.panel.config.zwave_js.common.home_id")}:
|
${this.hass.localize("ui.panel.config.zwave_js.common.source")}:
|
||||||
${this._homeId}
|
${this._configEntry!.title}
|
||||||
</div>
|
</div>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
<div>
|
<div>
|
||||||
${this.hass.localize("ui.panel.config.zwave_js.common.node_id")}:
|
${this.hass.localize("ui.panel.config.zwave_js.common.node_id")}:
|
||||||
${this._node.node_id}
|
${this._node.node_id}
|
||||||
|
@ -2593,6 +2593,7 @@
|
|||||||
"network": "Network",
|
"network": "Network",
|
||||||
"node_id": "Node ID",
|
"node_id": "Node ID",
|
||||||
"home_id": "Home ID",
|
"home_id": "Home ID",
|
||||||
|
"source": "Source",
|
||||||
"close": "Close",
|
"close": "Close",
|
||||||
"add_node": "Add Node",
|
"add_node": "Add Node",
|
||||||
"remove_node": "Remove Node",
|
"remove_node": "Remove Node",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user