mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-15 13:26:34 +00:00
Add alert to zwave_js device info page for custom device config (#18686)
This commit is contained in:
parent
15a5d2bc38
commit
5965c3fdaa
@ -219,8 +219,9 @@ export interface ZwaveJSNodeMetadata {
|
|||||||
device_database_url: string;
|
device_database_url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ZwaveJSNodeComments {
|
export interface ZwaveJSNodeAlerts {
|
||||||
comments: ZWaveJSNodeComment[];
|
comments: ZWaveJSNodeComment[];
|
||||||
|
is_embedded: boolean | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ZWaveJSNodeConfigParams {
|
export interface ZWaveJSNodeConfigParams {
|
||||||
@ -601,12 +602,12 @@ export const fetchZwaveNodeMetadata = (
|
|||||||
device_id,
|
device_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fetchZwaveNodeComments = (
|
export const fetchZwaveNodeAlerts = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_id: string
|
device_id: string
|
||||||
): Promise<ZwaveJSNodeComments> =>
|
): Promise<ZwaveJSNodeAlerts> =>
|
||||||
hass.callWS({
|
hass.callWS({
|
||||||
type: "zwave_js/node_comments",
|
type: "zwave_js/node_alerts",
|
||||||
device_id,
|
device_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
|
import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
|
||||||
import { fetchZwaveNodeComments } from "../../../../../../data/zwave_js";
|
import { fetchZwaveNodeAlerts } from "../../../../../../data/zwave_js";
|
||||||
import { HomeAssistant } from "../../../../../../types";
|
import { HomeAssistant } from "../../../../../../types";
|
||||||
import { DeviceAlert } from "../../../ha-config-device-page";
|
import { DeviceAlert } from "../../../ha-config-device-page";
|
||||||
|
|
||||||
@ -7,14 +7,27 @@ export const getZwaveDeviceAlerts = async (
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device: DeviceRegistryEntry
|
device: DeviceRegistryEntry
|
||||||
): Promise<DeviceAlert[]> => {
|
): Promise<DeviceAlert[]> => {
|
||||||
const nodeComments = await fetchZwaveNodeComments(hass, device.id);
|
const nodeAlerts = await fetchZwaveNodeAlerts(hass, device.id);
|
||||||
|
const deviceAlerts: DeviceAlert[] = [];
|
||||||
|
|
||||||
if (!nodeComments?.comments?.length) {
|
if (nodeAlerts?.is_embedded === false) {
|
||||||
return [];
|
deviceAlerts.push({
|
||||||
|
level: "info",
|
||||||
|
text: hass.localize(
|
||||||
|
"ui.panel.config.zwave_js.device_info.custom_device_config"
|
||||||
|
),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodeComments.comments.map((comment) => ({
|
if (!nodeAlerts?.comments?.length) {
|
||||||
|
return deviceAlerts;
|
||||||
|
}
|
||||||
|
|
||||||
|
deviceAlerts.push(
|
||||||
|
...nodeAlerts.comments.map((comment) => ({
|
||||||
level: comment.level,
|
level: comment.level,
|
||||||
text: comment.text,
|
text: comment.text,
|
||||||
}));
|
}))
|
||||||
|
);
|
||||||
|
return deviceAlerts;
|
||||||
};
|
};
|
||||||
|
@ -4064,7 +4064,8 @@
|
|||||||
"unknown": "Unknown",
|
"unknown": "Unknown",
|
||||||
"zwave_plus": "Z-Wave Plus",
|
"zwave_plus": "Z-Wave Plus",
|
||||||
"zwave_plus_version": "Version {version}",
|
"zwave_plus_version": "Version {version}",
|
||||||
"node_statistics": "Statistics"
|
"node_statistics": "Statistics",
|
||||||
|
"custom_device_config": "This device is using a custom device config file not provided by Z-Wave JS. If you want to use the default device config provided by Z-Wave JS, you must remove the custom device config file from the folder that Z-Wave JS is reading from."
|
||||||
},
|
},
|
||||||
"hard_reset_controller": {
|
"hard_reset_controller": {
|
||||||
"NotStarted": {
|
"NotStarted": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user