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