diff --git a/src/panels/lovelace/cards/energy/hui-energy-distribution-card.ts b/src/panels/lovelace/cards/energy/hui-energy-distribution-card.ts index 4f455b2d0b..54fb147c27 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-distribution-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-distribution-card.ts @@ -47,6 +47,8 @@ class HuiEnergyDistrubutionCard @state() private _data?: EnergyData; + @state() private _animate = true; + protected hassSubscribeRequiredHostProps = ["_config"]; public setConfig(config: EnergyDistributionCardConfig): void { @@ -78,6 +80,12 @@ class HuiEnergyDistrubutionCard ); } + protected willUpdate() { + if (!this.hasUpdated && matchMedia("(prefers-reduced-motion)").matches) { + this._animate = false; + } + } + protected render() { if (!this._config) { return nothing; @@ -349,7 +357,7 @@ class HuiEnergyDistrubutionCard - ${gasUsage + ${gasUsage && this._animate ? svg` - ${waterUsage + ${waterUsage && this._animate ? svg` - ${waterUsage + ${waterUsage && this._animate ? svg` - ${returnedToGrid && hasSolarProduction + ${returnedToGrid && hasSolarProduction && this._animate ? svg` ` : ""} - ${solarConsumption + ${solarConsumption && this._animate ? svg` ` : ""} - ${gridConsumption + ${gridConsumption && this._animate ? svg` ` : ""} - ${solarToBattery + ${solarToBattery && this._animate ? svg` ` : ""} - ${batteryConsumption + ${batteryConsumption && this._animate ? svg` ` : ""} - ${batteryFromGrid + ${batteryFromGrid && this._animate ? svg` ` : ""} - ${batteryToGrid + ${batteryToGrid && this._animate ? svg`