added migrated 2.x add-ons
Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
32
bundles/org.openhab.binding.windcentrale/.classpath
Normal file
32
bundles/org.openhab.binding.windcentrale/.classpath
Normal file
@@ -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-11">
|
||||
<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>
|
||||
23
bundles/org.openhab.binding.windcentrale/.project
Normal file
23
bundles/org.openhab.binding.windcentrale/.project
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.openhab.binding.windcentrale</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
bundles/org.openhab.binding.windcentrale/NOTICE
Normal file
13
bundles/org.openhab.binding.windcentrale/NOTICE
Normal file
@@ -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
|
||||
77
bundles/org.openhab.binding.windcentrale/README.md
Normal file
77
bundles/org.openhab.binding.windcentrale/README.md
Normal file
@@ -0,0 +1,77 @@
|
||||
# Windcentrale Binding
|
||||
|
||||
This Binding is used to display the details of a Windcentrale windmill.
|
||||
|
||||
## Supported Things
|
||||
|
||||
This Binding supports Windcentrale mill devices.
|
||||
|
||||
## Discovery
|
||||
|
||||
There is no discovery available for this binding.
|
||||
|
||||
## Binding Configuration
|
||||
|
||||
No binding configuration required.
|
||||
|
||||
## Thing Configuration
|
||||
|
||||
| Configuration Parameter | Required | Default | Description |
|
||||
|-------------------------|----------|---------|-----------------------------------------------------|
|
||||
| millId | X | 131 | Identifies the windmill (see table below) |
|
||||
| wd | | 1 | Number of wind shares ("Winddelen") |
|
||||
| refreshInterval | | 30 | Refresh interval for refreshing the data in seconds |
|
||||
|
||||
| millId | Windmill name |
|
||||
|--------|-------------------|
|
||||
| 1 | De Grote Geert |
|
||||
| 2 | De Jonge Held |
|
||||
| 31 | Het Rode Hert |
|
||||
| 41 | De Ranke Zwaan |
|
||||
| 51 | De Witte Juffer |
|
||||
| 111 | De Bonte Hen |
|
||||
| 121 | De Trouwe Wachter |
|
||||
| 131 | De Blauwe Reiger |
|
||||
| 141 | De Vier Winden |
|
||||
| 201 | De Boerenzwaluw |
|
||||
|
||||
## Channels
|
||||
|
||||
| Channel Type ID | Item Type | Description |
|
||||
|-----------------|----------------------|-------------------------------------|
|
||||
| kwh | Number:Energy | Current energy |
|
||||
| kwhForecast | Number:Energy | Energy forecast |
|
||||
| powerAbsTot | Number:Power | Total power |
|
||||
| powerAbsWd | Number:Power | Power provided for your wind shares |
|
||||
| powerRel | Number:Dimensionless | Relative power |
|
||||
| runPercentage | Number:Dimensionless | Run percentage this year |
|
||||
| runTime | Number:Time | Run time this year |
|
||||
| timestamp | DateTime | Timestamp of the last update |
|
||||
| windDirection | String | Current wind direction |
|
||||
| windSpeed | Number | Measured current wind speed (Bft) |
|
||||
|
||||
## Example
|
||||
|
||||
### demo.things
|
||||
|
||||
```
|
||||
Thing windcentrale:mill:geert [ millId=1 ]
|
||||
Thing windcentrale:mill:reiger [ millId=131, wd=3, refreshInterval=60 ]
|
||||
```
|
||||
|
||||
### demo.items
|
||||
|
||||
```
|
||||
Group gReiger "Windcentrale Reiger" <wind>
|
||||
|
||||
Number ReigerWindSpeed "Wind speed [%d Bft]" <wind> (gReiger) { channel="windcentrale:mill:reiger:windSpeed" }
|
||||
String ReigerWindDirection "Wind direction [%s]" <wind> (gReiger) { channel="windcentrale:mill:reiger:windDirection" }
|
||||
Number:Power ReigerPowerAbsTot "Total mill power [%.1f %unit%]" <wind> (gReiger) { channel="windcentrale:mill:reiger:powerAbsTot" }
|
||||
Number:Power ReigerPowerAbsWd "Wind shares power [%.1f %unit%]" <wind> (gReiger) { channel="windcentrale:mill:reiger:powerAbsWd" }
|
||||
Number:Dimensionless ReigerPowerRel "Relative power [%.1f %unit%]" <wind> (gReiger) { channel="windcentrale:mill:reiger:powerRel" }
|
||||
Number:Energy ReigerKwh "Current energy [%.0f %unit%]" <wind> (gReiger) { channel="windcentrale:mill:reiger:kwh" }
|
||||
Number:Energy ReigerKwhForecast "Energy forecast [%.0f %unit%]" <wind> (gReiger) { channel="windcentrale:mill:reiger:kwhForecast" }
|
||||
Number:Dimensionless ReigerRunPercentage "Run percentage [%.1f %unit%]" <wind> (gReiger) { channel="windcentrale:mill:reiger:runPercentage" }
|
||||
Number:Time ReigerRunTime "Run time [%.0f %unit%]" <wind> (gReiger) { channel="windcentrale:mill:reiger:runTime" }
|
||||
DateTime ReigerTimestamp "Update timestamp [%1$ta %1$tR]" <wind> (gReiger) { channel="windcentrale:mill:reiger:timestamp" }
|
||||
```
|
||||
17
bundles/org.openhab.binding.windcentrale/pom.xml
Normal file
17
bundles/org.openhab.binding.windcentrale/pom.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>org.openhab.binding.windcentrale</artifactId>
|
||||
|
||||
<name>openHAB Add-ons :: Bundles :: Windcentrale Binding</name>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<features name="org.openhab.binding.windcentrale-${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-windcentrale" description="Windcentrale Binding" version="${project.version}">
|
||||
<feature>openhab-runtime-base</feature>
|
||||
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.windcentrale/${project.version}</bundle>
|
||||
</feature>
|
||||
</features>
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 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.windcentrale.internal;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
|
||||
/**
|
||||
* The {@link WindcentraleBindingConstants} class defines common constants, which are
|
||||
* used across the whole binding.
|
||||
*
|
||||
* @author Marcel Verpaalen - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public final class WindcentraleBindingConstants {
|
||||
|
||||
public static final String BINDING_ID = "windcentrale";
|
||||
|
||||
// List of all Thing Type UIDs
|
||||
public static final ThingTypeUID THING_TYPE_MILL = new ThingTypeUID(BINDING_ID, "mill");
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_MILL);
|
||||
|
||||
// List of all Channel IDs
|
||||
public static final String CHANNEL_WIND_SPEED = "windSpeed";
|
||||
public static final String CHANNEL_WIND_DIRECTION = "windDirection";
|
||||
public static final String CHANNEL_POWER_TOTAL = "powerAbsTot";
|
||||
public static final String CHANNEL_POWER_PER_WD = "powerAbsWd";
|
||||
public static final String CHANNEL_POWER_RELATIVE = "powerRel";
|
||||
public static final String CHANNEL_ENERGY = "kwh";
|
||||
public static final String CHANNEL_ENERGY_FC = "kwhForecast";
|
||||
public static final String CHANNEL_RUNTIME = "runTime";
|
||||
public static final String CHANNEL_RUNTIME_PER = "runPercentage";
|
||||
public static final String CHANNEL_LAST_UPDATE = "timestamp";
|
||||
|
||||
public static final String PROPERTY_MILL_ID = "millId";
|
||||
public static final String PROPERTY_QTY_WINDDELEN = "wd";
|
||||
public static final String PROPERTY_REFRESH_INTERVAL = "refreshInterval";
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 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.windcentrale.internal;
|
||||
|
||||
import static org.openhab.binding.windcentrale.internal.WindcentraleBindingConstants.*;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.windcentrale.internal.handler.WindcentraleHandler;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
|
||||
import org.openhab.core.thing.binding.ThingHandler;
|
||||
import org.openhab.core.thing.binding.ThingHandlerFactory;
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
|
||||
/**
|
||||
* The {@link WindcentraleHandlerFactory} is responsible for creating things and thing
|
||||
* handlers.
|
||||
*
|
||||
* @author Marcel Verpaalen - Initial contribution
|
||||
*/
|
||||
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.windcentrale")
|
||||
@NonNullByDefault
|
||||
public class WindcentraleHandlerFactory extends BaseThingHandlerFactory {
|
||||
|
||||
@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_MILL)) {
|
||||
return new WindcentraleHandler(thing);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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.windcentrale.internal.config;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
||||
/**
|
||||
* The configuration of a Mill thing.
|
||||
*
|
||||
* @author Wouter Born - Add Mill configuration object
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class MillConfig {
|
||||
|
||||
/**
|
||||
* Windmill identifier
|
||||
*/
|
||||
public int millId = 1;
|
||||
|
||||
/**
|
||||
* Refresh interval for refreshing the data in seconds
|
||||
*/
|
||||
public int refreshInterval = 30;
|
||||
|
||||
/**
|
||||
* Number of wind shares ("Winddelen")
|
||||
*/
|
||||
public int wd = 1;
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* 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.windcentrale.internal.handler;
|
||||
|
||||
import static org.openhab.binding.windcentrale.internal.WindcentraleBindingConstants.*;
|
||||
import static org.openhab.core.library.unit.MetricPrefix.KILO;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.windcentrale.internal.config.MillConfig;
|
||||
import org.openhab.core.cache.ExpiringCache;
|
||||
import org.openhab.core.io.net.http.HttpUtil;
|
||||
import org.openhab.core.library.types.DateTimeType;
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.types.StringType;
|
||||
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||
import org.openhab.core.thing.ChannelUID;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingStatus;
|
||||
import org.openhab.core.thing.ThingStatusDetail;
|
||||
import org.openhab.core.thing.binding.BaseThingHandler;
|
||||
import org.openhab.core.types.Command;
|
||||
import org.openhab.core.types.RefreshType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
/**
|
||||
* The {@link WindcentraleHandler} is responsible for handling commands, which are
|
||||
* sent to one of the channels.
|
||||
*
|
||||
* @author Marcel Verpaalen - Initial contribution
|
||||
* @author Wouter Born - Add null annotations
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class WindcentraleHandler extends BaseThingHandler {
|
||||
|
||||
private static final String HOURS_RUN_THIS_YEAR = "hoursRunThisYear";
|
||||
private static final String URL_FORMAT = "https://zep-api.windcentrale.nl/production/%d/live?ignoreLoadingBar=true";
|
||||
private static final long CACHE_EXPIRY = TimeUnit.SECONDS.toMillis(5);
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(WindcentraleHandler.class);
|
||||
private final JsonParser parser = new JsonParser();
|
||||
|
||||
private @Nullable MillConfig millConfig;
|
||||
private @Nullable String millUrl;
|
||||
private @Nullable ScheduledFuture<?> pollingJob;
|
||||
|
||||
private final ExpiringCache<@Nullable String> windcentraleCache = new ExpiringCache<>(CACHE_EXPIRY, () -> {
|
||||
try {
|
||||
return millUrl != null ? HttpUtil.executeUrl("GET", millUrl, 5000) : null;
|
||||
} catch (IOException e) {
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
public WindcentraleHandler(Thing thing) {
|
||||
super(thing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||
if (command == RefreshType.REFRESH) {
|
||||
logger.debug("Refreshing {}", channelUID);
|
||||
updateData();
|
||||
} else {
|
||||
logger.debug("This binding is a read-only binding and cannot handle commands");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
logger.debug("Initializing Windcentrale handler '{}'", getThing().getUID());
|
||||
|
||||
final MillConfig config = getConfig().as(MillConfig.class);
|
||||
|
||||
millConfig = config;
|
||||
millUrl = String.format(URL_FORMAT, config.millId);
|
||||
pollingJob = scheduler.scheduleWithFixedDelay(this::updateData, 0, config.refreshInterval, TimeUnit.SECONDS);
|
||||
|
||||
logger.debug("Polling job scheduled to run every {} sec. for '{}'", config.refreshInterval,
|
||||
getThing().getUID());
|
||||
|
||||
updateProperty(Thing.PROPERTY_VENDOR, "Windcentrale");
|
||||
updateProperty(Thing.PROPERTY_MODEL_ID, "Windmolen");
|
||||
updateProperty(Thing.PROPERTY_SERIAL_NUMBER, Integer.toString(config.millId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
logger.debug("Disposing Windcentrale handler '{}'", getThing().getUID());
|
||||
if (pollingJob != null) {
|
||||
pollingJob.cancel(true);
|
||||
pollingJob = null;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void updateData() {
|
||||
try {
|
||||
logger.debug("Update windmill data '{}'", getThing().getUID());
|
||||
|
||||
final MillConfig config = millConfig;
|
||||
final String rawMillData = windcentraleCache.getValue();
|
||||
|
||||
if (config == null || rawMillData == null) {
|
||||
return;
|
||||
}
|
||||
logger.trace("Retrieved updated mill data: {}", rawMillData);
|
||||
final JsonElement jsonElement = parser.parse(rawMillData);
|
||||
|
||||
if (!(jsonElement instanceof JsonObject)) {
|
||||
throw new JsonParseException("Could not parse windmill json data");
|
||||
}
|
||||
final JsonObject millData = (JsonObject) jsonElement;
|
||||
|
||||
updateState(CHANNEL_WIND_SPEED, new DecimalType(millData.get(CHANNEL_WIND_SPEED).getAsString()));
|
||||
updateState(CHANNEL_WIND_DIRECTION, new StringType(millData.get(CHANNEL_WIND_DIRECTION).getAsString()));
|
||||
updateState(CHANNEL_POWER_TOTAL,
|
||||
new QuantityType<>(millData.get(CHANNEL_POWER_TOTAL).getAsBigDecimal(), KILO(SmartHomeUnits.WATT)));
|
||||
updateState(CHANNEL_POWER_PER_WD,
|
||||
new QuantityType<>(
|
||||
millData.get(CHANNEL_POWER_PER_WD).getAsBigDecimal().multiply(new BigDecimal(config.wd)),
|
||||
SmartHomeUnits.WATT));
|
||||
updateState(CHANNEL_POWER_RELATIVE,
|
||||
new QuantityType<>(millData.get(CHANNEL_POWER_RELATIVE).getAsBigDecimal(), SmartHomeUnits.PERCENT));
|
||||
updateState(CHANNEL_ENERGY,
|
||||
new QuantityType<>(millData.get(CHANNEL_ENERGY).getAsBigDecimal(), SmartHomeUnits.KILOWATT_HOUR));
|
||||
updateState(CHANNEL_ENERGY_FC, new QuantityType<>(millData.get(CHANNEL_ENERGY_FC).getAsBigDecimal(),
|
||||
SmartHomeUnits.KILOWATT_HOUR));
|
||||
updateState(CHANNEL_RUNTIME,
|
||||
new QuantityType<>(millData.get(HOURS_RUN_THIS_YEAR).getAsBigDecimal(), SmartHomeUnits.HOUR));
|
||||
updateState(CHANNEL_RUNTIME_PER,
|
||||
new QuantityType<>(millData.get(CHANNEL_RUNTIME_PER).getAsBigDecimal(), SmartHomeUnits.PERCENT));
|
||||
updateState(CHANNEL_LAST_UPDATE, new DateTimeType(millData.get(CHANNEL_LAST_UPDATE).getAsString()));
|
||||
|
||||
if (!getThing().getStatus().equals(ThingStatus.ONLINE)) {
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
}
|
||||
} catch (final RuntimeException e) {
|
||||
logger.debug("Failed to process windmill data", e);
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR,
|
||||
"Failed to process mill data");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<binding:binding id="windcentrale" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:binding="https://openhab.org/schemas/binding/v1.0.0"
|
||||
xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd">
|
||||
|
||||
<name>Windcentrale Binding</name>
|
||||
<description>Binding for Windcentrale windmills</description>
|
||||
<author>Marcel Verpaalen</author>
|
||||
|
||||
</binding:binding>
|
||||
@@ -0,0 +1,25 @@
|
||||
# binding
|
||||
binding.windcentrale.name = Windcentrale Binding
|
||||
binding.windcentrale.description = Binding voor Windcentrale windmolens
|
||||
|
||||
# thing types
|
||||
thing-type.windcentrale.mill.label = Windcentrale windmolen
|
||||
thing-type.config.windcentrale.mill.millId.label = Windmolen
|
||||
thing-type.config.windcentrale.mill.wd.label = Aantal Winddelen
|
||||
thing-type.config.windcentrale.mill.wd.description = Aantal Winddelen in bezit
|
||||
thing-type.config.windcentrale.mill.refreshInterval.label = Ververs interval
|
||||
thing-type.config.windcentrale.mill.refreshInterval.description = Ververs interval in seconden
|
||||
|
||||
# channels
|
||||
channel.windcentrale.windSpeed.label = Windsnelheid (Bft)
|
||||
channel.windcentrale.windDirection.label = Windrichting
|
||||
channel.windcentrale.powerAbsTot.label = Productie vermogen molen
|
||||
channel.windcentrale.powerAbsWd.label = Vermogen van de Winddelen
|
||||
channel.windcentrale.powerRel.label = Relatief vermogen
|
||||
channel.windcentrale.kwh.label = Productie
|
||||
channel.windcentrale.kwhForecast.label = Verwachte productie
|
||||
channel.windcentrale.runPercentage.label = Molen productie percentage
|
||||
channel.windcentrale.runPercentage.description = Molen productie percentage dit jaar
|
||||
channel.windcentrale.runTime.label = Molen productietijd
|
||||
channel.windcentrale.runTime.description = Molen productietijd dit jaar
|
||||
channel.windcentrale.timestamp.label = Ververs tijdstip
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<thing:thing-descriptions bindingId="windcentrale"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
|
||||
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
|
||||
|
||||
<thing-type id="mill">
|
||||
<label>Windcentrale Windmill</label>
|
||||
|
||||
<channels>
|
||||
<channel id="windSpeed" typeId="windSpeed"/>
|
||||
<channel id="windDirection" typeId="windDirection"/>
|
||||
<channel id="powerAbsTot" typeId="powerAbsTot"/>
|
||||
<channel id="powerAbsWd" typeId="powerAbsWd"/>
|
||||
<channel id="powerRel" typeId="powerRel"/>
|
||||
<channel id="kwh" typeId="kwh"/>
|
||||
<channel id="kwhForecast" typeId="kwhForecast"/>
|
||||
<channel id="runPercentage" typeId="runPercentage"/>
|
||||
<channel id="runTime" typeId="runTime"/>
|
||||
<channel id="timestamp" typeId="timestamp"/>
|
||||
</channels>
|
||||
|
||||
<properties>
|
||||
<property name="vendor">Windcentrale</property>
|
||||
</properties>
|
||||
|
||||
<config-description>
|
||||
<parameter name="millId" type="integer" required="true">
|
||||
<label>Windmill</label>
|
||||
<options>
|
||||
<option value="1">De Grote Geert</option>
|
||||
<option value="2">De Jonge Held</option>
|
||||
<option value="31">Het Rode Hert</option>
|
||||
<option value="41">De Ranke Zwaan</option>
|
||||
<option value="51">De Witte Juffer</option>
|
||||
<option value="111">De Bonte Hen</option>
|
||||
<option value="121">De Trouwe Wachter</option>
|
||||
<option value="131">De Blauwe Reiger</option>
|
||||
<option value="141">De Vier Winden</option>
|
||||
<option value="201">De Boerenzwaluw</option>
|
||||
</options>
|
||||
<default>131</default>
|
||||
</parameter>
|
||||
<parameter name="wd" type="integer" required="false">
|
||||
<label>Wind Shares</label>
|
||||
<description>Number of wind shares ("Winddelen")</description>
|
||||
<default>1</default>
|
||||
</parameter>
|
||||
<parameter name="refreshInterval" type="integer" min="1" max="9999" required="false">
|
||||
<label>Refresh Interval</label>
|
||||
<description>Refresh interval for refreshing the data in seconds</description>
|
||||
<default>30</default>
|
||||
<advanced>true</advanced>
|
||||
</parameter>
|
||||
</config-description>
|
||||
</thing-type>
|
||||
|
||||
<channel-type id="windSpeed">
|
||||
<item-type>Number</item-type>
|
||||
<label>Wind Speed</label>
|
||||
<category>Wind</category>
|
||||
<state pattern="%d Bft" readOnly="true"/>
|
||||
</channel-type>
|
||||
<channel-type id="windDirection">
|
||||
<item-type>String</item-type>
|
||||
<label>Wind Direction</label>
|
||||
<state pattern="%s" readOnly="true"/>
|
||||
</channel-type>
|
||||
<channel-type id="powerRel">
|
||||
<item-type>Number:Dimensionless</item-type>
|
||||
<label>Relative Power</label>
|
||||
<category>Energy</category>
|
||||
<state pattern="%.1f %unit%" readOnly="true"/>
|
||||
</channel-type>
|
||||
<channel-type id="runPercentage">
|
||||
<item-type>Number:Dimensionless</item-type>
|
||||
<label>Run Percentage</label>
|
||||
<description>Run percentage this year</description>
|
||||
<category>Energy</category>
|
||||
<state pattern="%.1f %unit%" readOnly="true"/>
|
||||
</channel-type>
|
||||
<channel-type id="runTime">
|
||||
<item-type>Number:Time</item-type>
|
||||
<label>Run Time</label>
|
||||
<description>Run time this year</description>
|
||||
<state pattern="%.0f %unit%" readOnly="true"/>
|
||||
</channel-type>
|
||||
<channel-type id="powerAbsWd">
|
||||
<item-type>Number:Power</item-type>
|
||||
<label>Wind Shares Power</label>
|
||||
<category>Energy</category>
|
||||
<state pattern="%.1f %unit%" readOnly="true"/>
|
||||
</channel-type>
|
||||
<channel-type id="powerAbsTot">
|
||||
<item-type>Number:Power</item-type>
|
||||
<label>Total Power</label>
|
||||
<category>Energy</category>
|
||||
<state pattern="%.1f %unit%" readOnly="true"/>
|
||||
</channel-type>
|
||||
<channel-type id="kwh">
|
||||
<item-type>Number:Energy</item-type>
|
||||
<label>Energy</label>
|
||||
<category>Energy</category>
|
||||
<state pattern="%.0f %unit%" readOnly="true"/>
|
||||
</channel-type>
|
||||
<channel-type id="kwhForecast">
|
||||
<item-type>Number:Energy</item-type>
|
||||
<label>Energy Forecast</label>
|
||||
<category>Energy</category>
|
||||
<state pattern="%.0f %unit%" readOnly="true"/>
|
||||
</channel-type>
|
||||
<channel-type id="timestamp">
|
||||
<item-type>DateTime</item-type>
|
||||
<label>Last Updated</label>
|
||||
<state readOnly="true"/>
|
||||
</channel-type>
|
||||
</thing:thing-descriptions>
|
||||
Reference in New Issue
Block a user