diff --git a/src/index.js b/src/index.js index 7bf9119..a1264c5 100644 --- a/src/index.js +++ b/src/index.js @@ -236,6 +236,8 @@ class BannerCard extends LitElement { return this.renderDomainCover(options); case "media_player": return this.renderDomainMediaPlayer(options); + case "climate": + return this.renderDomainClimate(options); } } return this.renderDomainDefault(options); @@ -381,6 +383,45 @@ class BannerCard extends LitElement { `; } + + renderDomainClimate(options) { + let entity_id = options.entity.split(".")[1]; + let thermostatTemperature = options.attributes.temperature; + let callClimateService = (options) => { + this._hass.callService("climate", "set_temperature", { "entity_id": options.entity, "temperature": options.attributes.temperature }); + }; + let onThermostatArrowClick = (diff) => { + clearTimeout(this._updateThermostateTemperatureTimeout); + options.attributes.temperature += diff; + this.hass = this._hass; + this._updateThermostateTemperatureTimeout = setTimeout(callClimateService, 3000, options); + }; + let onThermostatArrowUpClick = () => { + onThermostatArrowClick(0.5); + }; + let onThermostatArrowDownClick = () => { + onThermostatArrowClick(-0.5); + }; + return html` +
+ ${options.name} + + + ${thermostatTemperature.toFixed(1)} + + + +
+ `; + } getCardSize() { return 3;