Always show "polling for updates" switch (#16629)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
starkillerOG 2023-05-26 15:52:57 +02:00 committed by GitHub
parent da0cf9d950
commit 85e7986b44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,33 +86,30 @@ class DialogConfigEntrySystemOptions extends LitElement {
dialogInitialFocus
></ha-switch>
</ha-formfield>
${this._allowUpdatePolling()
? html`
<ha-formfield
.label=${html`<p>
${this.hass.localize(
"ui.dialogs.config_entry_system_options.enable_polling_label"
)}
</p>
<p class="secondary">
${this.hass.localize(
"ui.dialogs.config_entry_system_options.enable_polling_description",
"integration",
this.hass.localize(
`component.${this._params.entry.domain}.title`
) || this._params.entry.domain
)}
</p>`}
.dir=${computeRTLDirection(this.hass)}
>
<ha-switch
.checked=${!this._disablePolling}
@change=${this._disablePollingChanged}
.disabled=${this._submitting}
></ha-switch>
</ha-formfield>
`
: ""}
<ha-formfield
.label=${html`<p>
${this.hass.localize(
"ui.dialogs.config_entry_system_options.enable_polling_label"
)}
</p>
<p class="secondary">
${this.hass.localize(
"ui.dialogs.config_entry_system_options.enable_polling_description",
"integration",
this.hass.localize(
`component.${this._params.entry.domain}.title`
) || this._params.entry.domain
)}
</p>`}
.dir=${computeRTLDirection(this.hass)}
>
<ha-switch
.checked=${!this._disablePolling}
@change=${this._disablePollingChanged}
.disabled=${this._submitting}
></ha-switch>
</ha-formfield>
<mwc-button
slot="secondaryAction"
@click=${this.closeDialog}
@ -131,14 +128,6 @@ class DialogConfigEntrySystemOptions extends LitElement {
`;
}
private _allowUpdatePolling() {
return (
this._params!.manifest &&
(this._params!.manifest.iot_class === "local_polling" ||
this._params!.manifest.iot_class === "cloud_polling")
);
}
private _disableNewEntitiesChanged(ev: Event): void {
this._error = undefined;
this._disableNewEntities = !(ev.target as HaSwitch).checked;
@ -154,9 +143,7 @@ class DialogConfigEntrySystemOptions extends LitElement {
const data: ConfigEntryMutableParams = {
pref_disable_new_entities: this._disableNewEntities,
};
if (this._allowUpdatePolling()) {
data.pref_disable_polling = this._disablePolling;
}
data.pref_disable_polling = this._disablePolling;
try {
const result = await updateConfigEntry(
this.hass,