Skip to content

Commit

Permalink
Fix issue Animation Not working as expected #36 (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhadamantys authored Mar 30, 2023
1 parent 929c18a commit 25ec390
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions src/canvas-gauge-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,29 +120,31 @@ export class CanvasGaugeCard extends LitElement {

// Here we need to refresh the actual gauge after it has rendered
protected updated(_) {
var gauge;
if (this._config?.gauge.type == "linear-gauge") {
gauge = new Gauge.LinearGauge({
renderTo: this._canvasElement,
height: this._config.gauge["height"],
width: this._config.gauge["width"],
value: 0,
});
} else if (this._config?.gauge.type == "radial-gauge") {
gauge = new Gauge.RadialGauge({
renderTo: this._canvasElement,
height: this._config.gauge["height"],
width: this._config.gauge["width"],
value: 0,
});
}
if (this._gauge == null) {
var gauge;
if (this._config?.gauge.type == "linear-gauge") {
gauge = new Gauge.LinearGauge({
renderTo: this._canvasElement,
height: this._config.gauge["height"],
width: this._config.gauge["width"],
value: 0,
});
} else if (this._config?.gauge.type == "radial-gauge") {
gauge = new Gauge.RadialGauge({
renderTo: this._canvasElement,
height: this._config.gauge["height"],
width: this._config.gauge["width"],
value: 0,
});
}

for (const key in this._config?.gauge) {
if (this._config?.gauge?.hasOwnProperty(key)) {
gauge.options[key] = this._config.gauge[key];
for (const key in this._config?.gauge) {
if (this._config?.gauge?.hasOwnProperty(key)) {
gauge.options[key] = this._config.gauge[key];
}
}
this._gauge = gauge;
}
this._gauge = gauge;
var entityId = this._config?.entity;
this._state = this.hass?.states[entityId!].state;
this._gauge["value"] = this._state;
Expand Down

0 comments on commit 25ec390

Please sign in to comment.