diff --git a/gallery/src/demos/demo-hui-entities-card.js b/gallery/src/demos/demo-hui-entities-card.js index f193d92de0..1c53859965 100644 --- a/gallery/src/demos/demo-hui-entities-card.js +++ b/gallery/src/demos/demo-hui-entities-card.js @@ -38,6 +38,24 @@ const ENTITIES = [ battery: 71, friendly_name: 'Paulus' }), + getEntity('climate', 'ecobee', 'auto', { + current_temperature: 73, + min_temp: 45, + max_temp: 95, + temperature: null, + target_temp_high: 75, + target_temp_low: 70, + fan_mode: 'Auto Low', + fan_list: ['On Low', 'On High', 'Auto Low', 'Auto High', 'Off'], + operation_mode: 'auto', + operation_list: ['heat', 'cool', 'auto', 'off'], + hold_mode: 'home', + swing_mode: 'Auto', + swing_list: ['Auto', '1', '2', '3', 'Off'], + unit_of_measurement: '°F', + friendly_name: 'Ecobee', + supported_features: 1014 + }) ]; const CONFIGS = [ @@ -53,6 +71,7 @@ const CONFIGS = [ - lock.kitchen_door - light.bed_light - light.non_existing + - climate.ecobee ` }, { @@ -66,6 +85,7 @@ const CONFIGS = [ - group.kitchen - lock.kitchen_door - light.bed_light + - climate.ecobee title: Random group ` }, @@ -80,6 +100,7 @@ const CONFIGS = [ - group.kitchen - lock.kitchen_door - light.bed_light + - climate.ecobee title: Random group show_header_toggle: false ` @@ -108,6 +129,7 @@ const CONFIGS = [ icon: mdi:home-assistant - lock.kitchen_door - light.bed_light + - climate.ecobee title: Random group show_header_toggle: false ` diff --git a/src/panels/lovelace/common/create-row-element.js b/src/panels/lovelace/common/create-row-element.js index b2e797368e..0cde4011d7 100644 --- a/src/panels/lovelace/common/create-row-element.js +++ b/src/panels/lovelace/common/create-row-element.js @@ -1,5 +1,6 @@ import fireEvent from '../../../common/dom/fire_event.js'; +import '../entity-rows/hui-climate-entity-row.js'; import '../entity-rows/hui-cover-entity-row.js'; import '../entity-rows/hui-group-entity-row.js'; import '../entity-rows/hui-input-number-entity-row.js'; @@ -26,6 +27,7 @@ const SPECIAL_TYPES = new Set([ ]); const DOMAIN_TO_ELEMENT_TYPE = { automation: 'toggle', + climate: 'climate', cover: 'cover', fan: 'toggle', group: 'group', diff --git a/src/panels/lovelace/entity-rows/hui-climate-entity-row.js b/src/panels/lovelace/entity-rows/hui-climate-entity-row.js new file mode 100644 index 0000000000..8393a10a35 --- /dev/null +++ b/src/panels/lovelace/entity-rows/hui-climate-entity-row.js @@ -0,0 +1,44 @@ +import { html } from '@polymer/polymer/lib/utils/html-tag.js'; +import { PolymerElement } from '@polymer/polymer/polymer-element.js'; + +import '../../../components/ha-climate-state.js'; +import '../components/hui-generic-entity-row.js'; + +class HuiClimateEntityRow extends PolymerElement { + static get template() { + return html` + + + + `; + } + + static get properties() { + return { + hass: Object, + _config: Object, + _stateObj: { + type: Object, + computed: '_computeStateObj(hass.states, _config.entity)' + } + }; + } + + _computeStateObj(states, entityId) { + return states && entityId in states ? states[entityId] : null; + } + + setConfig(config) { + if (!config || !config.entity) { + throw new Error('Entity not configured.'); + } + this._config = config; + } +} +customElements.define('hui-climate-entity-row', HuiClimateEntityRow);