Allow stale ZHA coordinator entries to be deleted (#13154)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
puddly 2022-07-11 14:14:37 -04:00 committed by GitHub
parent be52ba0ea9
commit c50cf78bb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 41 deletions

View File

@ -26,6 +26,7 @@ export interface ZHADevice {
power_source?: string; power_source?: string;
area_id?: string; area_id?: string;
device_type: string; device_type: string;
active_coordinator: boolean;
signature: any; signature: any;
neighbors: Neighbor[]; neighbors: Neighbor[];
pairing_status?: string; pairing_status?: string;

View File

@ -30,7 +30,7 @@ export const getZHADeviceActions = async (
const actions: DeviceAction[] = []; const actions: DeviceAction[] = [];
if (zhaDevice.device_type !== "Coordinator") { if (!zhaDevice.active_coordinator) {
actions.push({ actions.push({
label: hass.localize("ui.dialogs.zha_device_info.buttons.reconfigure"), label: hass.localize("ui.dialogs.zha_device_info.buttons.reconfigure"),
action: () => showZHAReconfigureDeviceDialog(el, { device: zhaDevice }), action: () => showZHAReconfigureDeviceDialog(el, { device: zhaDevice }),
@ -58,15 +58,13 @@ export const getZHADeviceActions = async (
); );
} }
if (zhaDevice.device_type !== "Coordinator") {
actions.push( actions.push(
...[ ...[
{ {
label: hass.localize( label: hass.localize(
"ui.dialogs.zha_device_info.buttons.zigbee_information" "ui.dialogs.zha_device_info.buttons.zigbee_information"
), ),
action: () => action: () => showZHADeviceZigbeeInfoDialog(el, { device: zhaDevice }),
showZHADeviceZigbeeInfoDialog(el, { device: zhaDevice }),
}, },
{ {
label: hass.localize("ui.dialogs.zha_device_info.buttons.clusters"), label: hass.localize("ui.dialogs.zha_device_info.buttons.clusters"),
@ -79,7 +77,11 @@ export const getZHADeviceActions = async (
action: () => action: () =>
navigate(`/config/zha/visualization/${zhaDevice!.device_reg_id}`), navigate(`/config/zha/visualization/${zhaDevice!.device_reg_id}`),
}, },
{ ]
);
if (!zhaDevice.active_coordinator) {
actions.push({
label: hass.localize("ui.dialogs.zha_device_info.buttons.remove"), label: hass.localize("ui.dialogs.zha_device_info.buttons.remove"),
classes: "warning", classes: "warning",
action: async () => { action: async () => {
@ -99,9 +101,7 @@ export const getZHADeviceActions = async (
history.back(); history.back();
}, },
}, });
]
);
} }
return actions; return actions;