mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Add preferred thread credentials to matter external commission (#22022)
This commit is contained in:
parent
d2194d55f9
commit
5920efa2b2
@ -2,6 +2,8 @@ import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import { navigate } from "../common/navigate";
|
||||
import { HomeAssistant } from "../types";
|
||||
import { subscribeDeviceRegistry } from "./device_registry";
|
||||
import { isComponentLoaded } from "../common/config/is_component_loaded";
|
||||
import { getThreadDataSetTLV, listThreadDataSets } from "./thread";
|
||||
|
||||
export enum NetworkType {
|
||||
THREAD = "thread",
|
||||
@ -51,10 +53,30 @@ export interface MatterCommissioningParameters {
|
||||
export const canCommissionMatterExternal = (hass: HomeAssistant) =>
|
||||
hass.auth.external?.config.canCommissionMatter;
|
||||
|
||||
export const startExternalCommissioning = (hass: HomeAssistant) =>
|
||||
hass.auth.external!.fireMessage({
|
||||
export const startExternalCommissioning = async (hass: HomeAssistant) => {
|
||||
if (isComponentLoaded(hass, "thread")) {
|
||||
const datasets = await listThreadDataSets(hass);
|
||||
const preferredDataset = datasets.datasets.find(
|
||||
(dataset) => dataset.preferred
|
||||
);
|
||||
if (preferredDataset) {
|
||||
return hass.auth.external!.fireMessage({
|
||||
type: "matter/commission",
|
||||
payload: {
|
||||
active_operational_dataset: (
|
||||
await getThreadDataSetTLV(hass, preferredDataset.dataset_id)
|
||||
).tlv,
|
||||
border_agent_id: preferredDataset.preferred_border_agent_id,
|
||||
mac_extended_address: preferredDataset.preferred_extended_address,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return hass.auth.external!.fireMessage({
|
||||
type: "matter/commission",
|
||||
});
|
||||
};
|
||||
|
||||
export const redirectOnNewMatterDevice = (
|
||||
hass: HomeAssistant,
|
||||
|
@ -57,6 +57,11 @@ interface EMOutgoingMessageBarCodeNotify extends EMMessage {
|
||||
|
||||
interface EMOutgoingMessageMatterCommission extends EMMessage {
|
||||
type: "matter/commission";
|
||||
payload?: {
|
||||
mac_extended_address: string | null;
|
||||
border_agent_id: string | null;
|
||||
active_operational_dataset: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
interface EMOutgoingMessageImportThreadCredentials extends EMMessage {
|
||||
@ -136,7 +141,7 @@ interface EMOutgoingMessageThreadStoreInPlatformKeychain extends EMMessage {
|
||||
type: "thread/store_in_platform_keychain";
|
||||
payload: {
|
||||
mac_extended_address: string;
|
||||
border_agent_id: string | null;
|
||||
border_agent_id: string;
|
||||
active_operational_dataset: string;
|
||||
};
|
||||
}
|
||||
|
@ -106,13 +106,11 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
|
||||
"ui.panel.config.thread.add_dataset_from_tlv"
|
||||
)}</mwc-list-item
|
||||
>
|
||||
${!this._otbrInfo
|
||||
? html`<mwc-list-item @click=${this._addOTBR}
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.thread.add_open_thread_border_router"
|
||||
)}</mwc-list-item
|
||||
>`
|
||||
: ""}
|
||||
<mwc-list-item @click=${this._addOTBR}
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.thread.add_open_thread_border_router"
|
||||
)}</mwc-list-item
|
||||
>
|
||||
</ha-button-menu>
|
||||
<div class="content">
|
||||
<h1>${this.hass.localize("ui.panel.config.thread.my_network")}</h1>
|
||||
@ -342,8 +340,8 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
|
||||
type: "thread/store_in_platform_keychain",
|
||||
payload: {
|
||||
mac_extended_address: otbr.extended_address,
|
||||
border_agent_id: otbr.border_agent_id ?? "",
|
||||
active_operational_dataset: otbr.active_dataset_tlvs ?? "",
|
||||
border_agent_id: otbr.border_agent_id,
|
||||
active_operational_dataset: otbr.active_dataset_tlvs,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user