forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sagercaster] Sager Weather Caster Binding initial contribution (open…
…hab#4754) * First commit of v2 SagerCaster Binding Signed-off-by: Gaël L'hopital <gael@lhopital.org> Signed-off-by: Hans-Reiner Hoffmann <hans-reiner.hoffmann@gmx.de>
- Loading branch information
1 parent
a237edb
commit cdbdd2e
Showing
20 changed files
with
6,506 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>org.openhab.binding.sagercaster</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
This content is produced and maintained by the openHAB project. | ||
|
||
* Project home: https://www.openhab.org | ||
|
||
== Declared Project Licenses | ||
|
||
This program and the accompanying materials are made available under the terms | ||
of the Eclipse Public License 2.0 which is available at | ||
https://www.eclipse.org/legal/epl-2.0/. | ||
|
||
== Source Code | ||
|
||
https://github.com/openhab/openhab2-addons |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Sager Weathercaster Binding | ||
|
||
The Sager Weathercaster is a scientific instrument for accurate prediction of the weather. | ||
|
||
## Limitations | ||
|
||
* To operate, this binding will need to use channel values provided by other means (e.g. Weather Binding, Netatmo, a 1-Wire personal weather station...) | ||
|
||
* This binding buffers readings for some hours before producing weather forecasts(wind direction and sea level pressure). SagerWeatherCaster needs an observation period of minimum 6 hours. | ||
|
||
For these reasons, this binding is not a binding in the usual sense. | ||
|
||
## Discovery | ||
|
||
A default `sagercaster` thing will be automatically discovered, based on system location. | ||
|
||
## Binding Configuration | ||
|
||
The binding itself does not require any configuration. | ||
|
||
## Thing Configuration | ||
|
||
### SagerCaster | ||
|
||
| Name | Type | Description | | ||
|--------------------|----------|--------------------------------------------------------------------------| | ||
| location | Location | Latitude and longitude of the desired weather forecast. | | ||
| observation-period | int | Minimum delay (in hours) before producing forecasts. Defaulted to 6. | | ||
|
||
## Channels | ||
|
||
The binding will use some input channels, that can be configured directly with profiles (sample below). | ||
|
||
| Name | Group |Type | Description | | ||
|---------------------|--------|---------------------|-----------------------------------------------------------------| | ||
| is-raining (*) | input |Switch | On if it is raining, else Off. | | ||
| rain-qtty (*) | input |Number | Any value that give indication of a current rain volume | | ||
| or | input |Number:Speed | Any value that give indication of a current rain volume eg mm/h | | ||
| or | input |Number:Length | Any value that give indication of a current rain volume eg mm | | ||
| cloudiness | input |Number:Dimensionless | Cloud cover percentage | | ||
| wind-speed-beaufort | input |Number | Wind speed expressed using the Beaufort scale | | ||
| pressure | input |Number:Pressure | Sea level pressure | | ||
| wind-angle | input |Number:Angle | Wind direction | | ||
| forecast | output |String | Description of the weather forecast | | ||
| velocity | output |String | Description of the expected wind evolution | | ||
| velocity-beaufort | output |Number | Expected wind evolution using the Beaufort scale | | ||
| wind-from | output |String | Expected wind orientation | | ||
| wind-to | output |String | Evolution of the expected wind orientation | | ||
| wind-evolution | output |String | Wind orientation evolution over observation period | | ||
| pressure-trend | output |String | Pressure evolution over observation period | | ||
| temperature-trend | output |String | Temperature evolution over observation period | | ||
|
||
(*) You may use either is-raining, either rain-qtty depending upon the data available in your system. | ||
|
||
## Full Example | ||
|
||
### Things | ||
|
||
``` | ||
sagercaster:sagercaster:triel "Sager Triel" @ "Outside" [location="48,2"] | ||
``` | ||
|
||
### Items | ||
|
||
Input channel can be updated via profiles in versions of OH > 2.4. | ||
|
||
``` | ||
Number:Pressure NWS_Abs_Pressure "Pression absolue" <pressure> {channel="netatmo:NAMain:home:insidews:AbsolutePressure", channel="sagercaster:sagercaster:triel:input#pressure" [profile="follow"]} | ||
Number:Angle NWS_wind_angle "Orientation [%d°]" {channel="netatmo:NAModule2:home:anemometre:WindAngle", channel="sagercaster:sagercaster:triel:input#wind-angle" [profile="follow"]} | ||
Number:Dimensionless OWM_Cloudiness "Cloudiness [%d %unit%]" <clouds> {channel="openweathermap:weather-and-forecast:api:local:current#cloudiness", channel="sagercaster:sagercaster:triel:input#cloudiness" [profile="follow"] } | ||
Number Synop_beaufort "Beaufort [%d]" <beaufort> {channel="synopanalyzer:synopanalyzer:orly:wind-speed-beaufort", channel="sagercaster:sagercaster:triel:input#wind-speed-beaufort" [profile="follow"] } | ||
Number:Length NWS_rain_1h "Précipitation 1h [%.2f %unit%]" <rain> {channel="netatmo:NAModule3:home:pluviometre:SumRain1", channel="sagercaster:sagercaster:triel:input#rain-qtty" [profile="follow"]} | ||
``` | ||
|
||
Here is the definition of output channels | ||
|
||
``` | ||
// Items directly derived from inputs | ||
String SWC_windevolution "Wind Evolution" (gSager) {channel="sagercaster:sagercaster:triel:output#wind-evolution"} | ||
String SWC_presstrend "Pressure Trend" (gSager) {channel="sagercaster:sagercaster:triel:output#pressure-trend"} | ||
// SagerWeatherCaster Forecast Items | ||
String SWC_forecast "Weather Forecast" (gSager) {channel="sagercaster:sagercaster:triel:output#forecast"} | ||
String SWC_velocity "Wind Velocity" (gSager) {channel="sagercaster:sagercaster:triel:output#velocity"} | ||
String SWC_windfrom "Wind from" (gSager) {channel="sagercaster:sagercaster:triel:output#wind-from"} | ||
DateTime SWC_ObservationTime "Timestamp [%1$tH:%1$tM]" <time> (gSager, gTrackAge) {channel="sagercaster:sagercaster:triel:output#timestamp" } | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.openhab.addons.bundles</groupId> | ||
<artifactId>org.openhab.addons.reactor.bundles</artifactId> | ||
<version>2.5.4-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>org.openhab.binding.sagercaster</artifactId> | ||
|
||
<name>openHAB Add-ons :: Bundles :: Sager Weathercaster Binding</name> | ||
|
||
</project> |
9 changes: 9 additions & 0 deletions
9
bundles/org.openhab.binding.sagercaster/src/main/feature/feature.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<features name="org.openhab.binding.sagercaster-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"> | ||
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository> | ||
|
||
<feature name="openhab-binding-sagercaster" description="Sager Weathercaster Binding" version="${project.version}"> | ||
<feature>openhab-runtime-base</feature> | ||
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.sagercaster/${project.version}</bundle> | ||
</feature> | ||
</features> |
58 changes: 58 additions & 0 deletions
58
...r/src/main/java/org/openhab/binding/sagercaster/internal/SagerCasterBindingConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright (c) 2010-2020 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.sagercaster.internal; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.smarthome.core.thing.ThingTypeUID; | ||
|
||
/** | ||
* The {@link SagerCasterBindingConstants} class defines common constants, which are | ||
* used across the whole binding. | ||
* | ||
* @author Gaël L'hopital - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class SagerCasterBindingConstants { | ||
|
||
public static final String BINDING_ID = "sagercaster"; | ||
public static final String LOCAL = "local"; | ||
|
||
// List of all Thing Type UIDs | ||
public static final ThingTypeUID THING_TYPE_SAGERCASTER = new ThingTypeUID(BINDING_ID, "sagercaster"); | ||
|
||
// Configuration elements | ||
public static final String CONFIG_LOCATION = "location"; | ||
public static final String CONFIG_PERIOD = "observation-period"; | ||
|
||
// List of all Channel Groups Group Channel ids | ||
public static final String GROUP_INPUT = "input"; | ||
public static final String GROUP_OUTPUT = "output"; | ||
|
||
// Output channel ids | ||
public static final String CHANNEL_FORECAST = "forecast"; | ||
public static final String CHANNEL_VELOCITY = "velocity"; | ||
public static final String CHANNEL_VELOCITY_BEAUFORT = "velocity-beaufort"; | ||
public static final String CHANNEL_WINDFROM = "wind-from"; | ||
public static final String CHANNEL_WINDTO = "wind-to"; | ||
public static final String CHANNEL_WINDEVOLUTION = "wind-evolution"; | ||
public static final String CHANNEL_PRESSURETREND = "pressure-trend"; | ||
public static final String CHANNEL_TEMPERATURETREND = "temperature-trend"; | ||
// Input channel ids | ||
public static final String CHANNEL_CLOUDINESS = "cloudiness"; | ||
public static final String CHANNEL_IS_RAINING = "is-raining"; | ||
public static final String CHANNEL_RAIN_QTTY = "rain-qtty"; | ||
public static final String CHANNEL_WIND_SPEED = "wind-speed-beaufort"; | ||
public static final String CHANNEL_TEMPERATURE = "temperature"; | ||
public static final String CHANNEL_PRESSURE = "pressure"; | ||
public static final String CHANNEL_WIND_ANGLE = "wind-angle"; | ||
} |
66 changes: 66 additions & 0 deletions
66
...ter/src/main/java/org/openhab/binding/sagercaster/internal/SagerCasterHandlerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright (c) 2010-2020 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.sagercaster.internal; | ||
|
||
import static org.openhab.binding.sagercaster.internal.SagerCasterBindingConstants.THING_TYPE_SAGERCASTER; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.eclipse.smarthome.core.thing.Thing; | ||
import org.eclipse.smarthome.core.thing.ThingTypeUID; | ||
import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory; | ||
import org.eclipse.smarthome.core.thing.binding.ThingHandler; | ||
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory; | ||
import org.openhab.binding.sagercaster.internal.handler.SagerCasterHandler; | ||
import org.osgi.service.component.annotations.Activate; | ||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.Reference; | ||
|
||
/** | ||
* The {@link SagerCasterHandlerFactory} is responsible for creating things and thing | ||
* handlers. | ||
* | ||
* @author Gaël L'hopital - Initial contribution | ||
*/ | ||
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.sagercaster") | ||
@NonNullByDefault | ||
public class SagerCasterHandlerFactory extends BaseThingHandlerFactory { | ||
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_SAGERCASTER); | ||
private final WindDirectionStateDescriptionProvider stateDescriptionProvider; | ||
private final SagerWeatherCaster sagerWeatherCaster; | ||
|
||
@Activate | ||
public SagerCasterHandlerFactory(@Reference SagerWeatherCaster sagerWeatherCaster, | ||
@Reference WindDirectionStateDescriptionProvider provider) { | ||
this.stateDescriptionProvider = provider; | ||
this.sagerWeatherCaster = sagerWeatherCaster; | ||
} | ||
|
||
@Override | ||
public boolean supportsThingType(ThingTypeUID thingTypeUID) { | ||
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID); | ||
} | ||
|
||
@Override | ||
protected @Nullable ThingHandler createHandler(Thing thing) { | ||
ThingTypeUID thingTypeUID = thing.getThingTypeUID(); | ||
|
||
if (thingTypeUID.equals(THING_TYPE_SAGERCASTER)) { | ||
return new SagerCasterHandler(thing, stateDescriptionProvider, sagerWeatherCaster); | ||
} | ||
return null; | ||
} | ||
} |
Oops, something went wrong.