mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Fix matter device actions (#22117)
* Fix matter device actions when matter integration loads forever * Fix matter device-actions types path * Move getMatterDeviceActions inside getDeviceActions in device page
This commit is contained in:
parent
ac9654c1de
commit
c721afa137
@ -17,6 +17,30 @@ import type { DeviceAction } from "../../../ha-config-device-page";
|
|||||||
import { showMatterManageFabricsDialog } from "../../../../integrations/integration-panels/matter/show-dialog-matter-manage-fabrics";
|
import { showMatterManageFabricsDialog } from "../../../../integrations/integration-panels/matter/show-dialog-matter-manage-fabrics";
|
||||||
import { navigate } from "../../../../../../common/navigate";
|
import { navigate } from "../../../../../../common/navigate";
|
||||||
|
|
||||||
|
export const getMatterDeviceDefaultActions = (
|
||||||
|
el: HTMLElement,
|
||||||
|
hass: HomeAssistant,
|
||||||
|
device: DeviceRegistryEntry
|
||||||
|
): DeviceAction[] => {
|
||||||
|
if (device.via_device_id !== null) {
|
||||||
|
// only show device actions for top level nodes (so not bridged)
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const actions: DeviceAction[] = [];
|
||||||
|
|
||||||
|
actions.push({
|
||||||
|
label: hass.localize("ui.panel.config.matter.device_actions.ping_device"),
|
||||||
|
icon: mdiChatQuestion,
|
||||||
|
action: () =>
|
||||||
|
showMatterPingNodeDialog(el, {
|
||||||
|
device_id: device.id,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
return actions;
|
||||||
|
};
|
||||||
|
|
||||||
export const getMatterDeviceActions = async (
|
export const getMatterDeviceActions = async (
|
||||||
el: HTMLElement,
|
el: HTMLElement,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -75,14 +99,5 @@ export const getMatterDeviceActions = async (
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.push({
|
|
||||||
label: hass.localize("ui.panel.config.matter.device_actions.ping_device"),
|
|
||||||
icon: mdiChatQuestion,
|
|
||||||
action: () =>
|
|
||||||
showMatterPingNodeDialog(el, {
|
|
||||||
device_id: device.id,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
};
|
};
|
||||||
|
@ -1119,12 +1119,17 @@ export class HaConfigDevicePage extends LitElement {
|
|||||||
const matter = await import(
|
const matter = await import(
|
||||||
"./device-detail/integration-elements/matter/device-actions"
|
"./device-detail/integration-elements/matter/device-actions"
|
||||||
);
|
);
|
||||||
const actions = await matter.getMatterDeviceActions(
|
const defaultActions = matter.getMatterDeviceDefaultActions(
|
||||||
this,
|
this,
|
||||||
this.hass,
|
this.hass,
|
||||||
device
|
device
|
||||||
);
|
);
|
||||||
deviceActions.push(...actions);
|
deviceActions.push(...defaultActions);
|
||||||
|
|
||||||
|
// load matter device actions async to avoid an UI with 0 actions when the matter integration needs very long to get node diagnostics
|
||||||
|
matter.getMatterDeviceActions(this, this.hass, device).then((actions) => {
|
||||||
|
this._deviceActions = [...actions, ...(this._deviceActions || [])];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this._deviceActions = deviceActions;
|
this._deviceActions = deviceActions;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user