Skip to content

Commit

Permalink
[draytonwiser] Drayton Wiser Binding initial contribution (#3168)
Browse files Browse the repository at this point in the history
Also-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
Signed-off-by: Andrew Schofield <the.uncle.fungus@gmail.com>
  • Loading branch information
andrew-schofield authored Aug 9, 2020
1 parent 5a493ee commit 6e32b2f
Show file tree
Hide file tree
Showing 50 changed files with 7,174 additions and 0 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
/bundles/org.openhab.binding.dlinksmarthome/ @MikeJMajor
/bundles/org.openhab.binding.dmx/ @J-N-K
/bundles/org.openhab.binding.doorbird/ @mhilbush
/bundles/org.openhab.binding.draytonwiser/ @andrew-schofield
/bundles/org.openhab.binding.dscalarm/ @RSStephens
/bundles/org.openhab.binding.dsmr/ @Hilbrand
/bundles/org.openhab.binding.ecobee/ @mhilbush
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 @@ -219,6 +219,11 @@
<artifactId>org.openhab.binding.doorbird</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.draytonwiser</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.dscalarm</artifactId>
Expand Down
33 changes: 33 additions & 0 deletions bundles/org.openhab.binding.draytonwiser/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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="src" path="src/test/resources/org/openhab/binding/draytonwiser"/>
<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.draytonwiser/.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.draytonwiser</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.draytonwiser/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
248 changes: 248 additions & 0 deletions bundles/org.openhab.binding.draytonwiser/README.md

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.draytonwiser/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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.8-SNAPSHOT</version>
</parent>

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

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

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.library.types.DecimalType;
import org.eclipse.smarthome.core.thing.ThingTypeUID;
import org.eclipse.smarthome.core.types.State;
import org.eclipse.smarthome.core.types.UnDefType;

/**
* The {@link DraytonWiserBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Andrew Schofield - Initial contribution
*/
@NonNullByDefault
public class DraytonWiserBindingConstants {

public static final String BINDING_ID = "draytonwiser";

public static final String REFRESH_INTERVAL = "refresh";
public static final int DEFAULT_REFRESH_SECONDS = 60;

public static final int OFFLINE_TEMPERATURE = -32768;

// Web Service Endpoints
public static final String DEVICE_ENDPOINT = "data/domain/Device/";
public static final String ROOMSTATS_ENDPOINT = "data/domain/RoomStat/";
public static final String TRVS_ENDPOINT = "data/domain/SmartValve/";
public static final String ROOMS_ENDPOINT = "data/domain/Room/";
public static final String HEATCHANNELS_ENDPOINT = "data/domain/HeatingChannel/";
public static final String SYSTEM_ENDPOINT = "data/domain/System/";
public static final String STATION_ENDPOINT = "data/network/Station/";
public static final String DOMAIN_ENDPOINT = "data/domain/";
public static final String HOTWATER_ENDPOINT = "data/domain/HotWater/";
public static final String SMARTPLUG_ENDPOINT = "data/domain/SmartPlug/";

// bridge
public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "heathub");

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_CONTROLLER = new ThingTypeUID(BINDING_ID, "boiler-controller");
public static final ThingTypeUID THING_TYPE_ROOM = new ThingTypeUID(BINDING_ID, "room");
public static final ThingTypeUID THING_TYPE_ROOMSTAT = new ThingTypeUID(BINDING_ID, "roomstat");
public static final ThingTypeUID THING_TYPE_ITRV = new ThingTypeUID(BINDING_ID, "itrv");
public static final ThingTypeUID THING_TYPE_HOTWATER = new ThingTypeUID(BINDING_ID, "hotwater");
public static final ThingTypeUID THING_TYPE_SMARTPLUG = new ThingTypeUID(BINDING_ID, "smart-plug");

// properties
public static final String PROP_ADDRESS = "networkAddress";
public static final String PROP_SERIAL_NUMBER = "serialNumber";
public static final String PROP_NAME = "name";
public static final String PROP_ID = "id";

// List of all Channel ids
public static final String CHANNEL_CURRENT_TEMPERATURE = "currentTemperature";
public static final String CHANNEL_CURRENT_HUMIDITY = "currentHumidity";
public static final String CHANNEL_CURRENT_SETPOINT = "currentSetPoint";
public static final String CHANNEL_CURRENT_BATTERY_VOLTAGE = "currentBatteryVoltage";
public static final String CHANNEL_CURRENT_BATTERY_LEVEL = "currentBatteryLevel";
public static final String CHANNEL_CURRENT_WISER_BATTERY_LEVEL = "currentWiserBatteryLevel";
public static final String CHANNEL_CURRENT_DEMAND = "currentDemand";
public static final String CHANNEL_HEAT_REQUEST = "heatRequest";
public static final String CHANNEL_CURRENT_SIGNAL_RSSI = "currentSignalRSSI";
public static final String CHANNEL_CURRENT_SIGNAL_LQI = "currentSignalLQI";
public static final String CHANNEL_CURRENT_SIGNAL_STRENGTH = "currentSignalStrength";
public static final String CHANNEL_CURRENT_WISER_SIGNAL_STRENGTH = "currentWiserSignalStrength";
public static final String CHANNEL_HEATING_OVERRIDE = "heatingOverride";
public static final String CHANNEL_HOT_WATER_OVERRIDE = "hotWaterOverride";
public static final String CHANNEL_HEATCHANNEL_1_DEMAND = "heatChannel1Demand";
public static final String CHANNEL_HEATCHANNEL_2_DEMAND = "heatChannel2Demand";
public static final String CHANNEL_HEATCHANNEL_1_DEMAND_STATE = "heatChannel1DemandState";
public static final String CHANNEL_HEATCHANNEL_2_DEMAND_STATE = "heatChannel2DemandState";
public static final String CHANNEL_HOTWATER_DEMAND_STATE = "hotWaterDemandState";
public static final String CHANNEL_AWAY_MODE_STATE = "awayModeState";
public static final String CHANNEL_ECO_MODE_STATE = "ecoModeState";
public static final String CHANNEL_MANUAL_MODE_STATE = "manualModeState";
public static final String CHANNEL_ZIGBEE_CONNECTED = "zigbeeConnected";
public static final String CHANNEL_HOT_WATER_SETPOINT = "hotWaterSetPoint";
public static final String CHANNEL_HOT_WATER_BOOST_DURATION = "hotWaterBoostDuration";
public static final String CHANNEL_HOT_WATER_BOOSTED = "hotWaterBoosted";
public static final String CHANNEL_HOT_WATER_BOOST_REMAINING = "hotWaterBoostRemaining";
public static final String CHANNEL_ROOM_BOOST_DURATION = "roomBoostDuration";
public static final String CHANNEL_ROOM_BOOSTED = "roomBoosted";
public static final String CHANNEL_ROOM_BOOST_REMAINING = "roomBoostRemaining";
public static final String CHANNEL_ROOM_WINDOW_STATE_DETECTION = "windowStateDetection";
public static final String CHANNEL_ROOM_WINDOW_STATE = "windowState";
public static final String CHANNEL_DEVICE_LOCKED = "deviceLocked";
public static final String CHANNEL_SMARTPLUG_OUTPUT_STATE = "plugOutputState";
public static final String CHANNEL_SMARTPLUG_AWAY_ACTION = "plugAwayAction";

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(THING_TYPE_CONTROLLER, THING_TYPE_ROOM, THING_TYPE_ROOMSTAT,
THING_TYPE_BRIDGE, THING_TYPE_ITRV, THING_TYPE_HOTWATER, THING_TYPE_SMARTPLUG)));

// Lookups from text representations to useful values

public enum SignalStrength {
VERYGOOD(4),
GOOD(3),
MEDIUM(2),
POOR(1),
NOSIGNAL(0);

private final int signalStrength;

SignalStrength(final int signalStrength) {
this.signalStrength = signalStrength;
}

public static State toSignalStrength(final String strength) {
try {
return new DecimalType(SignalStrength.valueOf(strength.toUpperCase()).signalStrength);
} catch (final IllegalArgumentException e) {
// Catch unrecognized values.
return UnDefType.UNDEF;
}
}
}

public enum BatteryLevel {
FULL(100),
NORMAL(80),
TWOTHIRDS(60),
ONETHIRD(40),
LOW(20),
CRITICAL(0);

private final int batteryLevel;

private BatteryLevel(final int batteryLevel) {
this.batteryLevel = batteryLevel;
}

public static State toBatteryLevel(final String level) {
try {
return new DecimalType(BatteryLevel.valueOf(level.toUpperCase()).batteryLevel);
} catch (final IllegalArgumentException e) {
// Catch unrecognized values.
return UnDefType.UNDEF;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* 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.draytonwiser.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.smarthome.core.thing.Bridge;
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.eclipse.smarthome.io.net.http.HttpClientFactory;
import org.openhab.binding.draytonwiser.internal.handler.ControllerHandler;
import org.openhab.binding.draytonwiser.internal.handler.HeatHubHandler;
import org.openhab.binding.draytonwiser.internal.handler.HotWaterHandler;
import org.openhab.binding.draytonwiser.internal.handler.RoomHandler;
import org.openhab.binding.draytonwiser.internal.handler.RoomStatHandler;
import org.openhab.binding.draytonwiser.internal.handler.SmartPlugHandler;
import org.openhab.binding.draytonwiser.internal.handler.TRVHandler;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* The {@link DraytonWiserHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Andrew Schofield - Initial contribution
*/
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.draytonwiser")
@NonNullByDefault
public class DraytonWiserHandlerFactory extends BaseThingHandlerFactory {

private final HttpClient httpClient;

@Activate
public DraytonWiserHandlerFactory(@Reference final HttpClientFactory factory) {
httpClient = factory.getCommonHttpClient();
}

@Override
public boolean supportsThingType(final ThingTypeUID thingTypeUID) {
return DraytonWiserBindingConstants.SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}

@Override
protected @Nullable ThingHandler createHandler(final Thing thing) {
final ThingTypeUID thingTypeUID = thing.getThingTypeUID();

if (DraytonWiserBindingConstants.THING_TYPE_BRIDGE.equals(thingTypeUID)) {
return new HeatHubHandler((Bridge) thing, httpClient);
} else if (DraytonWiserBindingConstants.THING_TYPE_ROOM.equals(thingTypeUID)) {
return new RoomHandler(thing);
} else if (DraytonWiserBindingConstants.THING_TYPE_ROOMSTAT.equals(thingTypeUID)) {
return new RoomStatHandler(thing);
} else if (DraytonWiserBindingConstants.THING_TYPE_ITRV.equals(thingTypeUID)) {
return new TRVHandler(thing);
} else if (DraytonWiserBindingConstants.THING_TYPE_CONTROLLER.equals(thingTypeUID)) {
return new ControllerHandler(thing);
} else if (DraytonWiserBindingConstants.THING_TYPE_HOTWATER.equals(thingTypeUID)) {
return new HotWaterHandler(thing);
} else if (DraytonWiserBindingConstants.THING_TYPE_SMARTPLUG.equals(thingTypeUID)) {
return new SmartPlugHandler(thing);
}

return null;
}
}
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.draytonwiser.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.draytonwiser.internal.model.DraytonWiserDTO;

/**
* Listener for item/sensor updates.
*
* @author Andrew Schofield - Initial contribution
*/
@NonNullByDefault
public interface DraytonWiserRefreshListener {

void onRefresh(DraytonWiserDTO domain);
}
Loading

0 comments on commit 6e32b2f

Please sign in to comment.