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

[draytonwiser] Drayton Wiser Binding initial contribution #3168

Merged
merged 122 commits into from
Aug 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
586f113
[draytonwiser] Initial skeleton of drayton wiser binding
andrew-schofield Jan 2, 2018
59962c5
[draytonwiser] Fix build.properties file
andrew-schofield Jan 3, 2018
fc47e5e
[draytonwiser] Add metatdata for binding and things
andrew-schofield Jan 3, 2018
7029832
[draytonwiser] Fix license headers
andrew-schofield Jan 3, 2018
11de02b
[draytonwiser] Add some default handlers
andrew-schofield Jan 4, 2018
42f8335
[draytonwiser] Fix supported thing types so that the bridge can be in…
andrew-schofield Jan 4, 2018
aa1b49c
[draytonwiser] Add basic online checker for the heathub
andrew-schofield Jan 4, 2018
e1b1fe8
[draytonwiser] Add skeleton discoveryservice
andrew-schofield Jan 4, 2018
ff92ff9
[draytonwiser] Register discovery service
andrew-schofield Jan 5, 2018
006a769
[draytonwiser] Get extended properties when adding the heathub
andrew-schofield Jan 5, 2018
57b7854
[draytonwiser] Implement autodiscovery for room stats
andrew-schofield Jan 5, 2018
4986d0e
[draytonwiser] Implement autodiscovery for iTRVs/Smart Valves
andrew-schofield Jan 5, 2018
a6afcaa
[draytonwiser] Implement autodiscovery for rooms
andrew-schofield Jan 5, 2018
f7ac35f
[draytonwiser] Implement autodiscovery of the heat hub. Still require…
andrew-schofield Jan 5, 2018
7ff95d5
[draytonwiser] Retrieve room temperature and setpoint via a scheduled…
andrew-schofield Jan 7, 2018
c803fd6
[draytonwiser] Pull room humidity if there is an attached roomstat de…
andrew-schofield Jan 7, 2018
d1bce91
[draytonwiser] Minor fixes
andrew-schofield Jan 7, 2018
e10f530
[draytonwiser] Add current demand and request for heat channels to rooms
andrew-schofield Jan 7, 2018
dbde822
[draytonwiser] Minor fix to heating demand state channel
andrew-schofield Jan 8, 2018
418c00e
[draytonwiser] Add support for reading properties from room stats and…
andrew-schofield Jan 8, 2018
8cea121
[draytonwiser] Add RSSI and fix negative setpoint
andrew-schofield Jan 8, 2018
6aed259
[draytonwiser] Add battery voltage
andrew-schofield Jan 8, 2018
b4a1221
[draytonwiser] Add signal strength and battery level string channels
andrew-schofield Jan 9, 2018
f6e4076
[draytonwiser] Add support for reading controller properties and crea…
andrew-schofield Jan 9, 2018
24ef95e
[draytonwiser] Add licenses on all new files
andrew-schofield Jan 9, 2018
6041738
[draytonwiser] Fix checkstyle errors preventing maven build from running
andrew-schofield Jan 9, 2018
7105a0b
[draytonwiser] Add initial readme file
andrew-schofield Jan 10, 2018
028a6fd
[draytonwiser] Remove a number of unnecessary setters
andrew-schofield Jan 10, 2018
6dd6ed6
[draytonwiser] Refactor common methods into base class
andrew-schofield Jan 10, 2018
b2105c1
[draytonwiser] Add some known string responses for specific channels
andrew-schofield Jan 10, 2018
0a0ade5
[draytonwiser] Prepare improved data querying
andrew-schofield Jan 11, 2018
ba86419
[draytonwiser] Report away mode state
andrew-schofield Jan 11, 2018
d4c87cb
[draytonwiser] Add ecomode channel
andrew-schofield Jan 12, 2018
eafaefc
[draytonwiser] Refactor to reduce number of http calls to controller
andrew-schofield Jan 12, 2018
483c746
[draytonwiser] Alter the default refresh interval for updates
andrew-schofield Jan 12, 2018
e766906
[draytonwiser] Enable changing room setpoint
andrew-schofield Jan 12, 2018
0b5d957
[draytonwiser] Partial support for enabling room manual mode
andrew-schofield Jan 12, 2018
cff9b25
[draytonwiser] Correctly refresh domain data
andrew-schofield Jan 13, 2018
e5c61be
[draytonwiser] Documentation update to detail supported channels
andrew-schofield Jan 13, 2018
a711039
[draytonwiser] Support setting away mode
andrew-schofield Jan 13, 2018
7e8647e
[draytonwiser] Support setting eco mode
andrew-schofield Jan 13, 2018
397d8b4
[draytonwiser] Update readme with .things file example
andrew-schofield Jan 24, 2018
1db1cbb
[draytonwiser] Added binding to feature list
andrew-schofield Jan 24, 2018
d7676b0
[draytonwiser] Alter identifier being used to address each device to …
andrew-schofield Jan 27, 2018
aee1fab
[draytonwiser] Correctly update domain data when pushing an update
andrew-schofield Jan 31, 2018
053df46
[draytonwiser] Add support for hot water heating state item
andrew-schofield Jan 31, 2018
8fd17c0
[draytonwiser] Add guard around null responses, and return immediatel…
andrew-schofield Feb 1, 2018
e6a16ef
[draytonwiser] Better names for autodiscovered thermostats and TRVs
andrew-schofield Feb 1, 2018
68ed65b
[draytonwiser] Updated README with new response values for signal and…
andrew-schofield Feb 3, 2018
9f031ee
[draytonwiser] Add LQI channel to zigbee devices
andrew-schofield Feb 3, 2018
e9786c0
[draytonwiser] Print causative stacktrace for ExecutionException when…
andrew-schofield Feb 4, 2018
c84983b
[draytonwiser] Update thing status to OFFLINE if something goes wrong…
andrew-schofield Feb 4, 2018
fbec178
[draytonwiser] Move some items into a new HotWater thing
andrew-schofield Feb 4, 2018
e07bbaf
[draytonwiser] Updated documentation with hot water thing
andrew-schofield Feb 4, 2018
16ce8a3
[draytonwiser] Add manual mode state for hot water
andrew-schofield Feb 4, 2018
0b7c2c7
[draytonwiser] Reverted OFFLINE status change as it broke things
andrew-schofield Feb 4, 2018
95ec42e
[draytonwiser] Don't keep things offline if the next update succeeds
andrew-schofield Feb 5, 2018
2e336d8
[draytonwiser] Return undefined value rather than large negative numb…
andrew-schofield Feb 6, 2018
d425df4
[draytonwiser] Make auto-refresh methods synchronized
andrew-schofield Feb 6, 2018
df469af
[draytonwiser] Add channels that could be implemented to README
andrew-schofield Feb 6, 2018
317b4d2
[draytonwiser] Add zigbee connected state item to devices
andrew-schofield Feb 6, 2018
de3edc8
[draytonwiser] Limit jetty connection count to try and prevent EOFExc…
andrew-schofield Feb 8, 2018
7d59e4f
[draytonwiser] Fix discovery of TRVs when rooms with no TRVs exist
andrew-schofield Mar 14, 2018
673818e
[draytonwiser] Refactor from using scheduled jobs to update listeners
andrew-schofield Mar 15, 2018
d731a6a
[draytonwiser] Add away mode setpoint to heat hub configuration
andrew-schofield Mar 22, 2018
390fd52
[draytonwiser] Add hot water set point
andrew-schofield Mar 22, 2018
88d775a
[draytonwiser] Remove unnecessary method comments
andrew-schofield Apr 3, 2018
34d5be0
[draytonwiser] Add boosting to rooms and hot water
andrew-schofield Apr 4, 2018
866e608
[draytonwiser] Update documentation
andrew-schofield Apr 5, 2018
63a7da0
[draytonwiser] Alter room boost channel behaviour so that the boost d…
andrew-schofield Apr 5, 2018
895b760
[draytonwiser] Add unified battery level and signal strength so that …
andrew-schofield Apr 17, 2018
3881058
[draytonwiser] Add support for open window detection
andrew-schofield Apr 21, 2018
72ce7a5
[draytonwiser] Add ability to retrieve and update heating schedules
andrew-schofield Apr 22, 2018
c67c7cd
[draytonwiser] Minor refactor
andrew-schofield Apr 23, 2018
d971141
[draytonwiser] Set lesser used channels as advanced
andrew-schofield Apr 23, 2018
6619ddf
[draytonwiser] Cleanup documentation
andrew-schofield Apr 23, 2018
cfbd604
[draytonwiser] Add extra debug logging
andrew-schofield Jun 9, 2018
7255dbc
[draytonwiser] Update version to 2.4.0
andrew-schofield Jun 13, 2018
4019053
[draytonwiser] Fix potential null reference exceptions being thrown
andrew-schofield Jun 13, 2018
0c7eaa3
[draytonwiser] Fix timout bug in heathub requests which resulted in t…
andrew-schofield Jun 13, 2018
6520d69
[draytonwiser] Add RSSI and LQI back to devices after the firmware ch…
andrew-schofield Jun 14, 2018
e4f2702
[draytonwiser] Add support for device locking
andrew-schofield Jun 14, 2018
cb52ce9
[draytonwiser] Add initial support for wiser smart plugs
andrew-schofield Jul 21, 2018
8a84877
[draytonwiser] Updated OSGI-INF folder as per PR
andrew-schofield Jul 21, 2018
1740417
[draytonwiser] Change case of parameters and rename
andrew-schofield Jul 24, 2018
117d9a4
[draytonwiser] Tidy up channel names and types
andrew-schofield Jul 29, 2018
4caeb70
[draytonwiser] Add UoM to temperature measurements
andrew-schofield Aug 12, 2018
95304ec
[draytonwiser] Add UoM for more channels
andrew-schofield Aug 12, 2018
5cad1db
[draytonwiser] Updated openhab2 version to 2.5.0
andrew-schofield Jan 3, 2019
4aaa5cc
[draytonwiser] Update README to include better example .items and .th…
andrew-schofield Jan 3, 2019
9d6b9ed
[draytonwiser] Fix UoM parsing for room setpoint temperature
andrew-schofield Jan 3, 2019
a01cb77
[draytonwiser] Fix issue where properties which could take large valu…
andrew-schofield Feb 8, 2019
5d48d03
[draytonwiser] Move Humidity channel to use UoM
andrew-schofield Feb 10, 2019
c65690a
[draytonwiser] Fix copyright header for openHAB 2.5.0
andrew-schofield Feb 11, 2019
31ef317
[draytonwiser] Add imports that are now required for 2.5.0
andrew-schofield Feb 11, 2019
0b3f109
[draytonwiser] Additional checks in discovery that prevent null refer…
andrew-schofield Feb 14, 2019
15e7c86
[draytonwiser] Fixed NOTICE to be compatible with openHAB 2.5.0
andrew-schofield Feb 15, 2019
72803a2
[draytonwiser] Improve mis-handling of failure states on heat hub res…
andrew-schofield Feb 17, 2019
2d06b27
[draytonwiser] Fix build file to include notice file
andrew-schofield Feb 17, 2019
d9b6afa
[draytonwiser] Initial contribution
Hilbrand Jan 13, 2020
23bfff2
[draytonwiser] Remove unnecessary files after the merge
andrew-schofield Jun 21, 2020
14fcbdc
[draytonwiser] Updated POM with most recent openHAB snapshot version
andrew-schofield Jun 22, 2020
34fd3a8
[draytonwiser] JSON schedule channel as per PR review request
andrew-schofield Jun 27, 2020
1e4499a
[draytonwiser] Apply spotless changes
andrew-schofield Jun 29, 2020
463611a
[draytonwiser] Add type check to smartplug command handler
andrew-schofield Jun 29, 2020
56b7418
[draytonwiser] Fix use of thinguid in updateState
andrew-schofield Jun 29, 2020
c60b00d
[draytonwiser] Remove "Channel 1" from heat demand channel label
andrew-schofield Jun 29, 2020
435d10a
[draytonwiser] Code cleanup (local variables etc)
andrew-schofield Jun 30, 2020
f8e278c
[draytonwiser] Clean up exception handling
andrew-schofield Jun 30, 2020
4ea7361
Addressed some of the last comments (#1)
Hilbrand Jul 6, 2020
1b857fc
More review comments addressed (#2)
Hilbrand Jul 8, 2020
d47ebea
Changed boost remaining to QuantityType (#3)
Hilbrand Jul 13, 2020
825f29c
[draytonwiser] Update boost remaining unit in thing definition and
andrew-schofield Jul 13, 2020
72271c1
[draytonwiser] Fix bug where all items were discoverd as smart plugs
andrew-schofield Jul 14, 2020
db9b424
[draytonwiser] Updated hot water and room boost to return time in min…
andrew-schofield Jul 14, 2020
efbd3f6
[draytonwiser] Fix error in readme where boost duration was given wro…
andrew-schofield Jul 14, 2020
565fbd7
[draytonwiser] Remove possibility of returning a null state for boost…
andrew-schofield Jul 14, 2020
0faa1a8
Changed back to just use seconds in code. It's just cleaner code (#4)
Hilbrand Jul 28, 2020
9a6a1e1
[draytonwiser] Fix item type of window state
andrew-schofield Jul 29, 2020
4da5349
[draytonwiser] Remove redundant imports
andrew-schofield Jul 29, 2020
8dc59bd
[draytonwiser] Fix spotless warnings
andrew-schofield Jul 29, 2020
af8d624
[draytonwiser] fix represenation property (#5)
Hilbrand Aug 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
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