Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[meteoalerte] Météo Alerte binding #7200

Merged
merged 16 commits into from
May 30, 2020
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
/bundles/org.openhab.binding.max/ @marcelrv
/bundles/org.openhab.binding.mcp23017/ @aogorek
/bundles/org.openhab.binding.melcloud/ @lucacalcaterra @paulianttila @thewiep
/bundles/org.openhab.binding.meteoalerte/ @clinique
/bundles/org.openhab.binding.meteoblue/ @9037568
/bundles/org.openhab.binding.meteostick/ @cdjackson
/bundles/org.openhab.binding.miele/ @kgoderis
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,11 @@
<artifactId>org.openhab.binding.melcloud</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.meteoalerte</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.meteoblue</artifactId>
Expand Down
32 changes: 32 additions & 0 deletions bundles/org.openhab.binding.meteoalerte/.classpath
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="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="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="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions bundles/org.openhab.binding.meteoalerte/.project
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.meteoalerte</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>
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.meteoalerte/NOTICE
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/openhab-addons
96 changes: 96 additions & 0 deletions bundles/org.openhab.binding.meteoalerte/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Meteo Alerte Binding

clinique marked this conversation as resolved.
Show resolved Hide resolved
The Meteo Alerte binding gives alert level regarding major weather related risk factors.

## Supported Things

There is exactly one supported thing type, which represents the weather alerts for a given department.
It has the `department` id.
Of course, you can add multiple Things, e.g. for getting alerts for different locations.
clinique marked this conversation as resolved.
Show resolved Hide resolved

## Discovery

This binding does not handle auto-discovery.

clinique marked this conversation as resolved.
Show resolved Hide resolved
## Binding Configuration

The binding has no configuration options, all configuration is done at Thing level.
lolodomo marked this conversation as resolved.
Show resolved Hide resolved

## Thing Configuration

The thing has a few configuration parameters:

| Parameter | Description |
|------------|---------------------------------------------------------------------|
| department | Name of the department. |
clinique marked this conversation as resolved.
Show resolved Hide resolved
| refresh | Refresh interval in hours. Optional, the default value is 24 hours. |

## Channels

The Météo Alerte information that are retrieved is available as these channels:

| Channel ID | Item Type | Description |
clinique marked this conversation as resolved.
Show resolved Hide resolved
|-----------------------|-----------|-----------------------------------------------|
| observation-time | DateTime | Date and time of alert creation |
| comment | String | General comments on alerts for the department |
| vent | String | Wind alert level (*) |
| pluie-inondation | String | Rain alert level (*) |
| orage | String | Storm alert level (*) |
| inondation | String | Flood alert level (*) |
| neige | String | Snow alert level (*) |
| canicule | String | Heat alert level (*) |
| grand-froid | String | Cold alert level (*) |
| avalanches | String | Avalanche alert level (*) |
| pluie-inondation-icon | Image | Pictogram of the Rain alert level |
| vent-icon | Image | Pictogram of the Wind alert level |
| orage-icon | Image | Pictogram of Storm alert level |
| inondation-icon | Image | Pictogram of Flood alert level |
| neige-icon | Image | Pictogram of Snow alert level |
| canicule-icon | Image | Pictogram of Heat alert level |
| grand-froid-icon | Image | Pictogram of Cold alert level |
| avalanches-icon | Image | Pictogram of Avalanche alert level |

(*) Each alert level is described by a color :

| Code | Color | Description |
|------|--------|-------------------------------------------|
| 0 | Green | No particular vigilance |
| 1 | Yellow | Be attentive to the weather situation |
| 2 | Orange | Be "very vigilant" in the concerned areas |
| 3 | Red | Absolute vigilance required |


## Full Example

meteoalert.things:

```
Thing meteoalerte:department:yvelines @ "MyCity" [department="YVELINES", refresh=12]
```

meteoalert.items:
clinique marked this conversation as resolved.
Show resolved Hide resolved

```
Group gMeteoAlert "Alertes Météo" <weather>
String MA_Dept78 "Département 78 [%s]" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:comment"}
String MA_etat_canicule "Canicule [%s]" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:canicule"}
String MA_etat_grand_froid "Grand Froid [%s]" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:grand-froid"}
String MA_etat_pluie_inondation "Pluie-Inondation [%s]" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:pluie-inondation"}
String MA_etat_neige "Neige [%s]" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:neige"}
String MA_etat_vent "Vent [%s]" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:vent"}
String MA_etat_inondation "Inondation [%s]" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:inondation"}
String MA_etat_orage "Orage [%s]" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:orage"}
String MA_etat_avalanche "Avalanches [%s]" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:avalanches"}

Image MA_icon_canicule "Canicule" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:canicule-icon"}
Image MA_icon_grand_froid "Grand Froid" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:grand-froid-icon"}
Image MA_icon_pluie_inondation "Pluie-Inondation" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:pluie-inondation-icon"}
Image MA_icon_neige "Neige" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:neige-icon"}
Image MA_icon_vent "Vent" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:vent-icon"}
Image MA_icon_inondation "Inondation" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:inondation-icon"}
Image MA_icon_orage "Orage" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:orage-icon"}
Image MA_icon_avalanche "Avalanche" <aqi> (gMeteoAlert) {channel="meteoalerte:department:yvelines:avalanches-icon"}

DateTime MA_ObservationTS "Timestamp [%1$tH:%1$tM]" <time> (gMeteoAlert) {channel="meteoalerte:department:yvelines:observation-time"}

```
15 changes: 15 additions & 0 deletions bundles/org.openhab.binding.meteoalerte/pom.xml
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/xsd/maven-4.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.6-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.meteoalerte</artifactId>

<name>openHAB Add-ons :: Bundles :: Meteo Alerte Binding</name>

</project>
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.meteoalerte-${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-meteoalerte" description="Meteo Alerte Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.meteoalerte/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* 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.meteoalerte.internal;

import java.util.Collections;
import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.thing.ThingTypeUID;

/**
* The {@link MeteoAlerteBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Gaël L'hopital - Initial contribution
*/
@NonNullByDefault
public class MeteoAlerteBindingConstants {

public static final String BINDING_ID = "meteoalerte";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_METEO_ALERT = new ThingTypeUID(BINDING_ID, "department");

// List of all Channel id's
public static final String AVALANCHE = "avalanches";
public static final String HEAT = "canicule";
public static final String FREEZE = "grand-froid";
public static final String FLOOD = "inondation";
public static final String SNOW = "neige";
public static final String STORM = "orage";
public static final String RAIN = "pluie-inondation";
public static final String WIND = "vent";
public static final String WIND_ICON = "vent-icon";
public static final String RAIN_ICON = "pluie-inondation-icon";
public static final String STORM_ICON = "orage-icon";
public static final String FLOOD_ICON = "inondation-icon";
public static final String SNOW_ICON = "neige-icon";
public static final String HEAT_ICON = "canicule-icon";
public static final String FREEZE_ICON = "grand-froid-icon";
public static final String AVALANCHE_ICON = "avalanches-icon";
public static final String OBSERVATION_TIME = "observation-time";
public static final String COMMENT = "comment";

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_METEO_ALERT);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* 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.meteoalerte.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link MeteoAlerteConfiguration} is the class used to match the
* thing configuration.
*
* @author Gaël L'hopital - Initial contribution
*/
@NonNullByDefault
public class MeteoAlerteConfiguration {
public String department = "";
public Integer refresh = 24;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* 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.meteoalerte.internal;

import static org.openhab.binding.meteoalerte.internal.MeteoAlerteBindingConstants.*;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.i18n.TimeZoneProvider;
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.meteoalerte.internal.handler.MeteoAlerteHandler;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* The {@link MeteoAlerteHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Gaël L'hopital - Initial contribution
*/
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.meteoalerte")
@NonNullByDefault
public class MeteoAlerteHandlerFactory extends BaseThingHandlerFactory {

// Needed for converting UTC time to local time
private final TimeZoneProvider timeZoneProvider;

@Activate
public MeteoAlerteHandlerFactory(@Reference TimeZoneProvider timeZoneProvider) {
this.timeZoneProvider = timeZoneProvider;
}

@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_METEO_ALERT)) {
return new MeteoAlerteHandler(thing, timeZoneProvider);
}

return null;
}

}
Loading