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;
}
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,

View File

@ -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")) {

View File

@ -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";

View File

@ -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 {