diff --git a/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts index 5e19672487..da21cc8004 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-gas-graph-card.ts @@ -26,7 +26,7 @@ import { rgb2hex, rgb2lab, } from "../../../../common/color/convert-color"; -import { labDarken } from "../../../../common/color/lab"; +import { labBrighten, labDarken } from "../../../../common/color/lab"; import { EnergyData, getEnergyDataCollection, @@ -247,10 +247,15 @@ export class HuiEnergyGasGraphCard const data: ChartDataset<"bar" | "line">[] = []; const entity = this.hass.states[source.stat_energy_from]; - const borderColor = + const modifiedColor = idx > 0 - ? rgb2hex(lab2rgb(labDarken(rgb2lab(hex2rgb(gasColor)), idx))) - : gasColor; + ? this.hass.themes.darkMode + ? labBrighten(rgb2lab(hex2rgb(gasColor)), idx) + : labDarken(rgb2lab(hex2rgb(gasColor)), idx) + : undefined; + const borderColor = modifiedColor + ? rgb2hex(lab2rgb(modifiedColor)) + : gasColor; let prevValue: number | null = null; let prevStart: string | null = null; diff --git a/src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts index 98305f7c2a..584da90561 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-solar-graph-card.ts @@ -1,9 +1,3 @@ -import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; -import { customElement, property, state } from "lit/decorators"; -import { UnsubscribeFunc } from "home-assistant-js-websocket"; -import memoizeOne from "memoize-one"; -import { classMap } from "lit/directives/class-map"; -import "../../../../components/ha-card"; import { ChartData, ChartDataset, @@ -17,16 +11,26 @@ import { isToday, startOfToday, } from "date-fns"; -import { HomeAssistant } from "../../../../types"; -import { LovelaceCard } from "../../types"; -import { EnergySolarGraphCardConfig } from "../types"; +import { UnsubscribeFunc } from "home-assistant-js-websocket"; +import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; +import { customElement, property, state } from "lit/decorators"; +import { classMap } from "lit/directives/class-map"; +import memoizeOne from "memoize-one"; import { hex2rgb, lab2rgb, rgb2hex, rgb2lab, } from "../../../../common/color/convert-color"; -import { labDarken } from "../../../../common/color/lab"; +import { labBrighten, labDarken } from "../../../../common/color/lab"; +import { formatTime } from "../../../../common/datetime/format_time"; +import { computeStateName } from "../../../../common/entity/compute_state_name"; +import { + formatNumber, + numberFormatToLocale, +} from "../../../../common/number/format_number"; +import "../../../../components/chart/ha-chart-base"; +import "../../../../components/ha-card"; import { EnergyData, EnergySolarForecasts, @@ -34,15 +38,11 @@ import { getEnergySolarForecasts, SolarSourceTypeEnergyPreference, } from "../../../../data/energy"; -import { computeStateName } from "../../../../common/entity/compute_state_name"; -import "../../../../components/chart/ha-chart-base"; -import { - formatNumber, - numberFormatToLocale, -} from "../../../../common/number/format_number"; -import { SubscribeMixin } from "../../../../mixins/subscribe-mixin"; import { FrontendLocaleData } from "../../../../data/translation"; -import { formatTime } from "../../../../common/datetime/format_time"; +import { SubscribeMixin } from "../../../../mixins/subscribe-mixin"; +import { HomeAssistant } from "../../../../types"; +import { LovelaceCard } from "../../types"; +import { EnergySolarGraphCardConfig } from "../types"; @customElement("hui-energy-solar-graph-card") export class HuiEnergySolarGraphCard @@ -258,10 +258,15 @@ export class HuiEnergySolarGraphCard const data: ChartDataset<"bar" | "line">[] = []; const entity = this.hass.states[source.stat_energy_from]; - const borderColor = + const modifiedColor = idx > 0 - ? rgb2hex(lab2rgb(labDarken(rgb2lab(hex2rgb(solarColor)), idx))) - : solarColor; + ? this.hass.themes.darkMode + ? labBrighten(rgb2lab(hex2rgb(solarColor)), idx) + : labDarken(rgb2lab(hex2rgb(solarColor)), idx) + : undefined; + const borderColor = modifiedColor + ? rgb2hex(lab2rgb(modifiedColor)) + : solarColor; let prevValue: number | null = null; let prevStart: string | null = null; diff --git a/src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts b/src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts index bd6a0f3756..5c1b21a992 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts @@ -17,7 +17,7 @@ import { rgb2lab, hex2rgb, } from "../../../../common/color/convert-color"; -import { labDarken } from "../../../../common/color/lab"; +import { labBrighten, labDarken } from "../../../../common/color/lab"; import { computeStateName } from "../../../../common/entity/compute_state_name"; import { formatNumber } from "../../../../common/number/format_number"; import "../../../../components/chart/statistics-chart"; @@ -170,12 +170,17 @@ export class HuiEnergySourcesTableCard this._data!.stats[source.stat_energy_from] ) || 0; totalSolar += energy; - const color = + + const modifiedColor = idx > 0 - ? rgb2hex( - lab2rgb(labDarken(rgb2lab(hex2rgb(solarColor)), idx)) - ) - : solarColor; + ? this.hass.themes.darkMode + ? labBrighten(rgb2lab(hex2rgb(solarColor)), idx) + : labDarken(rgb2lab(hex2rgb(solarColor)), idx) + : undefined; + const color = modifiedColor + ? rgb2hex(lab2rgb(modifiedColor)) + : solarColor; + return html`