From fc96c391e2baf2741b2088b6dd2df61c5899f9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20F=C3=A9lix?= Date: Sun, 21 Apr 2024 17:49:40 +0200 Subject: [PATCH 1/2] feat: :art: hide icons --- src/components/battery.ts | 25 +++++++++++-------- src/components/grid.ts | 2 +- src/components/home.ts | 2 +- src/components/individualLeftBottomElement.ts | 2 +- src/components/individualLeftTopElement.ts | 2 +- .../individualRightBottomElement.ts | 2 +- src/components/individualRightTopElement.ts | 2 +- src/components/nonFossil.ts | 2 +- src/components/solar.ts | 2 +- 9 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/components/battery.ts b/src/components/battery.ts index 4c6fec2..5d1093e 100644 --- a/src/components/battery.ts +++ b/src/components/battery.ts @@ -57,17 +57,20 @@ export const batteryElement = ( })} ` : null} - void }) => { - main.openDetails(e, entities.battery?.state_of_charge!); - }} - @keyDown=${(e: { key: string; stopPropagation: () => void }) => { - if (e.key === "Enter") { - main.openDetails(e, entities.battery?.state_of_charge!); - } - }} - > + ${battery.icon !== " " + ? html` void }) => { + main.openDetails(e, entities.battery?.state_of_charge!); + }} + @keyDown=${(e: { key: string; stopPropagation: () => void }) => { + if (e.key === "Enter") { + main.openDetails(e, entities.battery?.state_of_charge!); + } + }} + />` + : null} ${entities.battery?.display_state === "two_way" || entities.battery?.display_state === undefined || (entities.battery?.display_state === "one_way_no_zero" && battery.state.toBattery > 0) || diff --git a/src/components/grid.ts b/src/components/grid.ts index 38e6cfc..0248439 100644 --- a/src/components/grid.ts +++ b/src/components/grid.ts @@ -37,7 +37,7 @@ export const gridElement = ( }} > ${generalSecondarySpan(main.hass, main, config, templatesObj, grid, "grid")} - + ${grid.icon !== " " ? html` ` : null} ${(entities.grid?.display_state === "two_way" || entities.grid?.display_state === undefined || (entities.grid?.display_state === "one_way_no_zero" && (grid.state.toGrid ?? 0) > 0) || diff --git a/src/components/home.ts b/src/components/home.ts index 9c40a48..fa0e28b 100644 --- a/src/components/home.ts +++ b/src/components/home.ts @@ -53,7 +53,7 @@ export const homeElement = ( }} > ${generalSecondarySpan(main.hass, main, config, templatesObj, home, "home")} - + ${home.icon !== " " ? html`` : null} ${homeUsageToDisplay} ${ diff --git a/src/components/individualLeftBottomElement.ts b/src/components/individualLeftBottomElement.ts index 72b1fd8..ae118d7 100644 --- a/src/components/individualLeftBottomElement.ts +++ b/src/components/individualLeftBottomElement.ts @@ -63,7 +63,7 @@ export const individualLeftBottomElement = ( }} > ${individualSecondarySpan(hass, main, config, templatesObj, individualObj, 1, "left-bottom")} - + ${individualObj?.icon !== " " ? html` ` : null} ${individualObj?.field?.display_zero_state !== false || (individualObj?.state || 0) > (individualObj.displayZeroTolerance ?? 0) ? html` ${individualObj?.showDirection diff --git a/src/components/individualLeftTopElement.ts b/src/components/individualLeftTopElement.ts index 687caca..9f87539 100644 --- a/src/components/individualLeftTopElement.ts +++ b/src/components/individualLeftTopElement.ts @@ -38,7 +38,7 @@ export const individualLeftTopElement = ( }} > ${individualSecondarySpan(main.hass, main, config, templatesObj, individualObj, 0, "left-top")} - + ${individualObj.icon !== " " ? html` ` : null} ${individualObj?.field?.display_zero_state !== false || (individualObj.state || 0) > (individualObj.displayZeroTolerance ?? 0) ? html` ${individualObj?.showDirection diff --git a/src/components/individualRightBottomElement.ts b/src/components/individualRightBottomElement.ts index 341a2f1..9ee9491 100644 --- a/src/components/individualRightBottomElement.ts +++ b/src/components/individualRightBottomElement.ts @@ -46,7 +46,7 @@ export const individualRightBottomElement = ( }} > ${individualSecondarySpan(main.hass, main, config, templatesObj, individualObj, 3, "right-bottom")} - + ${individualObj.icon !== " " ? html` ` : null} ${individualObj?.field?.display_zero_state !== false || (individualObj.state || 0) > (individualObj.displayZeroTolerance ?? 0) ? html` ${individualObj?.showDirection diff --git a/src/components/individualRightTopElement.ts b/src/components/individualRightTopElement.ts index b6a47e4..35bcb3b 100644 --- a/src/components/individualRightTopElement.ts +++ b/src/components/individualRightTopElement.ts @@ -47,7 +47,7 @@ export const individualRightTopElement = ( }} > ${individualSecondarySpan(main.hass, main, config, templatesObj, individualObj, 2, "right-top")} - + ${individualObj.icon !== " " ? html` ` : null} ${individualObj?.field?.display_zero_state !== false || (individualObj.state || 0) > (individualObj.displayZeroTolerance ?? 0) ? html` ${individualObj?.showDirection diff --git a/src/components/nonFossil.ts b/src/components/nonFossil.ts index a47cb8c..1cc06f2 100644 --- a/src/components/nonFossil.ts +++ b/src/components/nonFossil.ts @@ -38,7 +38,7 @@ export const nonFossilElement = ( }} > ${generalSecondarySpan(main.hass, main, config, templatesObj, nonFossil, "low-carbon")} - + ${nonFossil.icon !== " " ? html` ` : null} ${entities.fossil_fuel_percentage?.display_zero_state !== false || (nonFossil.state.power || 0) > (entities.fossil_fuel_percentage?.display_zero_tolerance || 0) ? html` diff --git a/src/components/solar.ts b/src/components/solar.ts index 18944e0..d69222d 100644 --- a/src/components/solar.ts +++ b/src/components/solar.ts @@ -32,7 +32,7 @@ export const solarElement = ( }} > ${generalSecondarySpan(main.hass, main, config, templatesObj, solar, "solar")} - + ${solar.icon !== " " ? html` ` : null} ${entities.solar?.display_zero_state !== false || (solar.state.total || 0) > 0 ? html` ${displayValue(main.hass, config, solar.state.total, { From d31dec95fbaac930f9f42d8176529aafabbc3f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20F=C3=A9lix?= Date: Sun, 21 Apr 2024 17:59:10 +0200 Subject: [PATCH 2/2] fix: :bug: display zero behaviour individual secondary --- src/components/spans/individualSecondarySpan.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/spans/individualSecondarySpan.ts b/src/components/spans/individualSecondarySpan.ts index fa2d9a2..2b6359b 100644 --- a/src/components/spans/individualSecondarySpan.ts +++ b/src/components/spans/individualSecondarySpan.ts @@ -33,9 +33,9 @@ export const individualSecondarySpan = ( const shouldShowSecondary = () => { if (!!templateResult) return true; + if (individual?.secondary?.displayZero === true) return true; if (!individual?.secondary?.state) return false; if (!isNumberValue(individual?.secondary?.state)) return true; - if (individual?.secondary?.displayZero === true) return true; const toleranceSet = individual?.secondary?.displayZeroTolerance ?? 0; return (