less broken thermostat-card (#2793)

* Update hui-thermostat-card.ts

* made light and thermo more consistent
This commit is contained in:
Ian Richardson 2019-02-19 00:16:18 -06:00 committed by Paulus Schoutsen
parent 79a5947587
commit 32d0e8bf1d
2 changed files with 10 additions and 3 deletions

View File

@ -135,6 +135,7 @@ export class HuiLightCard extends LitElement implements LovelaceCard {
const stateObj = this.hass!.states[this._config!.entity] as LightEntity;
if (!stateObj) {
// Card will require refresh to work again
return;
}

View File

@ -213,6 +213,7 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
private get _stepSize(): number {
const stateObj = this.hass!.states[this._config!.entity];
if (stateObj.attributes.target_temp_step) {
return stateObj.attributes.target_temp_step;
}
@ -220,6 +221,13 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
}
private async _initialLoad(): Promise<void> {
const stateObj = this.hass!.states[this._config!.entity] as ClimateEntity;
if (!stateObj) {
// Card will require refresh to work again
return;
}
this._loaded = true;
await this.updateComplete;
@ -233,15 +241,13 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
(this.shadowRoot!.querySelector(
"#thermostat"
)! as HTMLElement).style.height = radius * 2 + "px";
) as HTMLElement)!.style.height = radius * 2 + "px";
const loaded = await loadRoundslider();
this._roundSliderStyle = loaded.roundSliderStyle;
this._jQuery = loaded.jQuery;
const stateObj = this.hass!.states[this._config!.entity] as ClimateEntity;
const _sliderType =
stateObj.attributes.target_temp_low &&
stateObj.attributes.target_temp_high