Skip to content

Commit

Permalink
add temperature shortcut in mode (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya authored Oct 17, 2021
1 parent ada6793 commit b7d7f94
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
13 changes: 12 additions & 1 deletion climate-mode-entity-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand All @@ -132,13 +141,15 @@
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,
hvac_mode,
preset_mode,
fan_mode,
swing_mode,
temperature,
};
}
}
Expand Down
Binary file added images/temperature_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b7d7f94

Please sign in to comment.