mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 13:57:21 +00:00
Add direct link to zwave_js device's device DB page (#9797)
Co-authored-by: Charles Garwood <cgarwood@newdealmultimedia.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
5bd92d04d9
commit
900efe8a36
@ -24,12 +24,22 @@ export interface ZWaveJSController {
|
||||
is_heal_network_active: boolean;
|
||||
}
|
||||
|
||||
export interface ZWaveJSNode {
|
||||
export interface ZWaveJSNodeStatus {
|
||||
node_id: number;
|
||||
ready: boolean;
|
||||
status: number;
|
||||
}
|
||||
|
||||
export interface ZwaveJSNodeMetadata {
|
||||
node_id: number;
|
||||
exclusion: string;
|
||||
inclusion: string;
|
||||
manual: string;
|
||||
wakeup: string;
|
||||
reset: string;
|
||||
device_database_url: string;
|
||||
}
|
||||
|
||||
export interface ZWaveJSNodeConfigParams {
|
||||
[key: string]: ZWaveJSNodeConfigParam;
|
||||
}
|
||||
@ -132,13 +142,24 @@ export const fetchNodeStatus = (
|
||||
hass: HomeAssistant,
|
||||
entry_id: string,
|
||||
node_id: number
|
||||
): Promise<ZWaveJSNode> =>
|
||||
): Promise<ZWaveJSNodeStatus> =>
|
||||
hass.callWS({
|
||||
type: "zwave_js/node_status",
|
||||
entry_id,
|
||||
node_id,
|
||||
});
|
||||
|
||||
export const fetchNodeMetadata = (
|
||||
hass: HomeAssistant,
|
||||
entry_id: string,
|
||||
node_id: number
|
||||
): Promise<ZwaveJSNodeMetadata> =>
|
||||
hass.callWS({
|
||||
type: "zwave_js/node_metadata",
|
||||
entry_id,
|
||||
node_id,
|
||||
});
|
||||
|
||||
export const fetchNodeConfigParameters = (
|
||||
hass: HomeAssistant,
|
||||
entry_id: string,
|
||||
|
@ -16,7 +16,7 @@ import {
|
||||
fetchNodeStatus,
|
||||
getIdentifiersFromDevice,
|
||||
nodeStatus,
|
||||
ZWaveJSNode,
|
||||
ZWaveJSNodeStatus,
|
||||
ZWaveJSNodeIdentifiers,
|
||||
} from "../../../../../../data/zwave_js";
|
||||
import { haStyle } from "../../../../../../resources/styles";
|
||||
@ -36,7 +36,7 @@ export class HaDeviceInfoZWaveJS extends LitElement {
|
||||
|
||||
@state() private _nodeId?: number;
|
||||
|
||||
@state() private _node?: ZWaveJSNode;
|
||||
@state() private _node?: ZWaveJSNodeStatus;
|
||||
|
||||
protected updated(changedProperties: PropertyValues) {
|
||||
if (changedProperties.has("device")) {
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
NodeStatus,
|
||||
setDataCollectionPreference,
|
||||
ZWaveJSNetwork,
|
||||
ZWaveJSNode,
|
||||
ZWaveJSNodeStatus,
|
||||
} from "../../../../../data/zwave_js";
|
||||
import {
|
||||
ConfigEntry,
|
||||
@ -53,7 +53,7 @@ class ZWaveJSConfigDashboard extends LitElement {
|
||||
|
||||
@state() private _network?: ZWaveJSNetwork;
|
||||
|
||||
@state() private _nodes?: ZWaveJSNode[];
|
||||
@state() private _nodes?: ZWaveJSNodeStatus[];
|
||||
|
||||
@state() private _status = "unknown";
|
||||
|
||||
|
@ -34,8 +34,10 @@ import {
|
||||
} from "../../../../../data/device_registry";
|
||||
import {
|
||||
fetchNodeConfigParameters,
|
||||
fetchNodeMetadata,
|
||||
setNodeConfigParameter,
|
||||
ZWaveJSNodeConfigParams,
|
||||
ZwaveJSNodeMetadata,
|
||||
ZWaveJSSetConfigParamResult,
|
||||
} from "../../../../../data/zwave_js";
|
||||
import "../../../../../layouts/hass-tabs-subpage";
|
||||
@ -89,6 +91,8 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
@property({ type: Array })
|
||||
private _deviceRegistryEntries?: DeviceRegistryEntry[];
|
||||
|
||||
@state() private _nodeMetadata?: ZwaveJSNodeMetadata;
|
||||
|
||||
@state() private _config?: ZWaveJSNodeConfigParams;
|
||||
|
||||
@state() private _results: Record<string, ZWaveJSSetConfigParamResult> = {};
|
||||
@ -162,7 +166,11 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.zwave_js.node_config.attribution",
|
||||
"device_database",
|
||||
html`<a href="https://devices.zwave-js.io/" target="_blank"
|
||||
html`<a
|
||||
rel="noreferrer noopener"
|
||||
href="${this._nodeMetadata?.device_database_url ||
|
||||
"https://devices.zwave-js.io"}"
|
||||
target="_blank"
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.zwave_js.node_config.zwave_js_device_database"
|
||||
)}</a
|
||||
@ -421,11 +429,10 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._config = await fetchNodeConfigParameters(
|
||||
this.hass,
|
||||
this.configEntryId,
|
||||
nodeId!
|
||||
);
|
||||
[this._nodeMetadata, this._config] = await Promise.all([
|
||||
fetchNodeMetadata(this.hass, this.configEntryId, nodeId!),
|
||||
fetchNodeConfigParameters(this.hass, this.configEntryId, nodeId!),
|
||||
]);
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
|
Loading…
x
Reference in New Issue
Block a user