]> git.basschouten.com Git - openhab-addons.git/commitdiff
[openweathermap] Add daily moon channels to OneCall Thing (#16350)
authorErikDB87 <148375835+ErikDB87@users.noreply.github.com>
Wed, 28 Feb 2024 18:53:12 +0000 (19:53 +0100)
committerGitHub <noreply@github.com>
Wed, 28 Feb 2024 18:53:12 +0000 (19:53 +0100)
* [openweathermap] Add daily moon channels to OneCall Thing
This adds the daily moon data provided by the API (https://openweathermap.org/api/one-call-api#parameter) to the OneCall Thing.

Also-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Erik De Boeck <deboeck.erik@gmail.com>
bundles/org.openhab.binding.openweathermap/README.md
bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/OpenWeatherMapBindingConstants.java
bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Daily.java
bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHandler.java
bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap.properties
bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/thing/channel-types.xml
bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/thing/thing-types.xml
bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/update/instructions.xml

index 2b5aecb95ff1a6edb39cb987a92f5c29516f8afd..7f37efcd198e50bcb1a51210f1af2c68f03d5f99 100644 (file)
@@ -191,39 +191,43 @@ In a future release, the `forecastHours01` to `forecastHours48` channel groups w
 
 ### Daily Forecast
 
-| Channel Group ID                                                                | Channel ID           | Item Type            | Description                                                                      |
-|---------------------------------------------------------------------------------|----------------------|----------------------|----------------------------------------------------------------------------------|
-| forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16                | time-stamp           | DateTime             | Date of data forecasted.                                                         |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | sunrise              | DateTime             | Time of sunrise for the given day.                                               |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | sunset               | DateTime             | Time of sunset for the given day.                                                |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | condition            | String               | Forecast weather condition.                                                      |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | condition-id         | String               | Id of the forecasted weather condition. **Advanced**                             |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | icon                 | Image                | Icon representing the forecasted weather condition.                              |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | icon-id              | String               | Id of the icon representing the forecasted weather condition. **Advanced**       |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | apparent-temperature | Number:Temperature   | Forecasted apparent temperature. Not available in the One Call API               |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | min-temperature      | Number:Temperature   | Minimum forecasted temperature of a day.                                         |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | max-temperature      | Number:Temperature   | Maximum forecasted temperature of a day.                                         |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | pressure             | Number:Pressure      | Forecasted barometric pressure.                                                  |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | humidity             | Number:Dimensionless | Forecasted atmospheric humidity.                                                 |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | wind-speed           | Number:Speed         | Forecasted wind speed.                                                           |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | wind-direction       | Number:Angle         | Forecasted wind direction.                                                       |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | gust-speed           | Number:Speed         | Forecasted gust speed. **Advanced**                                              |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | cloudiness           | Number:Dimensionless | Forecasted cloudiness.                                                           |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | rain                 | Number:Length        | Expected rain volume of a day.                                                   |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | snow                 | Number:Length        | Expected snow volume of a day.                                                   |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | dew-point            | Number:Temperature   | Expected dew-point. Only available in the One Call API                           |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | uvindex              | Number               | Forecasted Midday UV Index. Only available in the One Call API                   |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | precip-probability   | Number:Dimensionless | Precipitation probability.                                                       |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | morning-temperature  | Number:Temperature   | Expected morning temperature. Only available in the One Call API                 |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | day-temperature      | Number:Temperature   | Expected day-temperature. Only available in the One Call API                     |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | evening-temperature  | Number:Temperature   | Expected evening-temperature. Only available in the One Call API                 |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | night-temperature    | Number:Temperature   | Expected night-temperature. Only available in the One Call API                   |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | apparent-morning     | Number:Temperature   | Expected apparent temperature in the morning. Only available in the One Call API |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | apparent-day         | Number:Temperature   | Expected apparent temperature in the day. Only available in the One Call API     |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | apparent-evening     | Number:Temperature   | Expected apparent temperature in the evening. Only available in the One Call API |
-| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | apparent-night       | Number:Temperature   | Expected apparent temperature in the night. Only available in the One Call API   |
+| Channel Group ID                                                                | Channel ID           | Item Type            | Description                                                                                                                                                                                                                                                         |
+|---------------------------------------------------------------------------------|----------------------|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16                | time-stamp           | DateTime             | Date of data forecasted.                                                                                                                                                                                                                                            |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | sunrise              | DateTime             | Time of sunrise for the given day.                                                                                                                                                                                                                                  |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | sunset               | DateTime             | Time of sunset for the given day.                                                                                                                                                                                                                                   |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | moonrise             | DateTime             | Time of moonrise for the given day.                                                                                                                                                                                                                                 |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | moonset              | DateTime             | Time of moonset for the given day.                                                                                                                                                                                                                                  |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | moon-phase           | Number:Dimensionless | Moon phase for the given day. 0 and 1 are 'new moon', 0.25 is 'first quarter moon', 0.5 is 'full moon' and 0.75 is 'last quarter moon'. The periods in between are called 'waxing crescent', 'waxing gibous', 'waning gibous', and 'waning crescent', respectively. |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | condition            | String               | Forecast weather condition.                                                                                                                                                                                                                                         |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | condition-id         | String               | Id of the forecasted weather condition. **Advanced**                                                                                                                                                                                                                |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | icon                 | Image                | Icon representing the forecasted weather condition.                                                                                                                                                                                                                 |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | icon-id              | String               | Id of the icon representing the forecasted weather condition. **Advanced**                                                                                                                                                                                          |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | apparent-temperature | Number:Temperature   | Forecasted apparent temperature. Not available in the One Call API                                                                                                                                                                                                  |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | min-temperature      | Number:Temperature   | Minimum forecasted temperature of a day.                                                                                                                                                                                                                            |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | max-temperature      | Number:Temperature   | Maximum forecasted temperature of a day.                                                                                                                                                                                                                            |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | pressure             | Number:Pressure      | Forecasted barometric pressure.                                                                                                                                                                                                                                     |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | humidity             | Number:Dimensionless | Forecasted atmospheric humidity.                                                                                                                                                                                                                                    |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | wind-speed           | Number:Speed         | Forecasted wind speed.                                                                                                                                                                                                                                              |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | wind-direction       | Number:Angle         | Forecasted wind direction.                                                                                                                                                                                                                                          |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | gust-speed           | Number:Speed         | Forecasted gust speed. **Advanced**                                                                                                                                                                                                                                 |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | cloudiness           | Number:Dimensionless | Forecasted cloudiness.                                                                                                                                                                                                                                              |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | rain                 | Number:Length        | Expected rain volume of a day.                                                                                                                                                                                                                                      |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay16 | snow                 | Number:Length        | Expected snow volume of a day.                                                                                                                                                                                                                                      |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | dew-point            | Number:Temperature   | Expected dew-point. Only available in the One Call API                                                                                                                                                                                                              |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | uvindex              | Number               | Forecasted Midday UV Index. Only available in the One Call API                                                                                                                                                                                                      |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | precip-probability   | Number:Dimensionless | Precipitation probability.                                                                                                                                                                                                                                          |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | morning-temperature  | Number:Temperature   | Expected morning temperature. Only available in the One Call API                                                                                                                                                                                                    |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | day-temperature      | Number:Temperature   | Expected day-temperature. Only available in the One Call API                                                                                                                                                                                                        |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | evening-temperature  | Number:Temperature   | Expected evening-temperature. Only available in the One Call API                                                                                                                                                                                                    |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | night-temperature    | Number:Temperature   | Expected night-temperature. Only available in the One Call API                                                                                                                                                                                                      |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | apparent-morning     | Number:Temperature   | Expected apparent temperature in the morning. Only available in the One Call API                                                                                                                                                                                    |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | apparent-day         | Number:Temperature   | Expected apparent temperature in the day. Only available in the One Call API                                                                                                                                                                                        |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | apparent-evening     | Number:Temperature   | Expected apparent temperature in the evening. Only available in the One Call API                                                                                                                                                                                    |
+| forecastDaily, forecastToday, forecastTomorrow, forecastDay2, ... forecastDay7  | apparent-night       | Number:Temperature   | Expected apparent temperature in the night. Only available in the One Call API                                                                                                                                                                                      |
 
 The `forecastDaily` channel group provides [time series support](#persisting-time-series).
+The `moon*` channels are currently only provided by the OneCall API Weather and Forecast Thing.
 
 In a future release, the `forecastToday` to `forecastDay7` channel groups won't be created anymore by default as usage of the time series channels instead is encouraged.
 
index b614aab1aeef8ecd018bb89fb4f234154a390974..d7c9edfe3d7d56187a41f6b36771dc89cb9f89df 100644 (file)
@@ -83,6 +83,9 @@ public class OpenWeatherMapBindingConstants {
     public static final String CHANNEL_TIME_STAMP = "time-stamp";
     public static final String CHANNEL_SUNRISE = "sunrise";
     public static final String CHANNEL_SUNSET = "sunset";
+    public static final String CHANNEL_MOONRISE = "moonrise";
+    public static final String CHANNEL_MOONSET = "moonset";
+    public static final String CHANNEL_MOON_PHASE = "moon-phase";
     public static final String CHANNEL_CONDITION = "condition";
     public static final String CHANNEL_CONDITION_ID = "condition-id";
     public static final String CHANNEL_CONDITION_ICON = "icon";
index edf312c7d8fb58fc6bde8a338be6b8e40bbacbdd..3aed7624e1dcf5551eb5336c186a483367c8c712 100644 (file)
@@ -28,6 +28,10 @@ public class Daily {
     private int dt;
     private int sunrise;
     private int sunset;
+    private int moonrise;
+    private int moonset;
+    @SerializedName("moon_phase")
+    private double moonPhase;
     private Temp temp;
     @SerializedName("feels_like")
     private FeelsLikeTemp feelsLikeTemp;
@@ -61,6 +65,18 @@ public class Daily {
         return sunset;
     }
 
+    public int getMoonrise() {
+        return moonrise;
+    }
+
+    public int getMoonset() {
+        return moonset;
+    }
+
+    public double getMoonPhase() {
+        return moonPhase;
+    }
+
     public Temp getTemp() {
         return temp;
     }
index 6c21c4e37207b5cea8483fea901f69b28f0ff510..daf763e7ee1aa180ff70d69ca239dd95ac2d9208 100644 (file)
@@ -666,6 +666,15 @@ public class OpenWeatherMapOneCallHandler extends AbstractOpenWeatherMapHandler
             case CHANNEL_SUNSET:
                 state = getDateTimeTypeState(forecastData.getSunset());
                 break;
+            case CHANNEL_MOONRISE:
+                state = getDateTimeTypeState(forecastData.getMoonrise());
+                break;
+            case CHANNEL_MOONSET:
+                state = getDateTimeTypeState(forecastData.getMoonset());
+                break;
+            case CHANNEL_MOON_PHASE:
+                state = getDecimalTypeState(forecastData.getMoonPhase());
+                break;
             case CHANNEL_CONDITION:
                 if (!forecastData.getWeather().isEmpty()) {
                     state = getStringTypeState(forecastData.getWeather().get(0).getDescription());
index 9ed91981c8595b0113ff9f22853d3af046f0b0c6..864bc3f080ddd37732afad3b2f6b8396c34fd515 100644 (file)
@@ -287,6 +287,14 @@ channel-type.openweathermap.gust-speed.description = Current gust speed.
 channel-type.openweathermap.hourly-forecast-time-stamp.label = Forecast Time
 channel-type.openweathermap.hourly-forecast-time-stamp.description = Time of data forecasted.
 channel-type.openweathermap.hourly-forecast-time-stamp.state.pattern = %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS
+channel-type.openweathermap.moon-phase.label = Moon Phase
+channel-type.openweathermap.moon-phase.description = Moon phase for the given day. 0 and 1 are 'new moon', 0.25 is 'first quarter moon', 0.5 is 'full moon' and 0.75 is 'last quarter moon'. The periods in between are called 'waxing crescent', 'waxing gibous', 'waning gibous', and 'waning crescent', respectively.
+channel-type.openweathermap.moonrise.label = Moonrise Time
+channel-type.openweathermap.moonrise.description = Time of moonrise for the given day.
+channel-type.openweathermap.moonrise.state.pattern = %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS
+channel-type.openweathermap.moonset.label = Moonset Time
+channel-type.openweathermap.moonset.description = Time of moonset for the given day.
+channel-type.openweathermap.moonset.state.pattern = %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS
 channel-type.openweathermap.morning-temperature.label = Morning Temperature
 channel-type.openweathermap.morning-temperature.description = Forecasted outdoor temperature for the morning.
 channel-type.openweathermap.night-temperature.label = Night Temperature
index 67573a833d2da4ad5dc83155732b6a8f047dd099..733f74f13b0151e4218c9b25c44959e75df833e0 100644 (file)
                <channels>
                        <channel id="sunrise" typeId="sunrise"/>
                        <channel id="sunset" typeId="sunset"/>
+                       <channel id="moonrise" typeId="moonrise"/>
+                       <channel id="moonset" typeId="moonset"/>
+                       <channel id="moon-phase" typeId="moon-phase"/>
                        <channel id="condition" typeId="condition"/>
                        <channel id="condition-id" typeId="condition-id"/>
                        <channel id="icon" typeId="condition-icon"/>
                        <channel id="time-stamp" typeId="daily-forecast-time-stamp"/>
                        <channel id="sunrise" typeId="sunrise"/>
                        <channel id="sunset" typeId="sunset"/>
+                       <channel id="moonrise" typeId="moonrise"/>
+                       <channel id="moonset" typeId="moonset"/>
+                       <channel id="moon-phase" typeId="moon-phase"/>
                        <channel id="condition" typeId="condition"/>
                        <channel id="condition-id" typeId="condition-id"/>
                        <channel id="icon" typeId="condition-icon"/>
                <state readOnly="true" pattern="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS"/>
        </channel-type>
 
+       <channel-type id="moonrise">
+               <item-type>DateTime</item-type>
+               <label>Moonrise Time</label>
+               <description>Time of moonrise for the given day.</description>
+               <category>Time</category>
+               <state readOnly="true" pattern="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS"/>
+       </channel-type>
+
+       <channel-type id="moonset">
+               <item-type>DateTime</item-type>
+               <label>Moonset Time</label>
+               <description>Time of moonset for the given day.</description>
+               <category>Time</category>
+               <state readOnly="true" pattern="%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS"/>
+       </channel-type>
+
+       <channel-type id="moon-phase">
+               <item-type>Number</item-type>
+               <label>Moon Phase</label>
+               <description>Moon phase for the given day. 0 and 1 are 'new moon', 0.25 is 'first quarter moon', 0.5 is 'full moon'
+                       and 0.75 is 'last quarter moon'. The periods in between are called 'waxing crescent', 'waxing gibous', 'waning
+                       gibous', and 'waning crescent', respectively.</description>
+               <category>Moon</category>
+               <state readOnly="true" pattern="%.2f"/>
+       </channel-type>
+
        <channel-type id="hourly-forecast-time-stamp">
                <item-type>DateTime</item-type>
                <label>Forecast Time</label>
index 041c2694644f88157ceb54c5605840c6a1b0a6ea..c2fad42bca7dac27cb4e327b06db68e104c5c251 100644 (file)
                </channel-groups>
 
                <properties>
-                       <property name="thingTypeVersion">1</property>
+                       <property name="thingTypeVersion">2</property>
                </properties>
                <representation-property>location</representation-property>
 
index 238adb654cc8d47d69dabc91aaa1cb8d2550513f..a3067de8a621cab207de86a00eb89c7fd02d6692 100644 (file)
                                <type>openweathermap:snow</type>
                        </add-channel>
                </instruction-set>
+               <instruction-set targetVersion="2">
+                       <add-channel id="moonrise"
+                               groupIds="forecastDaily,forecastToday,forecastTomorrow,forecastDay2,forecastDay3,forecastDay4,forecastDay5,forecastDay6,forecastDay7">
+                               <type>openweathermap:moonrise</type>
+                       </add-channel>
+                       <add-channel id="moonset"
+                               groupIds="forecastDaily,forecastToday,forecastTomorrow,forecastDay2,forecastDay3,forecastDay4,forecastDay5,forecastDay6,forecastDay7">
+                               <type>openweathermap:moonset</type>
+                       </add-channel>
+                       <add-channel id="moon-phase"
+                               groupIds="forecastDaily,forecastToday,forecastTomorrow,forecastDay2,forecastDay3,forecastDay4,forecastDay5,forecastDay6,forecastDay7">
+                               <type>openweathermap:moon-phase</type>
+                       </add-channel>
+               </instruction-set>
        </thing-type>
 
 </update:update-descriptions>