Skip to content

Commit 3ae9efe

Browse files
authored
Changes for Version 1.3.3.1
## Fixed - Power flow lines now recalculate flow speed at the end of the animation run. This should remove any more dot "juddering" when entity values change.
1 parent 5843887 commit 3ae9efe

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/pacemaker82/compact-power-card/total?label=Total%20Downloads) ![GitHub Downloads (all assets, latest release)](https://img.shields.io/github/downloads/pacemaker82/compact-power-card/latest/total?label=Latest%20Version)
44

5+
If you enjoy this card, please give it a [star on the github repository](https://github.com/pacemaker82/Compact-Power-Card). Thank you!
6+
57
<img width="1043" height="640" alt="Screenshot 2025-12-24 at 07 39 40" src="https://github.com/user-attachments/assets/583dde65-2885-4cfb-8db0-d91a9ec7c580" />
68

79
Inspired by the excellent [power flow card plus](https://github.com/flixlix/power-flow-card-plus) - A compact power card for Home Assistant that supports a tighter user experience, labels and power devices in the home in a single card. Various elements are very customisable, see below for more.

‎compact-power-card.js‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,13 +2839,7 @@ class CompactPowerCard extends (window.LitElement ||
28392839
if (existing && existing.active) {
28402840
existing.geom = geom;
28412841
if (Number.isFinite(duration)) {
2842-
const now = performance.now ? performance.now() : Date.now();
2843-
const prev = Number.isFinite(existing.duration) ? existing.duration : duration;
2844-
const dt = Math.max(0, now - (existing.lastUpdateTs || now));
2845-
const tau = 1200; // ms time constant for smoothing
2846-
const alpha = 1 - Math.exp(-dt / tau);
2847-
existing.duration = prev + (duration - prev) * alpha;
2848-
existing.lastUpdateTs = now;
2842+
existing.pendingDuration = duration;
28492843
}
28502844
if (geom?.mode === "path") {
28512845
existing.pathEl = null;
@@ -2864,7 +2858,8 @@ class CompactPowerCard extends (window.LitElement ||
28642858
start: null,
28652859
geom,
28662860
duration,
2867-
lastUpdateTs: performance.now ? performance.now() : Date.now(),
2861+
pendingDuration: null,
2862+
lastPhase: 0,
28682863
};
28692864
if (name === "pv-home") {
28702865
animState.lockCXPercent = "50%";
@@ -2877,6 +2872,12 @@ class CompactPowerCard extends (window.LitElement ||
28772872
const d = animState.duration || 1500;
28782873
const elapsed = (timestamp - animState.start) % d;
28792874
const t = elapsed / d;
2875+
if (animState.pendingDuration != null && t < animState.lastPhase) {
2876+
animState.duration = animState.pendingDuration;
2877+
animState.pendingDuration = null;
2878+
animState.start = timestamp;
2879+
}
2880+
animState.lastPhase = t;
28802881
const fadeInEnd = 0.05;
28812882
const fadeOutStart = 0.85;
28822883
let opacity = 1;

0 commit comments

Comments
 (0)