From 3292fb1ec0e72c2d0e8e5aa18ee02b151ca7f187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20L=27hopital?= Date: Fri, 9 Jan 2026 13:27:14 +0100 Subject: [PATCH] [astro] Adds dynamic icons for Sun Eclipses (#20007) * Adds dynamic icons for Sun Eclipse Signed-off-by: clinique --- bundles/org.openhab.binding.astro/README.md | 26 +++++-------------- .../doc/images/sun_eclipse.svg | 12 +++++++++ .../astro/internal/AstroIconProvider.java | 5 +++- .../main/resources/OH-INF/thing/channels.xml | 7 ++--- .../resources/icon/sun_eclipse-partial.svg | 12 +++++++++ .../main/resources/icon/sun_eclipse-ring.svg | 12 +++++++++ .../main/resources/icon/sun_eclipse-total.svg | 12 +++++++++ .../src/main/resources/icon/sun_eclipse.svg | 12 +++++++++ 8 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 bundles/org.openhab.binding.astro/doc/images/sun_eclipse.svg create mode 100644 bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse-partial.svg create mode 100644 bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse-ring.svg create mode 100644 bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse-total.svg create mode 100644 bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse.svg diff --git a/bundles/org.openhab.binding.astro/README.md b/bundles/org.openhab.binding.astro/README.md index 5cdcd1c02a..29ea288552 100644 --- a/bundles/org.openhab.binding.astro/README.md +++ b/bundles/org.openhab.binding.astro/README.md @@ -32,26 +32,12 @@ This is done by setting `useMeteorologicalSeason` to true in the advanced settin This binding has its own IconProvider and makes available the following list of icons -| Icon Name | Dynamic | Illustration | -|-----------------------------|---------|--------------| -| oh:astro:zodiac | Yes | ![Zodiac](doc/images/zodiac.svg) | -| oh:astro:zodiac-aquarius | Yes | ![Aquarius](doc/images/zodiac-aquarius.svg) | -| oh:astro:zodiac-aries | Yes | ![Aries](doc/images/zodiac-aries.svg) | -| oh:astro:zodiac-cancer | Yes | ![Cancer](doc/images/zodiac-cancer.svg) | -| oh:astro:zodiac-capricorn | Yes | ![Capricorn](doc/images/zodiac-capricorn.svg) | -| oh:astro:zodiac-gemini | Yes | ![Gemini](doc/images/zodiac-gemini.svg) | -| oh:astro:zodiac-leo | Yes | ![Leo](doc/images/zodiac-leo.svg) | -| oh:astro:zodiac-libra | Yes | ![Libra](doc/images/zodiac-libra.svg) | -| oh:astro:zodiac-pisces | Yes | ![Pisces](doc/images/zodiac-pisces.svg) | -| oh:astro:zodiac-sagittarius | Yes | ![Sagittarius](doc/images/zodiac-sagittarius.svg) | -| oh:astro:zodiac-scorpio | Yes | ![Scorpio](doc/images/zodiac-scorpio.svg) | -| oh:astro:zodiac-taurus | Yes | ![Taurus](doc/images/zodiac-taurus.svg) | -| oh:astro:zodiac-virgo | Yes | ![Virgo](doc/images/zodiac-virgo.svg) | -| oh:astro:season | Yes | ![Season](doc/images/season.svg) | -| oh:astro:season-autumn | Yes | ![Autumn](doc/images/season-autumn.svg) | -| oh:astro:season-spring | Yes | ![Spring](doc/images/season-spring.svg) | -| oh:astro:season-summer | Yes | ![Summer](doc/images/season-summer.svg) | -| oh:astro:season-winter | Yes | ![Winter](doc/images/season-winter.svg) | +| Icon Name | Dynamic | Illustration | +| --------------------------- | ------- | ------------------------------------------------- | +| oh:astro:zodiac | Yes | ![Zodiac](doc/images/zodiac.svg) | +| oh:astro:season | Yes | ![Season](doc/images/season.svg) | +| oh:astro:sun_eclipse | Yes | ![Sun Eclipse](doc/images/sun_eclipse.svg) | + ## Channels diff --git a/bundles/org.openhab.binding.astro/doc/images/sun_eclipse.svg b/bundles/org.openhab.binding.astro/doc/images/sun_eclipse.svg new file mode 100644 index 0000000000..cf5db40f36 --- /dev/null +++ b/bundles/org.openhab.binding.astro/doc/images/sun_eclipse.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/AstroIconProvider.java b/bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/AstroIconProvider.java index 67293501c4..bb6f453e30 100755 --- a/bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/AstroIconProvider.java +++ b/bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/AstroIconProvider.java @@ -24,6 +24,7 @@ import java.util.Set; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.astro.internal.model.EclipseKind; import org.openhab.binding.astro.internal.model.SeasonName; import org.openhab.binding.astro.internal.model.ZodiacSign; import org.openhab.core.i18n.TranslationProvider; @@ -50,7 +51,8 @@ public class AstroIconProvider implements IconProvider { private static final String DEFAULT_DESCRIPTION = "Icons provided for the Astro Binding"; private static final String ZODIAC_SET = "zodiac"; private static final String SEASON_SET = "season"; - private static final Set ICON_SETS = Set.of(SEASON_SET, ZODIAC_SET); + private static final String SUN_ECLIPSE_SET = "sun_eclipse"; + private static final Set ICON_SETS = Set.of(SEASON_SET, SUN_ECLIPSE_SET, ZODIAC_SET); private final Logger logger = LoggerFactory.getLogger(AstroIconProvider.class); private final TranslationProvider i18nProvider; @@ -93,6 +95,7 @@ public class AstroIconProvider implements IconProvider { Enum stateEnum = switch (category) { case ZODIAC_SET -> ZodiacSign.valueOf(state); case SEASON_SET -> SeasonName.valueOf(state); + case SUN_ECLIPSE_SET -> EclipseKind.valueOf(state); default -> throw new IllegalArgumentException("Category of icon not found: %s".formatted(category)); }; iconName = iconName.replace(".", "-%s.".formatted(stateEnum.name().toLowerCase(Locale.US))); diff --git a/bundles/org.openhab.binding.astro/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.astro/src/main/resources/OH-INF/thing/channels.xml index ab53ea1857..e4641e8596 100644 --- a/bundles/org.openhab.binding.astro/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.astro/src/main/resources/OH-INF/thing/channels.xml @@ -314,7 +314,7 @@ DateTime The DateTime of the next total eclipse - calendar + Calendar Calculation Timestamp @@ -326,7 +326,7 @@ DateTime The DateTime of the next partial eclipse - calendar + Calendar Calculation Timestamp @@ -338,7 +338,7 @@ DateTime The DateTime of the next ring eclipse - calendar + Calendar Calculation Timestamp @@ -350,6 +350,7 @@ trigger Sun eclipse event + oh:astro:sun_eclipse diff --git a/bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse-partial.svg b/bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse-partial.svg new file mode 100644 index 0000000000..cf5db40f36 --- /dev/null +++ b/bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse-partial.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse-ring.svg b/bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse-ring.svg new file mode 100644 index 0000000000..d617f8b8dd --- /dev/null +++ b/bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse-ring.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse-total.svg b/bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse-total.svg new file mode 100644 index 0000000000..27386ad4d2 --- /dev/null +++ b/bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse-total.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse.svg b/bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse.svg new file mode 100644 index 0000000000..cf5db40f36 --- /dev/null +++ b/bundles/org.openhab.binding.astro/src/main/resources/icon/sun_eclipse.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file