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:
Raman Gupta 2021-08-25 13:53:30 -04:00 committed by GitHub
parent 5bd92d04d9
commit 900efe8a36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 12 deletions

View File

@ -24,12 +24,22 @@ export interface ZWaveJSController {
is_heal_network_active: boolean; is_heal_network_active: boolean;
} }
export interface ZWaveJSNode { export interface ZWaveJSNodeStatus {
node_id: number; node_id: number;
ready: boolean; ready: boolean;
status: number; 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 { export interface ZWaveJSNodeConfigParams {
[key: string]: ZWaveJSNodeConfigParam; [key: string]: ZWaveJSNodeConfigParam;
} }
@ -132,13 +142,24 @@ export const fetchNodeStatus = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string, entry_id: string,
node_id: number node_id: number
): Promise<ZWaveJSNode> => ): Promise<ZWaveJSNodeStatus> =>
hass.callWS({ hass.callWS({
type: "zwave_js/node_status", type: "zwave_js/node_status",
entry_id, entry_id,
node_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 = ( export const fetchNodeConfigParameters = (
hass: HomeAssistant, hass: HomeAssistant,
entry_id: string, entry_id: string,

View File

@ -16,7 +16,7 @@ import {
fetchNodeStatus, fetchNodeStatus,
getIdentifiersFromDevice, getIdentifiersFromDevice,
nodeStatus, nodeStatus,
ZWaveJSNode, ZWaveJSNodeStatus,
ZWaveJSNodeIdentifiers, ZWaveJSNodeIdentifiers,
} from "../../../../../../data/zwave_js"; } from "../../../../../../data/zwave_js";
import { haStyle } from "../../../../../../resources/styles"; import { haStyle } from "../../../../../../resources/styles";
@ -36,7 +36,7 @@ export class HaDeviceInfoZWaveJS extends LitElement {
@state() private _nodeId?: number; @state() private _nodeId?: number;
@state() private _node?: ZWaveJSNode; @state() private _node?: ZWaveJSNodeStatus;
protected updated(changedProperties: PropertyValues) { protected updated(changedProperties: PropertyValues) {
if (changedProperties.has("device")) { if (changedProperties.has("device")) {

View File

@ -15,7 +15,7 @@ import {
NodeStatus, NodeStatus,
setDataCollectionPreference, setDataCollectionPreference,
ZWaveJSNetwork, ZWaveJSNetwork,
ZWaveJSNode, ZWaveJSNodeStatus,
} from "../../../../../data/zwave_js"; } from "../../../../../data/zwave_js";
import { import {
ConfigEntry, ConfigEntry,
@ -53,7 +53,7 @@ class ZWaveJSConfigDashboard extends LitElement {
@state() private _network?: ZWaveJSNetwork; @state() private _network?: ZWaveJSNetwork;
@state() private _nodes?: ZWaveJSNode[]; @state() private _nodes?: ZWaveJSNodeStatus[];
@state() private _status = "unknown"; @state() private _status = "unknown";

View File

@ -34,8 +34,10 @@ import {
} from "../../../../../data/device_registry"; } from "../../../../../data/device_registry";
import { import {
fetchNodeConfigParameters, fetchNodeConfigParameters,
fetchNodeMetadata,
setNodeConfigParameter, setNodeConfigParameter,
ZWaveJSNodeConfigParams, ZWaveJSNodeConfigParams,
ZwaveJSNodeMetadata,
ZWaveJSSetConfigParamResult, ZWaveJSSetConfigParamResult,
} from "../../../../../data/zwave_js"; } from "../../../../../data/zwave_js";
import "../../../../../layouts/hass-tabs-subpage"; import "../../../../../layouts/hass-tabs-subpage";
@ -89,6 +91,8 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
@property({ type: Array }) @property({ type: Array })
private _deviceRegistryEntries?: DeviceRegistryEntry[]; private _deviceRegistryEntries?: DeviceRegistryEntry[];
@state() private _nodeMetadata?: ZwaveJSNodeMetadata;
@state() private _config?: ZWaveJSNodeConfigParams; @state() private _config?: ZWaveJSNodeConfigParams;
@state() private _results: Record<string, ZWaveJSSetConfigParamResult> = {}; @state() private _results: Record<string, ZWaveJSSetConfigParamResult> = {};
@ -162,7 +166,11 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.zwave_js.node_config.attribution", "ui.panel.config.zwave_js.node_config.attribution",
"device_database", "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( >${this.hass.localize(
"ui.panel.config.zwave_js.node_config.zwave_js_device_database" "ui.panel.config.zwave_js.node_config.zwave_js_device_database"
)}</a )}</a
@ -421,11 +429,10 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) {
return; return;
} }
this._config = await fetchNodeConfigParameters( [this._nodeMetadata, this._config] = await Promise.all([
this.hass, fetchNodeMetadata(this.hass, this.configEntryId, nodeId!),
this.configEntryId, fetchNodeConfigParameters(this.hass, this.configEntryId, nodeId!),
nodeId! ]);
);
} }
static get styles(): CSSResultGroup { static get styles(): CSSResultGroup {