From 5889437d5a46852110d47073c7a81110aae9846b Mon Sep 17 00:00:00 2001 From: Raymond Julin Date: Sun, 11 Apr 2021 22:20:31 +0200 Subject: [PATCH] fix: Show a warning with decimals:0, step_size: <1 Fixes #240 --- src/main.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index 925d4fc..c396554 100644 --- a/src/main.ts +++ b/src/main.ts @@ -117,7 +117,7 @@ export default class SimpleThermostat extends LitElement { showSensors: boolean = true @property() name: string | false = '' - _stepSize = STEP_SIZE + stepSize = STEP_SIZE @property() _values: Values @property() @@ -238,7 +238,7 @@ export default class SimpleThermostat extends LitElement { }) if (this.config.step_size) { - this._stepSize = +this.config.step_size + this.stepSize = +this.config.step_size } if (this.config.hide) { @@ -285,6 +285,17 @@ export default class SimpleThermostat extends LitElement { } render({ _hide, _values, _updatingValues, config, entity } = this) { + const warnings = [] + if (this.stepSize < 1 && this.config.decimals === 0) { + warnings.push(html` + + Decimals is set to 0 and step_size is lower than 1. Decrementing a + setpoint will likely not work. Change one of the settings to clear + this warning. + + `) + } + if (!entity) { return html` Entity not available: ${config.entity} @@ -307,6 +318,7 @@ export default class SimpleThermostat extends LitElement { const classes = [!this.header && 'no-header', action].filter((cx) => !!cx) return html` + ${warnings} ${renderHeader({ header: this.header, toggleEntityChanged: this.toggleEntityChanged, @@ -335,7 +347,7 @@ export default class SimpleThermostat extends LitElement { ?disabled=${maxTemp !== null && value >= maxTemp} class="thermostat-trigger" icon=${row ? ICONS.PLUS : ICONS.UP} - @click="${() => this.setTemperature(this._stepSize, field)}" + @click="${() => this.setTemperature(this.stepSize, field)}" > @@ -354,7 +366,7 @@ export default class SimpleThermostat extends LitElement { ?disabled=${minTemp !== null && value <= minTemp} class="thermostat-trigger" icon=${row ? ICONS.MINUS : ICONS.DOWN} - @click="${() => this.setTemperature(-this._stepSize, field)}" + @click="${() => this.setTemperature(-this.stepSize, field)}" >