Skip to content

Commit 997e2e0

Browse files
committed
[TASK] fix HA core FE Bug, Fix scaleing bugs
1 parent 9aa1ded commit 997e2e0

File tree

11 files changed

+835
-4432
lines changed

11 files changed

+835
-4432
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Version - 2.0.0](https://img.shields.io/badge/Version-2.0.0-009688?style=for-the-badge)](https://github.com/KartoffelToby/better-thermostat-ui-card)
1+
[![Version - 2.1.0](https://img.shields.io/badge/Version-2.1.0-009688?style=for-the-badge)](https://github.com/KartoffelToby/better-thermostat-ui-card)
22
[![Discord](https://img.shields.io/discord/925725316540923914.svg?style=for-the-badge)](https://discord.gg/9BUegWTG3K)
33
[![hacs_badge](https://img.shields.io/badge/HACS-Default-41BDF5.svg?style=for-the-badge)](https://github.com/hacs/integration)
44

dist/better-thermostat-ui-card.js

Lines changed: 139 additions & 240 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 596 additions & 3849 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "better-thermostat-ui-card",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "Lovelace better-thermostat-ui",
55
"keywords": [
66
"home-assistant",
@@ -24,47 +24,29 @@
2424
"start:hass-cmd": "docker run --rm -p8123:8123 -v %cd%/.hass_dev:/config homeassistant/home-assistant:beta"
2525
},
2626
"dependencies": {
27-
"@babel/preset-env": "^7.22.20",
2827
"@egjs/hammerjs": "^2.0.17",
29-
"@lit-labs/context": "^0.4.1",
30-
"@lit-labs/motion": "^1.0.4",
31-
"@lit-labs/virtualizer": "^2.0.7",
32-
"@material/web": "^1.0.0-pre.17",
3328
"@mdi/js": "^7.2.96",
34-
"@svgdotjs/svg.js": "^3.2.0",
35-
"@types/gsap": "^3.0.0",
36-
"animejs": "^3.2.1",
37-
"custom-card-helpers": "^1.9.0",
38-
"gsap": "^3.12.2",
3929
"home-assistant-js-websocket": "^8.2.0",
4030
"lit": "^2.8.0",
41-
"lit-html": "^2.8.0",
42-
"memoize-one": "^6.0.0"
31+
"memoize-one": "^6.0.0",
32+
"superstruct": "^1.0.3"
4333
},
4434
"devDependencies": {
4535
"@babel/core": "^7.22.20",
4636
"@babel/preset-typescript": "^7.22.15",
4737
"@material/mwc-ripple": "^0.27.0",
48-
"@material/tab-bar": "^14.0.0",
4938
"@rollup/plugin-babel": "6.0.3",
5039
"@rollup/plugin-commonjs": "25.0.4",
5140
"@rollup/plugin-json": "6.0.0",
5241
"@rollup/plugin-node-resolve": "15.2.1",
53-
"@rollup/plugin-replace": "5.0.2",
5442
"@rollup/plugin-typescript": "^11.1.3",
55-
"@types/color": "^3.0.4",
56-
"@types/hammerjs": "^2.0.42",
5743
"@types/node": "^20.6.2",
58-
"eslint": "^8.49.0",
5944
"prettier": "^3.0.3",
6045
"rollup": "2.79.1",
61-
"rollup-plugin-import-css": "^3.3.3",
46+
"rollup-plugin-import-css": "^3.3.4",
6247
"rollup-plugin-minify-html-literals": "^1.2.6",
6348
"rollup-plugin-serve": "^2.0.2",
64-
"rollup-plugin-string": "3.0.0",
6549
"rollup-plugin-terser": "7.0.2",
66-
"rollup-plugin-version-injector": "^1.3.3",
67-
"rollup-plugin-visualizer": "5.9.2",
6850
"typescript": "^5.2.2"
6951
}
7052
}

rollup.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { terser } from "rollup-plugin-terser";
77
import serve from "rollup-plugin-serve";
88
import ignore from "./rollup-ignore-plugin.js";
99
import cssImports from 'rollup-plugin-import-css';
10-
import minifyHTML from 'rollup-plugin-minify-html-literals';
1110
const IGNORED_FILES = [
1211

1312
];

src/better-thermostat-ui.ts

Lines changed: 89 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import {
5151

5252
import { ClimateCardConfig } from './climate-card-config';
5353
import './ha/ha-control-circular-slider';
54-
import './ha/ha-outlined-icon-button';
5554

5655
const UNAVAILABLE = "unavailable";
5756
const UNKNOWN = "unknown";
@@ -149,7 +148,6 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
149148

150149
private _highChanged(ev) {
151150
this.value = ev.detail.value;
152-
console.log(this.value);
153151
this._setTemperature();
154152
}
155153

@@ -210,6 +208,7 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
210208
display: block;
211209
box-sizing: border-box;
212210
position: relative;
211+
container: bt-card / inline-size;
213212
}
214213
215214
ha-card {
@@ -221,11 +220,16 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
221220
justify-items: center;
222221
padding-left: 1em;
223222
padding-right: 1em;
223+
padding-top: 1.5em;
224224
box-sizing: border-box;
225+
position: relative;
225226
}
226227
227-
ha-card#expand {
228-
padding-bottom: 20%;
228+
bt-ha-outlined-icon-button {
229+
border: 1px solid var(--secondary-text-color);
230+
border-radius: 100%;
231+
padding: 0.5em;
232+
cursor: pointer;
229233
}
230234
231235
.content.battery, bt-ha-control-circular-slider.battery {
@@ -290,30 +294,46 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
290294
}
291295
292296
.content {
293-
margin: -0.5em auto;
294297
position: absolute;
295-
width: 100%;
296-
top: 15%;
297-
left: 0;
298-
z-index: 0
298+
width: calc(70% - 40px);
299+
height: calc(70% - 100px);
299300
box-sizing: border-box;
301+
border-radius: 100%;
302+
left: 50%;
303+
top: calc(50% - 20px);
304+
text-align: center;
305+
overflow-wrap: break-word;
306+
pointer-events: none;
307+
display: flex;
308+
align-items: center;
309+
place-content: center;
310+
flex-flow: wrap;
311+
z-index: 0;
312+
transform: translate(-50%,-50%);
313+
max-width: 155px;
300314
}
315+
316+
#main {
317+
transform: scale(2.3);
318+
}
319+
301320
.name {
302321
display: block;
303322
width: 100%;
304323
text-align: center;
305324
font-size: 20px;
306-
padding-top: 1em;
325+
word-break: keep-all;
326+
white-space: nowrap;
327+
text-overflow: ellipsis;
328+
overflow: hidden;
307329
}
308330
svg {
309331
height: auto;
310332
margin: auto;
311333
display: block;
312334
width: 100%;
313-
314-
transform: scale(1.5);
315335
-webkit-backface-visibility: hidden;
316-
max-width: 255px;
336+
max-width: 233px;
317337
}
318338
319339
path {
@@ -371,7 +391,7 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
371391
display: flex;
372392
width: auto;
373393
justify-content: center;
374-
margin-top: 1em;
394+
margin-top: -3em;
375395
margin-bottom: 1em;
376396
}
377397
@@ -381,8 +401,7 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
381401
display: flex;
382402
width: auto;
383403
justify-content: center;
384-
margin-top: 1em;
385-
margin-bottom: 1em;
404+
padding-bottom: 0.2em;
386405
}
387406
388407
#bt-control-buttons .button {
@@ -391,9 +410,8 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
391410
display: flex;
392411
width: auto;
393412
justify-content: center;
394-
margin-top: -1.5em;
395-
margin-bottom: 1em;
396413
padding: 1em;
414+
padding-top: 0.2em;
397415
}
398416
399417
#modes > * {
@@ -477,6 +495,19 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
477495
ha-icon-button[title="eco"] {
478496
--mode-color: var(--energy-non-fossil-color) !important;
479497
}
498+
499+
@container bt-card (max-width: 255px) {
500+
#modes {
501+
margin-top: -2em;
502+
}
503+
ha-card {
504+
padding-top: 2em;
505+
}
506+
.content {
507+
width: calc(90% - 40px);
508+
top: calc(50% - 20px);
509+
}
510+
}
480511
`;
481512

482513
private _vibrate(delay:number) {
@@ -704,7 +735,7 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
704735
step=${this.step}
705736
min=${this.min}
706737
max=${this.max}
707-
></bt-ha-control-circular-slider>
738+
>
708739
<div class="content ${this.lowBattery !== null || this.error.length > 0 ? 'battery': ''} ${this.window ? 'window_open': ''} ${(this?.stateObj?.attributes?.saved_temperature && this?.stateObj?.attributes?.saved_temperature !== null) ? 'eco' : ''} ${this.summer ? 'summer': ''} ">
709740
<svg id="main" viewbox="0 0 125 100">
710741
<g transform="translate(57.5,37) scale(0.35)">
@@ -758,7 +789,7 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
758789
this.hass.locale,
759790
{ minimumFractionDigits: 1, maximumFractionDigits: 1 }
760791
)}`}
761-
<tspan dx="-1" dy="-2" style="font-size: 3px;">
792+
<tspan dx="-0.3" dy="-2" style="font-size: 3px;">
762793
${svg`
763794
${this.hass.config.unit_system.temperature}
764795
`}
@@ -770,7 +801,7 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
770801
this.hass.locale,
771802
{ minimumFractionDigits: 1, maximumFractionDigits: 1 }
772803
)}`}
773-
<tspan dx="1" dy="-2" style="font-size: 3px;">
804+
<tspan dx="-0.3" dy="-2" style="font-size: 3px;">
774805
%
775806
</tspan>
776807
</text>
@@ -779,45 +810,46 @@ export class BetterThermostatUi extends LitElement implements LovelaceCard {
779810
780811
</g>
781812
</svg>
782-
<div id="modes">
783-
${this?._hasSummer ? svg`
784-
${this?._config?.disable_heat ? html `` : this._renderIcon("heat", this.mode)}
785-
${this?._config?.disable_eco ? html `` :
786-
this?.stateObj?.attributes?.saved_temperature &&
787-
this?.stateObj?.attributes?.saved_temperature !== "none" &&
788-
this?.stateObj?.state !== UNAVAILABLE
789-
? this._renderIcon("eco","eco"): this._renderIcon("eco", "none")}
790-
${this?._config?.disable_off ? html `` : this._renderIcon("off", this.mode)}
791-
`:
792-
svg`
793-
${this.modes.map((mode) => {
794-
if(this._config?.disable_heat && mode === "heat") return html ``;
795-
if(this._config?.disable_eco && mode === "eco") return html ``;
796-
if(this._config?.disable_off && mode === "off") return html ``;
797-
return this._renderIcon(mode, this.mode);
798-
})}
799-
`}
813+
</div>
814+
</bt-ha-control-circular-slider>
815+
<div id="modes">
816+
${this?._hasSummer ? svg`
817+
${this?._config?.disable_heat ? html `` : this._renderIcon("heat", this.mode)}
818+
${this?._config?.disable_eco ? html `` :
819+
this?.stateObj?.attributes?.saved_temperature &&
820+
this?.stateObj?.attributes?.saved_temperature !== "none" &&
821+
this?.stateObj?.state !== UNAVAILABLE
822+
? this._renderIcon("eco","eco"): this._renderIcon("eco", "none")}
823+
${this?._config?.disable_off ? html `` : this._renderIcon("off", this.mode)}
824+
`:
825+
svg`
826+
${this.modes.map((mode) => {
827+
if(this._config?.disable_heat && mode === "heat") return html ``;
828+
if(this._config?.disable_eco && mode === "eco") return html ``;
829+
if(this._config?.disable_off && mode === "off") return html ``;
830+
return this._renderIcon(mode, this.mode);
831+
})}
832+
`}
800833
801-
</div>
802-
${this?._config?.disable_buttons ? html`` : html`
803-
<div id="bt-control-buttons">
804-
<div class="button">
805-
<bt-ha-outlined-icon-button
806-
@click=${this._decValue}
807-
>
808-
<ha-svg-icon .path=${mdiMinus}></ha-svg-icon>
809-
</bt-ha-outlined-icon-button>
810-
</div>
811-
<div class="button">
812-
<bt-ha-outlined-icon-button
813-
@click=${this._incValue}
814-
>
815-
<ha-svg-icon .path=${mdiPlus}></ha-svg-icon>
834+
</div>
835+
${this?._config?.disable_buttons ? html`` : html`
836+
<div id="bt-control-buttons">
837+
<div class="button">
838+
<bt-ha-outlined-icon-button
839+
@click=${this._decValue}
840+
>
841+
<ha-svg-icon .path=${mdiMinus}></ha-svg-icon>
816842
</bt-ha-outlined-icon-button>
817-
</div>
818-
</div>
819-
`}
843+
</div>
844+
<div class="button">
845+
<bt-ha-outlined-icon-button
846+
@click=${this._incValue}
847+
>
848+
<ha-svg-icon .path=${mdiPlus}></ha-svg-icon>
849+
</bt-ha-outlined-icon-button>
850+
</div>
820851
</div>
852+
`}
821853
</div>
822854
</ha-card>
823855
`;

src/const.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const CARD_VERSION = '2.0.0';
1+
export const CARD_VERSION = '2.1.0';

0 commit comments

Comments
 (0)