Adjust to otbr info including extended address (#17581)

This commit is contained in:
Erik Montnemery 2023-08-15 09:51:13 +02:00 committed by GitHub
parent 4979e89251
commit f6087f3805
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 17 deletions

View File

@ -1,9 +1,10 @@
import { HomeAssistant } from "../types";
export interface OTBRInfo {
url: string;
active_dataset_tlvs: string;
channel: number;
extended_address: string;
url: string;
}
export const getOTBRInfo = (hass: HomeAssistant): Promise<OTBRInfo> =>
@ -25,13 +26,6 @@ export const OTBRSetNetwork = (
dataset_id,
});
export const OTBRGetExtendedAddress = (
hass: HomeAssistant
): Promise<{ extended_address: string }> =>
hass.callWS({
type: "otbr/get_extended_address",
});
export const OTBRSetChannel = (
hass: HomeAssistant,
channel: number

View File

@ -18,7 +18,6 @@ import { getConfigEntryDiagnosticsDownloadUrl } from "../../../../../data/diagno
import {
getOTBRInfo,
OTBRCreateNetwork,
OTBRGetExtendedAddress,
OTBRInfo,
OTBRSetChannel,
OTBRSetNetwork,
@ -63,7 +62,7 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
@state() private _datasets: ThreadDataSet[] = [];
@state() private _otbrInfo?: OTBRInfo & { extended_address?: string };
@state() private _otbrInfo?: OTBRInfo;
protected render(): TemplateResult {
const networks = this._groupRoutersByNetwork(this._routers, this._datasets);
@ -356,13 +355,7 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
return;
}
try {
const _otbrAddress = OTBRGetExtendedAddress(this.hass);
const _otbrInfo = getOTBRInfo(this.hass);
const [otbrAddress, otbrInfo] = await Promise.all([
_otbrAddress,
_otbrInfo,
]);
this._otbrInfo = { ...otbrAddress, ...otbrInfo };
this._otbrInfo = await getOTBRInfo(this.hass);
} catch (err) {
this._otbrInfo = undefined;
}