Fix fetching helper config entry (#16704)

* Fix fetching helper config entry

* willUpdate
This commit is contained in:
Bram Kragten 2023-06-01 00:58:03 +02:00 committed by GitHub
parent a4c57f09ad
commit a49d59f4c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ import {
removeEntityRegistryEntry, removeEntityRegistryEntry,
updateEntityRegistryEntry, updateEntityRegistryEntry,
} from "../../../data/entity_registry"; } from "../../../data/entity_registry";
import { fetchIntegrationManifest } from "../../../data/integration";
import { import {
showAlertDialog, showAlertDialog,
showConfirmationDialog, showConfirmationDialog,
@ -46,12 +47,32 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) {
@query("entity-registry-settings-editor") @query("entity-registry-settings-editor")
private _registryEditor?: EntityRegistrySettingsEditor; private _registryEditor?: EntityRegistrySettingsEditor;
protected firstUpdated(changedProps: PropertyValues): void { protected willUpdate(changedProps: PropertyValues): void {
super.firstUpdated(changedProps); super.willUpdate(changedProps);
if (this.entry.config_entry_id) { if (changedProps.has("entry")) {
getConfigEntry(this.hass, this.entry.config_entry_id).then((entry) => { this._fetchHelperConfigEntry();
this._helperConfigEntry = entry.config_entry; }
}); }
private async _fetchHelperConfigEntry() {
if (!this.entry?.config_entry_id) {
return;
}
try {
const configEntry = (
await getConfigEntry(this.hass, this.entry.config_entry_id)
).config_entry;
const manifest = await fetchIntegrationManifest(
this.hass,
configEntry.domain
);
if (manifest.integration_type === "helper") {
this._helperConfigEntry = configEntry;
} else {
this._helperConfigEntry = undefined;
}
} catch (err) {
this._helperConfigEntry = undefined;
} }
} }