Only update disabled for entity reg if it is a user value. (#4646)

This commit is contained in:
Bram Kragten 2020-01-29 17:51:29 +01:00 committed by GitHub
parent 27ebcc1bda
commit adec2fc2df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,7 @@ import {
EntityRegistryEntry, EntityRegistryEntry,
removeEntityRegistryEntry, removeEntityRegistryEntry,
updateEntityRegistryEntry, updateEntityRegistryEntry,
EntityRegistryEntryUpdateParams,
} from "../../../data/entity_registry"; } from "../../../data/entity_registry";
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box"; import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
import { PolymerChangedEvent } from "../../../polymer-types"; import { PolymerChangedEvent } from "../../../polymer-types";
@ -159,12 +160,15 @@ export class EntityRegistrySettings extends LitElement {
private async _updateEntry(): Promise<void> { private async _updateEntry(): Promise<void> {
this._submitting = true; this._submitting = true;
const params: Partial<EntityRegistryEntryUpdateParams> = {
name: this._name.trim() || null,
new_entity_id: this._entityId.trim(),
};
if (this._disabledBy === null || this._disabledBy === "user") {
params.disabled_by = this._disabledBy;
}
try { try {
await updateEntityRegistryEntry(this.hass!, this._origEntityId, { await updateEntityRegistryEntry(this.hass!, this._origEntityId, params);
name: this._name.trim() || null,
disabled_by: this._disabledBy,
new_entity_id: this._entityId.trim(),
});
fireEvent(this as HTMLElement, "close-dialog"); fireEvent(this as HTMLElement, "close-dialog");
} catch (err) { } catch (err) {
this._error = err.message || "Unknown error"; this._error = err.message || "Unknown error";