mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-29 12:34:21 +02:00
[astro] Adds dynamic icons for Sun Eclipses (#20007)
* Adds dynamic icons for Sun Eclipse Signed-off-by: clinique <gael@lhopital.org>
This commit is contained in:
@@ -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 |  |
|
||||
| oh:astro:zodiac-aquarius | Yes |  |
|
||||
| oh:astro:zodiac-aries | Yes |  |
|
||||
| oh:astro:zodiac-cancer | Yes |  |
|
||||
| oh:astro:zodiac-capricorn | Yes |  |
|
||||
| oh:astro:zodiac-gemini | Yes |  |
|
||||
| oh:astro:zodiac-leo | Yes |  |
|
||||
| oh:astro:zodiac-libra | Yes |  |
|
||||
| oh:astro:zodiac-pisces | Yes |  |
|
||||
| oh:astro:zodiac-sagittarius | Yes |  |
|
||||
| oh:astro:zodiac-scorpio | Yes |  |
|
||||
| oh:astro:zodiac-taurus | Yes |  |
|
||||
| oh:astro:zodiac-virgo | Yes |  |
|
||||
| oh:astro:season | Yes |  |
|
||||
| oh:astro:season-autumn | Yes |  |
|
||||
| oh:astro:season-spring | Yes |  |
|
||||
| oh:astro:season-summer | Yes |  |
|
||||
| oh:astro:season-winter | Yes |  |
|
||||
| Icon Name | Dynamic | Illustration |
|
||||
| --------------------------- | ------- | ------------------------------------------------- |
|
||||
| oh:astro:zodiac | Yes |  |
|
||||
| oh:astro:season | Yes |  |
|
||||
| oh:astro:sun_eclipse | Yes |  |
|
||||
|
||||
|
||||
## Channels
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<radialGradient id="prefix__a" cx="32" cy="32" r="31" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#f8f5e5" stop-opacity="0" offset=".8" />
|
||||
<stop stop-color="#ffde52" stop-opacity=".2" offset=".8" />
|
||||
<stop stop-color="#ffde52" stop-opacity="0" offset="1" />
|
||||
</radialGradient>
|
||||
</defs>
|
||||
<circle cx="32" cy="32" r="31" fill="url(#prefix__a)" />
|
||||
<circle cx="32" cy="32" r="23" fill="#ffde52" />
|
||||
<ellipse cx="40.787" cy="32.567" rx="21.7" ry="21.824" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 581 B |
+4
-1
@@ -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<String> ICON_SETS = Set.of(SEASON_SET, ZODIAC_SET);
|
||||
private static final String SUN_ECLIPSE_SET = "sun_eclipse";
|
||||
private static final Set<String> 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)));
|
||||
|
||||
@@ -314,7 +314,7 @@
|
||||
<item-type>DateTime</item-type>
|
||||
<label>Total Eclipse</label>
|
||||
<description>The DateTime of the next total eclipse</description>
|
||||
<category>calendar</category>
|
||||
<category>Calendar</category>
|
||||
<tags>
|
||||
<tag>Calculation</tag>
|
||||
<tag>Timestamp</tag>
|
||||
@@ -326,7 +326,7 @@
|
||||
<item-type>DateTime</item-type>
|
||||
<label>Partial Eclipse</label>
|
||||
<description>The DateTime of the next partial eclipse</description>
|
||||
<category>calendar</category>
|
||||
<category>Calendar</category>
|
||||
<tags>
|
||||
<tag>Calculation</tag>
|
||||
<tag>Timestamp</tag>
|
||||
@@ -338,7 +338,7 @@
|
||||
<item-type>DateTime</item-type>
|
||||
<label>Ring Eclipse</label>
|
||||
<description>The DateTime of the next ring eclipse</description>
|
||||
<category>calendar</category>
|
||||
<category>Calendar</category>
|
||||
<tags>
|
||||
<tag>Calculation</tag>
|
||||
<tag>Timestamp</tag>
|
||||
@@ -350,6 +350,7 @@
|
||||
<kind>trigger</kind>
|
||||
<label>Sun Eclipse Event</label>
|
||||
<description>Sun eclipse event</description>
|
||||
<category>oh:astro:sun_eclipse</category>
|
||||
<event>
|
||||
<options>
|
||||
<option value="TOTAL">total</option>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<radialGradient id="prefix__a" cx="32" cy="32" r="31" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#f8f5e5" stop-opacity="0" offset=".8" />
|
||||
<stop stop-color="#ffde52" stop-opacity=".2" offset=".8" />
|
||||
<stop stop-color="#ffde52" stop-opacity="0" offset="1" />
|
||||
</radialGradient>
|
||||
</defs>
|
||||
<circle cx="32" cy="32" r="31" fill="url(#prefix__a)" />
|
||||
<circle cx="32" cy="32" r="23" fill="#ffde52" />
|
||||
<ellipse cx="40.787" cy="32.567" rx="21.7" ry="21.824" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 581 B |
@@ -0,0 +1,12 @@
|
||||
<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<radialGradient id="prefix__a" cx="32" cy="32" r="31" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#f8f5e5" stop-opacity="0" offset=".8" />
|
||||
<stop stop-color="#ffde52" stop-opacity=".2" offset=".8" />
|
||||
<stop stop-color="#ffde52" stop-opacity="0" offset="1" />
|
||||
</radialGradient>
|
||||
</defs>
|
||||
<circle cx="32" cy="32" r="31" fill="url(#prefix__a)" />
|
||||
<circle cx="32" cy="32" r="23" fill="#ffde52" />
|
||||
<circle cx="32" cy="-32" transform="rotate(90)" r="20.957" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 585 B |
@@ -0,0 +1,12 @@
|
||||
<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<radialGradient id="prefix__a" cx="32" cy="32" r="31" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#f8f5e5" stop-opacity="0" offset=".618" />
|
||||
<stop stop-color="#ffde52" stop-opacity=".836" offset=".798" />
|
||||
<stop stop-color="#ffde52" stop-opacity="0" offset="1" />
|
||||
</radialGradient>
|
||||
</defs>
|
||||
<circle cx="32" cy="32" r="31" fill="url(#prefix__a)" />
|
||||
<circle cx="32" cy="32" r="23" fill="#ffde52" />
|
||||
<circle cx="32" cy="32" r="23" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 563 B |
@@ -0,0 +1,12 @@
|
||||
<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<radialGradient id="prefix__a" cx="32" cy="32" r="31" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#f8f5e5" stop-opacity="0" offset=".8" />
|
||||
<stop stop-color="#ffde52" stop-opacity=".2" offset=".8" />
|
||||
<stop stop-color="#ffde52" stop-opacity="0" offset="1" />
|
||||
</radialGradient>
|
||||
</defs>
|
||||
<circle cx="32" cy="32" r="31" fill="url(#prefix__a)" />
|
||||
<circle cx="32" cy="32" r="23" fill="#ffde52" />
|
||||
<ellipse cx="40.787" cy="32.567" rx="21.7" ry="21.824" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 581 B |
Reference in New Issue
Block a user