Add import thread credentials to external bus (#18777)

This commit is contained in:
Bram Kragten 2023-11-29 09:01:33 +01:00 committed by GitHub
parent d8d4ecf79f
commit 1eb25f4829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 2 deletions

View File

@ -37,6 +37,10 @@ interface EMOutgoingMessageMatterCommission extends EMMessage {
type: "matter/commission";
}
interface EMOutgoingMessageImportThreadCredentials extends EMMessage {
type: "thread/import_credentials";
}
type EMOutgoingMessageWithAnswer = {
"config/get": {
request: EMOutgoingMessageConfigGet;
@ -116,7 +120,8 @@ type EMOutgoingMessageWithoutAnswer =
| EMOutgoingMessageThemeUpdate
| EMMessageResultSuccess
| EMMessageResultError
| EMOutgoingMessageMatterCommission;
| EMOutgoingMessageMatterCommission
| EMOutgoingMessageImportThreadCredentials;
interface EMIncomingMessageRestart {
id: number;
@ -161,6 +166,7 @@ export interface ExternalConfig {
canWriteTag: boolean;
hasExoPlayer: boolean;
canCommissionMatter: boolean;
canImportThreadCredentials: boolean;
hasAssist: boolean;
}

View File

@ -7,7 +7,14 @@ import {
mdiInformationOutline,
mdiCellphoneKey,
} from "@mdi/js";
import { LitElement, PropertyValues, TemplateResult, css, html } from "lit";
import {
LitElement,
PropertyValues,
TemplateResult,
css,
html,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { isComponentLoaded } from "../../../../../common/config/is_component_loaded";
@ -132,6 +139,15 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
)}`
: ""}
</div>
${this.hass.auth.external?.config.canImportThreadCredentials
? html`<ha-fab
slot="fab"
@click=${this._importExternalThreadCredentials}
extended
label="Import credentials"
><ha-svg-icon slot="icon" .path=${mdiCellphoneKey}></ha-svg-icon
></ha-fab>`
: nothing}
</hass-subpage>
`;
}
@ -313,6 +329,12 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
});
}
private _importExternalThreadCredentials() {
this.hass.auth.external!.fireMessage({
type: "thread/import_credentials",
});
}
private _onImageError(ev) {
ev.target.style.display = "none";
}