From 219d37043975600fa574c15011aba2cbbce5b88f Mon Sep 17 00:00:00 2001 From: Ondrej Pecta Date: Fri, 27 Nov 2020 08:29:37 +0100 Subject: [PATCH] [somfytahoma] Added support for the thermostatic valve (#9122) Signed-off-by: Ondrej Pecta --- .../org.openhab.binding.somfytahoma/README.md | 119 +++++++++--------- .../internal/SomfyTahomaBindingConstants.java | 22 +++- .../internal/SomfyTahomaException.java | 39 ------ .../internal/SomfyTahomaHandlerFactory.java | 6 +- .../SomfyTahomaItemDiscoveryService.java | 10 +- .../handler/SomfyTahomaBaseThingHandler.java | 4 +- .../handler/SomfyTahomaBridgeHandler.java | 11 +- .../handler/SomfyTahomaGateHandler.java | 3 + .../handler/SomfyTahomaPodHandler.java | 24 ++++ .../handler/SomfyTahomaThermostatHandler.java | 1 + .../SomfyTahomaValveHeatingSystemHandler.java | 72 +++++++++++ ...SomfyTahomaZwaveHeatingSystemHandler.java} | 10 +- .../main/resources/OH-INF/thing/channels.xml | 41 +++++- .../src/main/resources/OH-INF/thing/gate.xml | 1 + .../resources/OH-INF/thing/heatingsystem.xml | 2 +- .../resources/OH-INF/thing/thermostat.xml | 3 +- .../OH-INF/thing/valveheatingsystem.xml | 24 ++++ 17 files changed, 273 insertions(+), 119 deletions(-) delete mode 100644 bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaException.java create mode 100644 bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaValveHeatingSystemHandler.java rename bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/{SomfyTahomaHeatingSystemHandler.java => SomfyTahomaZwaveHeatingSystemHandler.java} (79%) create mode 100644 bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/valveheatingsystem.xml diff --git a/bundles/org.openhab.binding.somfytahoma/README.md b/bundles/org.openhab.binding.somfytahoma/README.md index 8531794da..86f37019e 100644 --- a/bundles/org.openhab.binding.somfytahoma/README.md +++ b/bundles/org.openhab.binding.somfytahoma/README.md @@ -31,6 +31,7 @@ home automation systems. - electricity sensors (get energy consumption) - door locks (LOCK/UNLOCK, OPEN/CLOSE commands) - heating systems (control temperature, set heating level) +- valve heating systems (control temperature, derogation mode and temperature) - exterior heating systems (set heating level) - alarms (both interior/external) - pods @@ -62,63 +63,67 @@ Please see the example below. ## Channels -| Thing | Channel | Note | -|-------------------------------------------------------------------------------|:---------------------:|-------------------------------------------------------------------------------------------------------------------------------| -| bridge | N.A | bridge does not expose any channel | -| gateway | status | status of your Tahoma gateway | -| gate | gate_command | used for controlling your gate (open, close, stop, pedestrian) | -| gate | gate_state | get state of your gate | -| roller shutter, screen, venetian blind, garage door, awning, pergola, curtain | control | device controller which reacts to commands UP/DOWN/ON/OFF/OPEN/CLOSE/MY/STOP + closure 0-100 | -| window | control | device controller which reacts to commands UP/DOWN/ON/OFF/OPEN/CLOSE/STOP + closure 0-100 | -| silent roller shutter | silent_control | similar to control channel but in silent mode | -| venetian blind, adjustable slats roller shutter | orientation | percentual orientation of the blind's slats, it can have value 0-100. For IO Homecontrol devices only (non RTS) | -| venetian blind, adjustable slats roller shutter | closure_orientation | percentual closure and orientation of the blind's slats, it can have value 0-100. For IO Homecontrol devices only (non RTS) | -| adjustable slats roller shutter | rocker | used for setting the rocker position of the roller shutter, the only position allowing the slats control | -| action group | execute_action | switch which reacts to ON command and triggers the predefined Tahoma action | -| onoff, light | switch | reacts to standard ON/OFF commands | -| dimmer light | light_intensity | sets/gets intensity of the dimmer light or ON/OFF | -| smoke sensor, occupancy sensor, contact sensor & water sensor | contact | normal value is CLOSE, changes to OPEN when detection triggered | -| smoke sensor, occupancy sensor, contact sensor & water sensor | sensor_defect | indicates the health of the sensor (dead, lowBatter, maintenanceRequired, noDefect) | -| smoke sensor | radio_battery | maintenance radio part battery state (low, normal) | -| smoke sensor | sensor_battery | maintenance sensor part battery state (absence, low, normal) | -| smoke sensor | short_check | triggering the smoke sensor's short check | -| smoke sensor | long_check | triggering the smoke sensor's long check | -| light sensor | luminance | light luminance value in luxes | -| electricity sensor | energy_consumption | energy consumption value in watts | -| humidity sensor | humidity | current relative humidity | -| dock | battery_status | indicates running on battery (yes/no) | -| dock | battery_level | remaining battery percentage | -| dock | siren_status | used for controlling and getting siren state (on, off, cyclic) | -| dock | short_beep | testing of dock's siren - short beep | -| dock | long_beep | testing of dock's siren - long beep | -| siren | battery | battery level full/low/normal/verylow | -| siren | onoff | controlling siren status ON/OFF | -| siren | memorized_volume | setting memorized volume (normal/highest) | -| pod | cyclic_button | pod cyclic button state | -| pod | battery_status | pod battery status state | -| pod | lighting_led_pod_mode | lighting LED pod mod state | -| interior alarm | alarm_command | used for sending commands to Somfy alarm device | -| interior alarm | intrusion_control | used for alarm external intrusion controlling | -| interior alarm, myfox alarm | alarm_state | state of the Somfy alarm | -| interior alarm | target_alarm_state | target state of the Somfy alarm | -| interior alarm, myfox alarm | intrusion_state | intrusion state of the Somfy alarm | -| external alarm | active_zones_state | state of external alarm active zones | -| door lock | lock | switch representing unlocked/locked state | -| door lock | open | switch representing open/close state | -| on/off heating system | target_heating_level | target heating level (off, eco, comfort, frostprotection) | -| heating system | current_temperature | current temperature of the heating system | -| heating system | current_state | current state of the heating system | -| heating system, thermostat | target_temperature | target temperature of the heating system | -| heating system, thermostat | battery_level | battery level of the heating system | -| exterior heating system | heating_level | heating level of the exterior heating system or ON/OFF | -| thermostat | heating_mode | standard heating mode of the thermostat (away, freeze, manual, ...) | -| thermostat | derogation_heating_mode | derogation heating mode of the thermostat (away, freeze, manual, ...) | -| thermostat | derogation_activation | derogation activation state (inactive, active) | -| temperature sensor | temperature | temperature reported by the sensor | -| myfox camera, myfox alarm | cloud_status | cloud connection status | -| myfox camera | shutter | controlling of the camera shutter | -| myfox alarm | myfox_alarm_command | used for sending commands to Somfy Myfox alarm device | - +| Thing | Channel | Note | +|-------------------------------------------------------------------------------|------------------------------|-----------------------------------------------------------------------------------------------------------------------------| +| bridge | N.A | bridge does not expose any channel | +| gateway | status | status of your Tahoma gateway | +| gate | gate_command | used for controlling your gate (open, close, stop, pedestrian) | +| gate | gate_state | get state of your gate (open, closed, pedestrian) | +| gate | gate_position | get position (0-100%) of your gate (where supported) | +| roller shutter, screen, venetian blind, garage door, awning, pergola, curtain | control | device controller which reacts to commands UP/DOWN/ON/OFF/OPEN/CLOSE/MY/STOP + closure 0-100 | +| window | control | device controller which reacts to commands UP/DOWN/ON/OFF/OPEN/CLOSE/STOP + closure 0-100 | +| silent roller shutter | silent_control | similar to control channel but in silent mode | +| venetian blind, adjustable slats roller shutter | orientation | percentual orientation of the blind's slats, it can have value 0-100. For IO Homecontrol devices only (non RTS) | +| venetian blind, adjustable slats roller shutter | closure_orientation | percentual closure and orientation of the blind's slats, it can have value 0-100. For IO Homecontrol devices only (non RTS) | +| adjustable slats roller shutter | rocker | used for setting the rocker position of the roller shutter, the only position allowing the slats control | +| action group | execute_action | switch which reacts to ON command and triggers the predefined Tahoma action | +| onoff, light | switch | reacts to standard ON/OFF commands | +| dimmer light | light_intensity | sets/gets intensity of the dimmer light or ON/OFF | +| smoke sensor, occupancy sensor, contact sensor & water sensor | contact | normal value is CLOSE, changes to OPEN when detection triggered | +| smoke sensor, occupancy sensor, contact sensor & water sensor | sensor_defect | indicates the health of the sensor (dead, lowBatter, maintenanceRequired, noDefect) | +| smoke sensor | radio_battery | maintenance radio part battery state (low, normal) | +| smoke sensor | sensor_battery | maintenance sensor part battery state (absence, low, normal) | +| smoke sensor | short_check | triggering the smoke sensor's short check | +| smoke sensor | long_check | triggering the smoke sensor's long check | +| light sensor | luminance | light luminance value in luxes | +| electricity sensor | energy_consumption | energy consumption value in watts | +| humidity sensor | humidity | current relative humidity | +| dock | battery_status | indicates running on battery (yes/no) | +| dock | battery_level | remaining battery percentage | +| dock | siren_status | used for controlling and getting siren state (on, off, cyclic) | +| dock | short_beep | testing of dock's siren - short beep | +| dock | long_beep | testing of dock's siren - long beep | +| siren | battery | battery level full/low/normal/verylow | +| siren | onoff | controlling siren status ON/OFF | +| siren | memorized_volume | setting memorized volume (normal/highest) | +| pod | cyclic_button | pod cyclic button state | +| pod | battery_status | pod battery status state | +| pod | lighting_led_pod_mode | lighting LED pod mod state | +| interior alarm | alarm_command | used for sending commands to Somfy alarm device | +| interior alarm | intrusion_control | used for alarm external intrusion controlling | +| interior alarm, myfox alarm | alarm_state | state of the Somfy alarm | +| interior alarm | target_alarm_state | target state of the Somfy alarm | +| interior alarm, myfox alarm | intrusion_state | intrusion state of the Somfy alarm | +| external alarm | active_zones_state | state of external alarm active zones | +| door lock | lock | switch representing unlocked/locked state | +| door lock | open | switch representing open/close state | +| on/off heating system | target_heating_level | target heating level (off, eco, comfort, frostprotection) | +| heating system | current_temperature | current temperature of the heating system | +| heating system | current_state | current state of the heating system | +| heating system, valve heating system, thermostat | target_temperature | target temperature of the heating system | +| heating system, valve heating system, thermostat | battery_level | battery level of the heating system | +| valve heating system, thermostat | derogation_heating_mode | derogation heating mode of the thermostat (away, freeze, manual, ...) | +| valve heating system, thermostat | derogated_target_temperature | target temperature of the heating system | +| valve heating system | current_heating_mode | current heating mode of the thermostatic valve | +| valve heating system | open_closed_valve | current open/closed state of the thermostatic valve | +| valve heating system | operating mode | operating mode of the thermostatic valve | +| thermostat | heating_mode | standard heating mode of the thermostat (away, freeze, manual, ...) | +| thermostat | derogation_activation | derogation activation state (inactive, active) | +| exterior heating system | heating_level | heating level of the exterior heating system or ON/OFF | +| temperature sensor | temperature | temperature reported by the sensor | +| myfox camera, myfox alarm | cloud_status | cloud connection status | +| myfox camera | shutter | controlling of the camera shutter | +| myfox alarm | myfox_alarm_command | used for sending commands to Somfy Myfox alarm device | ### Remarks diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaBindingConstants.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaBindingConstants.java index 5f832a102..abcaad01c 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaBindingConstants.java +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaBindingConstants.java @@ -106,7 +106,9 @@ public class SomfyTahomaBindingConstants { public static final ThingTypeUID THING_TYPE_POD = new ThingTypeUID(BINDING_ID, "pod"); // Heating system - public static final ThingTypeUID THING_TYPE_HEATING_SYSTEM = new ThingTypeUID(BINDING_ID, "heatingsystem"); + public static final ThingTypeUID THING_TYPE_VALVE_HEATING_SYSTEM = new ThingTypeUID(BINDING_ID, + "valveheatingsystem"); + public static final ThingTypeUID THING_TYPE_ZWAVE_HEATING_SYSTEM = new ThingTypeUID(BINDING_ID, "heatingsystem"); public static final ThingTypeUID THING_TYPE_ONOFF_HEATING_SYSTEM = new ThingTypeUID(BINDING_ID, "onoffheatingsystem"); public static final ThingTypeUID THING_TYPE_EXTERIOR_HEATING_SYSTEM = new ThingTypeUID(BINDING_ID, @@ -220,15 +222,24 @@ public class SomfyTahomaBindingConstants { // Thermostat public static final String HEATING_MODE = "heating_mode"; - public static final String DEROGATION_HEATING_MODE = "derogation_heating_mode"; public static final String DEROGATION_ACTIVATION = "derogation_activation"; + // Thermostat & Valve Heating system + public static final String DEROGATED_TARGET_TEMPERATURE = "derogated_target_temperature"; + public static final String DEROGATION_HEATING_MODE = "derogation_heating_mode"; + + // Valve heating system + public static final String CURRENT_HEATING_MODE = "current_heating_mode"; + public static final String OPEN_CLOSED_VALVE = "open_closed_valve"; + public static final String OPERATING_MODE = "operating_mode"; + // Window handle public static final String HANDLE_STATE = "handle_state"; // Gate public static final String GATE_STATE = "gate_state"; public static final String GATE_COMMAND = "gate_command"; + public static final String GATE_POSITION = "gate_position"; // ElectricitySensor public static final String ENERGY_CONSUMPTION = "energy_consumption"; @@ -285,6 +296,7 @@ public class SomfyTahomaBindingConstants { public static final String COMMAND_SET_HEATINGLEVEL = "setHeatingLevel"; public static final String COMMAND_SET_PEDESTRIANPOSITION = "setPedestrianPosition"; public static final String COMMAND_SET_ROCKERPOSITION = "setRockerPosition"; + public static final String COMMAND_SET_DEROGATION = "setDerogation"; public static final String COMMAND_UP = "up"; public static final String COMMAND_DOWN = "down"; public static final String COMMAND_OPEN = "open"; @@ -309,10 +321,12 @@ public class SomfyTahomaBindingConstants { public static final String BATTERY_LEVEL_STATE = "core:BatteryLevelState"; public static final String SIREN_STATUS_STATE = "internal:SirenStatusState"; public static final String TARGET_TEMPERATURE_STATE = "core:TargetTemperatureState"; + public static final String TARGET_ROOM_TEMPERATURE_STATE = "core:TargetRoomTemperatureState"; public static final String SMOKE_STATE = "core:SmokeState"; public static final String SENSOR_DEFECT_STATE = "core:SensorDefectState"; public static final String RADIO_PART_BATTERY_STATE = "io:MaintenanceRadioPartBatteryState"; public static final String SENSOR_PART_BATTERY_STATE = "io:MaintenanceSensorPartBatteryState"; + public static final String ZWAVE_SET_POINT_TYPE_STATE = "zwave:SetPointTypeState"; // supported uiClasses public static final String CLASS_ROLLER_SHUTTER = "RollerShutter"; @@ -361,12 +375,12 @@ public class SomfyTahomaBindingConstants { THING_TYPE_EXTERIORSCREEN, THING_TYPE_EXTERIORVENETIANBLIND, THING_TYPE_GARAGEDOOR, THING_TYPE_AWNING, THING_TYPE_ACTIONGROUP, THING_TYPE_ONOFF, THING_TYPE_LIGHT, THING_TYPE_LIGHTSENSOR, THING_TYPE_SMOKESENSOR, THING_TYPE_CONTACTSENSOR, THING_TYPE_OCCUPANCYSENSOR, THING_TYPE_WINDOW, THING_TYPE_INTERNAL_ALARM, - THING_TYPE_EXTERNAL_ALARM, THING_TYPE_POD, THING_TYPE_HEATING_SYSTEM, THING_TYPE_ONOFF_HEATING_SYSTEM, + THING_TYPE_EXTERNAL_ALARM, THING_TYPE_POD, THING_TYPE_ZWAVE_HEATING_SYSTEM, THING_TYPE_ONOFF_HEATING_SYSTEM, THING_TYPE_DOOR_LOCK, THING_TYPE_PERGOLA, THING_TYPE_WINDOW_HANDLE, THING_TYPE_TEMPERATURESENSOR, THING_TYPE_GATE, THING_TYPE_CURTAIN, THING_TYPE_ELECTRICITYSENSOR, THING_TYPE_DOCK, THING_TYPE_SIREN, THING_TYPE_ADJUSTABLE_SLATS_ROLLERSHUTTER, THING_TYPE_MYFOX_CAMERA, THING_TYPE_ROLLERSHUTTER_UNO, THING_TYPE_WATERSENSOR, THING_TYPE_HUMIDITYSENSOR, THING_TYPE_MYFOX_ALARM, THING_TYPE_THERMOSTAT, - THING_TYPE_DIMMER_LIGHT, THING_TYPE_EXTERIOR_HEATING_SYSTEM)); + THING_TYPE_DIMMER_LIGHT, THING_TYPE_EXTERIOR_HEATING_SYSTEM, THING_TYPE_VALVE_HEATING_SYSTEM)); // somfy gateways public static Map gatewayTypes = new HashMap() { diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaException.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaException.java deleted file mode 100644 index a29cad324..000000000 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaException.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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.somfytahoma.internal; - -import org.eclipse.jdt.annotation.NonNullByDefault; - -/** - * The {@link SomfyTahomaException} represents an exception in the response of - * the TahomaLink cloud service. - * - * @author Ondrej Pecta - Initial contribution - */ -@NonNullByDefault -public class SomfyTahomaException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public SomfyTahomaException(String message) { - super(message); - } - - public SomfyTahomaException(final Throwable cause) { - super(cause); - } - - public SomfyTahomaException(final String message, final Throwable cause) { - super(message, cause); - } -} diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaHandlerFactory.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaHandlerFactory.java index 4cf0aa534..688e67bee 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaHandlerFactory.java +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaHandlerFactory.java @@ -108,8 +108,10 @@ public class SomfyTahomaHandlerFactory extends BaseThingHandlerFactory { return new SomfyTahomaExternalAlarmHandler(thing); } else if (thingTypeUID.equals(THING_TYPE_POD)) { return new SomfyTahomaPodHandler(thing); - } else if (thingTypeUID.equals(THING_TYPE_HEATING_SYSTEM)) { - return new SomfyTahomaHeatingSystemHandler(thing); + } else if (thingTypeUID.equals(THING_TYPE_VALVE_HEATING_SYSTEM)) { + return new SomfyTahomaValveHeatingSystemHandler(thing); + } else if (thingTypeUID.equals(THING_TYPE_ZWAVE_HEATING_SYSTEM)) { + return new SomfyTahomaZwaveHeatingSystemHandler(thing); } else if (thingTypeUID.equals(THING_TYPE_ONOFF_HEATING_SYSTEM)) { return new SomfyTahomaOnOffHeatingSystemHandler(thing); } else if (thingTypeUID.equals(THING_TYPE_EXTERIOR_HEATING_SYSTEM)) { diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/discovery/SomfyTahomaItemDiscoveryService.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/discovery/SomfyTahomaItemDiscoveryService.java index fd6b1b5d4..d79152aac 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/discovery/SomfyTahomaItemDiscoveryService.java +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/discovery/SomfyTahomaItemDiscoveryService.java @@ -237,10 +237,14 @@ public class SomfyTahomaItemDiscoveryService extends AbstractDiscoveryService case CLASS_HEATING_SYSTEM: if ("SomfyThermostat".equals(device.getWidget())) { deviceDiscovered(device, THING_TYPE_THERMOSTAT); + } else if ("ValveHeatingTemperatureInterface".equals(device.getWidget())) { + deviceDiscovered(device, THING_TYPE_VALVE_HEATING_SYSTEM); } else if (isOnOffHeatingSystem(device)) { deviceDiscovered(device, THING_TYPE_ONOFF_HEATING_SYSTEM); + } else if (isZwaveHeatingSystem(device)) { + deviceDiscovered(device, THING_TYPE_ZWAVE_HEATING_SYSTEM); } else { - deviceDiscovered(device, THING_TYPE_HEATING_SYSTEM); + logUnsupportedDevice(device); } break; case CLASS_EXTERIOR_HEATING_SYSTEM: @@ -354,6 +358,10 @@ public class SomfyTahomaItemDiscoveryService extends AbstractDiscoveryService return hasCommmand(device, COMMAND_SET_HEATINGLEVEL); } + private boolean isZwaveHeatingSystem(SomfyTahomaDevice device) { + return hasState(device, ZWAVE_SET_POINT_TYPE_STATE); + } + private boolean hasCommmand(SomfyTahomaDevice device, String command) { return device.getDefinition().getCommands().stream().anyMatch(cmd -> command.equals(cmd.getCommandName())); } diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBaseThingHandler.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBaseThingHandler.java index 7e12dc9cd..4dcab7551 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBaseThingHandler.java +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBaseThingHandler.java @@ -54,7 +54,7 @@ public abstract class SomfyTahomaBaseThingHandler extends BaseThingHandler { return stateNames; } - private String url = ""; + protected String url = ""; @Override public void initialize() { @@ -124,7 +124,7 @@ public abstract class SomfyTahomaBaseThingHandler extends BaseThingHandler { protected void sendCommand(String cmd, String param) { SomfyTahomaBridgeHandler handler = getBridgeHandler(); if (handler != null) { - handler.sendCommand(url, cmd, param); + handler.sendCommand(url, cmd, param, EXEC_URL + "apply"); } } diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBridgeHandler.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBridgeHandler.java index cee8000bf..9004f4f31 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBridgeHandler.java +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBridgeHandler.java @@ -556,23 +556,23 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler { .timeout(TAHOMA_TIMEOUT, TimeUnit.SECONDS).agent(TAHOMA_AGENT); } - public void sendCommand(String io, String command, String params) { + public void sendCommand(String io, String command, String params, String url) { if (ThingStatus.OFFLINE == thing.getStatus() && !reLogin()) { return; } - Boolean result = sendCommandInternal(io, command, params); + Boolean result = sendCommandInternal(io, command, params, url); if (!result) { - sendCommandInternal(io, command, params); + sendCommandInternal(io, command, params, url); } } - private Boolean sendCommandInternal(String io, String command, String params) { + private Boolean sendCommandInternal(String io, String command, String params, String url) { String value = params.equals("[]") ? command : params.replace("\"", ""); String urlParameters = "{\"label\":\"" + getThingLabelByURL(io) + " - " + value + " - OH2\",\"actions\":[{\"deviceURL\":\"" + io + "\",\"commands\":[{\"name\":\"" + command + "\",\"parameters\":" + params + "}]}]}"; - SomfyTahomaApplyResponse response = invokeCallToURL(EXEC_URL + "apply", urlParameters, HttpMethod.POST, + SomfyTahomaApplyResponse response = invokeCallToURL(url, urlParameters, HttpMethod.POST, SomfyTahomaApplyResponse.class); if (response != null) { if (!response.getExecId().isEmpty()) { @@ -699,6 +699,7 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler { break; case DELETE: response = sendDeleteToTahomaWithCookie(url); + default: } return classOfT != null ? gson.fromJson(response, classOfT) : null; } catch (JsonSyntaxException e) { diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaGateHandler.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaGateHandler.java index c334274c2..c823bc8d7 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaGateHandler.java +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaGateHandler.java @@ -32,6 +32,7 @@ public class SomfyTahomaGateHandler extends SomfyTahomaBaseThingHandler { public SomfyTahomaGateHandler(Thing thing) { super(thing); stateNames.put(GATE_STATE, "core:OpenClosedPedestrianState"); + stateNames.put(GATE_POSITION, "core:ClosureState"); } @Override @@ -42,6 +43,8 @@ public class SomfyTahomaGateHandler extends SomfyTahomaBaseThingHandler { } else { if (GATE_COMMAND.equals(channelUID.getId())) { sendCommand(getGateCommand(command.toString().toLowerCase())); + } else if (GATE_POSITION.equals(channelUID.getId())) { + sendCommand(COMMAND_SET_CLOSURE, "[" + toInteger(command) + "]"); } } } diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaPodHandler.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaPodHandler.java index c3c5c1e81..c6fb0eaae 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaPodHandler.java +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaPodHandler.java @@ -15,7 +15,10 @@ package org.openhab.binding.somfytahoma.internal.handler; import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.*; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; +import org.openhab.core.types.Command; +import org.openhab.core.types.RefreshType; /** * The {@link SomfyTahomaPodHandler} is responsible for handling commands, @@ -32,4 +35,25 @@ public class SomfyTahomaPodHandler extends SomfyTahomaBaseThingHandler { stateNames.put(BATTERY_STATUS, BATTERY_STATUS_STATE); stateNames.put(LIGHTING_LED_POD_MODE, "internal:LightingLedPodModeState"); } + + @Override + public void handleCommand(ChannelUID channelUID, Command command) { + super.handleCommand(channelUID, command); + if (!LIGHTING_LED_POD_MODE.equals(channelUID.getId())) { + return; + } + + if (command instanceof RefreshType) { + return; + } else { + sendPodCommand("setLightingLedPodMode", "[" + command + "]"); + } + } + + private void sendPodCommand(String cmd, String param) { + SomfyTahomaBridgeHandler handler = getBridgeHandler(); + if (handler != null) { + handler.sendCommand(url, cmd, param, EXEC_URL + "apply/internal"); + } + } } diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaThermostatHandler.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaThermostatHandler.java index 25fdbf2a6..83a41dd1f 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaThermostatHandler.java +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaThermostatHandler.java @@ -33,5 +33,6 @@ public class SomfyTahomaThermostatHandler extends SomfyTahomaBaseThingHandler { stateNames.put(HEATING_MODE, "somfythermostat:HeatingModeState"); stateNames.put(DEROGATION_HEATING_MODE, "somfythermostat:DerogationHeatingModeState"); stateNames.put(DEROGATION_ACTIVATION, "core:DerogationActivationState"); + stateNames.put(DEROGATED_TARGET_TEMPERATURE, "core:DerogatedTargetTemperatureState"); } } diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaValveHeatingSystemHandler.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaValveHeatingSystemHandler.java new file mode 100644 index 000000000..991e996c9 --- /dev/null +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaValveHeatingSystemHandler.java @@ -0,0 +1,72 @@ +/** + * 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.somfytahoma.internal.handler; + +import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.*; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.library.types.QuantityType; +import org.openhab.core.thing.ChannelUID; +import org.openhab.core.thing.Thing; +import org.openhab.core.types.Command; +import org.openhab.core.types.RefreshType; + +/** + * The {@link SomfyTahomaValveHeatingSystemHandler} is responsible for handling commands, + * which are sent to one of the channels of the valve heating system thing. + * + * @author Ondrej Pecta - Initial contribution + */ +@NonNullByDefault +public class SomfyTahomaValveHeatingSystemHandler extends SomfyTahomaBaseThingHandler { + + public SomfyTahomaValveHeatingSystemHandler(Thing thing) { + super(thing); + stateNames.put(TARGET_TEMPERATURE, TARGET_ROOM_TEMPERATURE_STATE); + stateNames.put(BATTERY_LEVEL, BATTERY_LEVEL_STATE); + stateNames.put(DEROGATION_HEATING_MODE, "io:DerogationHeatingModeState"); + stateNames.put(DEROGATED_TARGET_TEMPERATURE, "core:DerogatedTargetTemperatureState"); + stateNames.put(CURRENT_HEATING_MODE, "io:CurrentHeatingModeState"); + stateNames.put(OPEN_CLOSED_VALVE, "core:OpenClosedValveState"); + stateNames.put(OPERATING_MODE, "core:OperatingModeState"); + } + + @Override + public void handleCommand(ChannelUID channelUID, Command command) { + super.handleCommand(channelUID, command); + if (command instanceof RefreshType) { + return; + } else { + if (DEROGATED_TARGET_TEMPERATURE.equals(channelUID.getId()) && command instanceof QuantityType) { + QuantityType type = (QuantityType) command; + String param = "[" + type.doubleValue() + ", \"next_mode\"]"; + sendCommand(COMMAND_SET_DEROGATION, param); + } else if (DEROGATION_HEATING_MODE.equals(channelUID.getId())) { + switch (command.toString()) { + case "auto": + sendCommand("exitDerogation"); + break; + case "away": + case "comfort": + case "eco": + case "frostprotection": + String param = "[\"" + command.toString() + "\", \"next_mode\"]"; + sendCommand(COMMAND_SET_DEROGATION, param); + break; + default: + + } + } + } + } +} diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaHeatingSystemHandler.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaZwaveHeatingSystemHandler.java similarity index 79% rename from bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaHeatingSystemHandler.java rename to bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaZwaveHeatingSystemHandler.java index d6c4d2428..3cf4743bc 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaHeatingSystemHandler.java +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaZwaveHeatingSystemHandler.java @@ -21,20 +21,20 @@ import org.openhab.core.types.Command; import org.openhab.core.types.RefreshType; /** - * The {@link SomfyTahomaHeatingSystemHandler} is responsible for handling commands, - * which are sent to one of the channels of the heating system thing. + * The {@link SomfyTahomaZwaveHeatingSystemHandler} is responsible for handling commands, + * which are sent to one of the channels of the z-wave heating system thing. * * @author Ondrej Pecta - Initial contribution */ @NonNullByDefault -public class SomfyTahomaHeatingSystemHandler extends SomfyTahomaBaseThingHandler { +public class SomfyTahomaZwaveHeatingSystemHandler extends SomfyTahomaBaseThingHandler { - public SomfyTahomaHeatingSystemHandler(Thing thing) { + public SomfyTahomaZwaveHeatingSystemHandler(Thing thing) { super(thing); stateNames.put(TARGET_TEMPERATURE, TARGET_TEMPERATURE_STATE); stateNames.put(CURRENT_TEMPERATURE, "zwave:SetPointHeatingValueState"); stateNames.put(BATTERY_LEVEL, BATTERY_LEVEL_STATE); - stateNames.put(CURRENT_STATE, "zwave:SetPointTypeState"); + stateNames.put(CURRENT_STATE, ZWAVE_SET_POINT_TYPE_STATE); } @Override diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/channels.xml index d8ad87488..934e625fb 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/channels.xml @@ -190,6 +190,13 @@ + + Dimmer + + Position of the gate + + + Switch @@ -301,8 +308,17 @@ String - Derogation heating mode of the Somfy thermostat - + Derogation heating mode of the Somfy thermostat/valve + + + + + + + + + + @@ -352,4 +368,25 @@ The level of the heating + + + String + + Current heating mode of the Somfy thermostatic valve + + + + + Contact + + Current open/closed state of the Somfy thermostatic valve + + + + + String + + Operating mode of the Somfy thermostatic valve + + diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/gate.xml b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/gate.xml index 65ec0d88f..1d3519231 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/gate.xml +++ b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/gate.xml @@ -12,6 +12,7 @@ + diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/heatingsystem.xml b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/heatingsystem.xml index e509d851f..e97800f99 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/heatingsystem.xml +++ b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/heatingsystem.xml @@ -8,7 +8,7 @@ - + diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/thermostat.xml b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/thermostat.xml index e06b78675..690f9a1ce 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/thermostat.xml +++ b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/thermostat.xml @@ -10,11 +10,12 @@ - + + diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/valveheatingsystem.xml b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/valveheatingsystem.xml new file mode 100644 index 000000000..049ff44d6 --- /dev/null +++ b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/valveheatingsystem.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + +