mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +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 { navigate } from "../common/navigate";
|
||||||
import { HomeAssistant } from "../types";
|
import { HomeAssistant } from "../types";
|
||||||
import { subscribeDeviceRegistry } from "./device_registry";
|
import { subscribeDeviceRegistry } from "./device_registry";
|
||||||
|
import { isComponentLoaded } from "../common/config/is_component_loaded";
|
||||||
|
import { getThreadDataSetTLV, listThreadDataSets } from "./thread";
|
||||||
|
|
||||||
export enum NetworkType {
|
export enum NetworkType {
|
||||||
THREAD = "thread",
|
THREAD = "thread",
|
||||||
@ -51,10 +53,30 @@ export interface MatterCommissioningParameters {
|
|||||||
export const canCommissionMatterExternal = (hass: HomeAssistant) =>
|
export const canCommissionMatterExternal = (hass: HomeAssistant) =>
|
||||||
hass.auth.external?.config.canCommissionMatter;
|
hass.auth.external?.config.canCommissionMatter;
|
||||||
|
|
||||||
export const startExternalCommissioning = (hass: HomeAssistant) =>
|
export const startExternalCommissioning = async (hass: HomeAssistant) => {
|
||||||
hass.auth.external!.fireMessage({
|
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",
|
type: "matter/commission",
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const redirectOnNewMatterDevice = (
|
export const redirectOnNewMatterDevice = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
@ -57,6 +57,11 @@ interface EMOutgoingMessageBarCodeNotify extends EMMessage {
|
|||||||
|
|
||||||
interface EMOutgoingMessageMatterCommission extends EMMessage {
|
interface EMOutgoingMessageMatterCommission extends EMMessage {
|
||||||
type: "matter/commission";
|
type: "matter/commission";
|
||||||
|
payload?: {
|
||||||
|
mac_extended_address: string | null;
|
||||||
|
border_agent_id: string | null;
|
||||||
|
active_operational_dataset: string | null;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EMOutgoingMessageImportThreadCredentials extends EMMessage {
|
interface EMOutgoingMessageImportThreadCredentials extends EMMessage {
|
||||||
@ -136,7 +141,7 @@ interface EMOutgoingMessageThreadStoreInPlatformKeychain extends EMMessage {
|
|||||||
type: "thread/store_in_platform_keychain";
|
type: "thread/store_in_platform_keychain";
|
||||||
payload: {
|
payload: {
|
||||||
mac_extended_address: string;
|
mac_extended_address: string;
|
||||||
border_agent_id: string | null;
|
border_agent_id: string;
|
||||||
active_operational_dataset: string;
|
active_operational_dataset: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -106,13 +106,11 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
|
|||||||
"ui.panel.config.thread.add_dataset_from_tlv"
|
"ui.panel.config.thread.add_dataset_from_tlv"
|
||||||
)}</mwc-list-item
|
)}</mwc-list-item
|
||||||
>
|
>
|
||||||
${!this._otbrInfo
|
<mwc-list-item @click=${this._addOTBR}
|
||||||
? html`<mwc-list-item @click=${this._addOTBR}
|
>${this.hass.localize(
|
||||||
>${this.hass.localize(
|
"ui.panel.config.thread.add_open_thread_border_router"
|
||||||
"ui.panel.config.thread.add_open_thread_border_router"
|
)}</mwc-list-item
|
||||||
)}</mwc-list-item
|
>
|
||||||
>`
|
|
||||||
: ""}
|
|
||||||
</ha-button-menu>
|
</ha-button-menu>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>${this.hass.localize("ui.panel.config.thread.my_network")}</h1>
|
<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",
|
type: "thread/store_in_platform_keychain",
|
||||||
payload: {
|
payload: {
|
||||||
mac_extended_address: otbr.extended_address,
|
mac_extended_address: otbr.extended_address,
|
||||||
border_agent_id: otbr.border_agent_id ?? "",
|
border_agent_id: otbr.border_agent_id,
|
||||||
active_operational_dataset: otbr.active_dataset_tlvs ?? "",
|
active_operational_dataset: otbr.active_dataset_tlvs,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user