Skip to content

Commit

Permalink
[TASK] add battery warning disable, fix eco mode switch, deps update
Browse files Browse the repository at this point in the history
  • Loading branch information
KartoffelToby committed Jul 14, 2023
1 parent fe926f3 commit c7914d7
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 124 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Version - 1.1.0](https://img.shields.io/badge/Version-1.1.0-009688?style=for-the-badge)](https://github.com/KartoffelToby/better-thermostat-ui-card)
[![Version - 1.1.1](https://img.shields.io/badge/Version-1.1.1-009688?style=for-the-badge)](https://github.com/KartoffelToby/better-thermostat-ui-card)
[![Discord](https://img.shields.io/discord/925725316540923914.svg?style=for-the-badge)](https://discord.gg/9BUegWTG3K)
[![hacs_badge](https://img.shields.io/badge/HACS-Default-41BDF5.svg?style=for-the-badge)](https://github.com/hacs/integration)

Expand Down
16 changes: 8 additions & 8 deletions dist/better-thermostat-ui-card.js

Large diffs are not rendered by default.

203 changes: 98 additions & 105 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "better-thermostat-ui-card",
"version": "1.1.0",
"version": "1.1.1",
"description": "Lovelace better-thermostat-ui",
"keywords": [
"home-assistant",
Expand All @@ -24,19 +24,19 @@
"start:hass-cmd": "docker run --rm -p8123:8123 -v %cd%/.hass_dev:/config homeassistant/home-assistant:beta"
},
"dependencies": {
"@babel/preset-env": "^7.22.7",
"@babel/preset-env": "^7.22.9",
"@mdi/js": "^7.2.96",
"@svgdotjs/svg.js": "^3.2.0",
"@types/gsap": "^3.0.0",
"animejs": "^3.2.1",
"custom-card-helpers": "^1.9.0",
"gsap": "^3.12.2",
"home-assistant-js-websocket": "^8.1.0",
"home-assistant-js-websocket": "^8.2.0",
"lit": "^2.7.6",
"memoize-one": "^6.0.0"
},
"devDependencies": {
"@babel/core": "^7.22.8",
"@babel/core": "^7.22.9",
"@babel/preset-typescript": "^7.22.5",
"@material/mwc-ripple": "^0.27.0",
"@material/tab-bar": "^14.0.0",
Expand All @@ -47,8 +47,8 @@
"@rollup/plugin-typescript": "^11.1.2",
"@types/color": "^3.0.3",
"@types/hammerjs": "^2.0.41",
"@types/node": "^20.4.0",
"eslint": "^8.44.0",
"@types/node": "^20.4.2",
"eslint": "^8.45.0",
"prettier": "^3.0.0",
"rollup": "^3.26.2",
"rollup-plugin-serve": "^2.0.2",
Expand Down
5 changes: 3 additions & 2 deletions src/better-thermostat-ui-card-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ const loadHaComponents = (version: string) => {
}
};

const CLIMATE_LABELS = ["eco_temperature", "disable_window", "disable_summer", "disable_eco", "disable_heat", "disable_off", "disable_menu", "set_current_as_main"] as string[];
const CLIMATE_LABELS = ["eco_temperature", "disable_window", "disable_summer", "disable_eco", "disable_heat", "disable_off", "disable_menu", "disable_battery_warning", "set_current_as_main"] as string[];

const computeSchema = memoizeOne(
(): any[] => [
{ name: "entity", selector: { entity: { domain: ["climate"] } } },
{ name: "name", selector: { text: {} } },
{ name: "eco_temperature", selector: { number: {placeholder: 20, min: 5, max: 45} } },
{ name: "eco_temperature", selector: { number: {placeholder: 20, min: 5, max: 45, default: 20} } },
{
type: "grid",
name: "",
Expand All @@ -50,6 +50,7 @@ const computeSchema = memoizeOne(
{ name: "disable_heat", selector: { boolean: {} } },
{ name: "disable_off", selector: { boolean: {} } },
{ name: "disable_menu", selector: { boolean: {} } },
{ name: "disable_battery_warning", selector: { boolean: {} } },
{ name: "set_current_as_main", selector: { boolean: {} } },
],
},
Expand Down
8 changes: 7 additions & 1 deletion src/better-thermostat-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
this._hasSummer = true;
this.summer = !attributes.call_for_heat
}
if (attributes?.batteries !== undefined) {
if (attributes?.batteries !== undefined && !this?._config?.disable_battery_warning) {
const batteries = Object.entries(JSON.parse(attributes.batteries));
const lowBatteries = batteries.filter((entity: any) => entity[1].battery < 10);
if (lowBatteries.length > 0) {
Expand Down Expand Up @@ -781,6 +781,12 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
});
}
} else {
const saved_temp = this?.stateObj?.attributes?.saved_temperature || null;
if (saved_temp !== null) {
this.hass!.callService("better_thermostat", "restore_saved_target_temperature", {
entity_id: this._config!.entity,
});
}
this.hass!.callService("climate", "set_hvac_mode", {
entity_id: this._config!.entity,
hvac_mode: (e.currentTarget as any).mode,
Expand Down
2 changes: 2 additions & 0 deletions src/climate-card-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type ClimateCardConfig = LovelaceCardConfig &
disable_heat?: boolean;
disable_off?: boolean;
disable_menu?: boolean;
disable_battery_warning?: boolean;
set_current_as_main?: boolean;
eco_temperature?: number;
};
Expand All @@ -47,6 +48,7 @@ export const climateCardConfigStruct = assign(
disable_eco: optional(boolean()),
disable_heat: optional(boolean()),
disable_off: optional(boolean()),
disable_battery_warning: optional(boolean()),
set_current_as_main: optional(boolean()),
eco_temperature: optional(number()),
disable_menu: optional(boolean()),
Expand Down
2 changes: 1 addition & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const CARD_VERSION = '1.1.0';
export const CARD_VERSION = '1.1.1';
1 change: 1 addition & 0 deletions src/localize/languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"disable_heat": "Heiz-Anzeige deaktivieren",
"disable_off": "Aus-Anzeige deaktivieren",
"disable_menu": "Menü deaktivieren",
"disable_battery_warning": "Batterie-Warnung deaktivieren",
"eco_temperature": "Eco Temperatur",
"set_current_as_main": "Zieltemperatur mit aktueller Temperatur tauschen"
}
Expand Down
1 change: 1 addition & 0 deletions src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"disable_heat": "Disable heat",
"disable_off": "Disable off",
"disable_menu": "Disable menu",
"disable_battery_warning": "Disable battery warning",
"eco_temperature": "Eco temperature",
"set_current_as_main": "Swap target with current temperature places"
}
Expand Down

0 comments on commit c7914d7

Please sign in to comment.