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