From b7d7f94c6a2b7893b567ef11c7c41893ba602389 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Sun, 17 Oct 2021 18:33:59 +0200 Subject: [PATCH] add temperature shortcut in mode (#7) --- README.md | 28 +++++++++++++++++++++++++++- climate-mode-entity-row.js | 13 ++++++++++++- images/temperature_example.png | Bin 0 -> 10145 bytes 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 images/temperature_example.png diff --git a/README.md b/README.md index 2fead73..a0c5726 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ resources: | preset_mode | string | No | A valid preset_mode for the entity | | fan_mode | string | No | A valid fan_mode for the entity | | swing_mode | string | No | A valid swing_mode for the entity | +| temperature | number | No | A target temperature for the entity | | color | string | No | Custom color for the icon when toggle | ## Example @@ -85,9 +86,34 @@ entities: color: "#FFC107" ``` +### Temperature shortcuts + +If your thermostat entity does not support presets, you can directly define target temperature in the card + +![Temperature example](images/temperature_example.png) + +```yaml +type: entities +entities: + - entity: climate.heatpump + type: custom:climate-mode-entity-row + modes: + - hvac_mode: "off" + icon: "mdi:power" + color: "#ef5350" + - hvac_mode: "heat" + temperature: 19 + icon: "mdi:leaf" + color: "#66bb6a" + - hvac_mode: "heat" + temperature: 21 + icon: "mdi:fire" + color: "#FFC107" +``` + ### Multi mode config -You can combine or mix hvac_mode, preset_mode, fan_mode and swing_mode to build your custom controls. +You can combine or mix hvac_mode, preset_mode, fan_mode, swing_mode and temperature to build your custom controls. ![Multi example](images/multi_example.png) diff --git a/climate-mode-entity-row.js b/climate-mode-entity-row.js index 0e7aa25..f5e7ae7 100644 --- a/climate-mode-entity-row.js +++ b/climate-mode-entity-row.js @@ -67,7 +67,9 @@ (!mode.preset_mode || mode.preset_mode === this.state.preset_mode) && (!mode.hvac_mode || mode.hvac_mode === this.state.hvac_mode) && (!mode.fan_mode || mode.fan_mode === this.state.fan_mode) && - (!mode.swing_mode || mode.swing_mode === this.state.swing_mode); + (!mode.swing_mode || mode.swing_mode === this.state.swing_mode) && + (mode.temperature == null || + mode.temperature === this.state.temperature); const onClick = () => this.setMode(mode); @@ -114,6 +116,13 @@ swing_mode: mode.swing_mode, }); } + + if (mode.temperature != null) { + this._hass.callService("climate", "set_temperature", { + entity_id: this._config.entity, + temperature: mode.temperature, + }); + } } setConfig(config) { @@ -132,6 +141,7 @@ const preset_mode = entity.attributes.preset_mode; const fan_mode = entity.attributes.fan_mode; const swing_mode = entity.attributes.swing_mode; + const temperature = entity.attributes.temperature; this.state = { entity, @@ -139,6 +149,7 @@ preset_mode, fan_mode, swing_mode, + temperature, }; } } diff --git a/images/temperature_example.png b/images/temperature_example.png new file mode 100644 index 0000000000000000000000000000000000000000..8aac98d567ceef9ed9426ae61eb9ff1847a79509 GIT binary patch literal 10145 zcmeHsby(ZY@^A29h0-FWxO;GS4^mtU1q#7EP~0i*R-i~Jh2j)wafc#BLUAwd9taMX z_I=Me?{n_&-oNi3ck^s^c4j^^JF}Z_Hj_y87Yevoq*wp|02iz%s|f%gg*?!*K=g-q z^E-nQ0076_Qf~|vqikK~!qopbMh5)4E z;MfFI0;L#Csqe3d2#uN|Oy%_Co*Ek?RZ%0VnGmh|>KeKl#Bv&5PY6cbO)eKNTN~iN zc&zTU4hCC103$og-~z8Ae!yiCvVpWL(9X?JIC}gMlO%RR5cSB?@w(<4UtgR+?vZ=r z#b1Dk>b9LvYgd~W0ffdu>cbd-XV@-vASR0nXFSK@g;m95~4tfpSTc z19%PD>pFomvbYF!zZrRj#TA2bVd3AKaVu~)DCJK9^1&}X*&%i<(&rdjRlSu^hPTm6 zsBtZIq4Q@d5@mcCq?|m`J?OTkFO-^R?vIJpnj~GJsFKw20H~KJKF%nsR*1cHeN;wi zD!oUu^j2QR9>=Ag4#Y2C4jUv0hf;@?qGi)?EHOyg1CFKhMAb^xnB<5>(Z^2TyhQ3XlSx@Ye$r0eP^!1x0BvugQ>>o&c!ehxV*-& zw}?W8-00#n0_h)9v-p>BDih^=s0H=E!&{4XAc$2n2<1>mY^j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