diff --git a/bundles/org.openhab.binding.somfytahoma/README.md b/bundles/org.openhab.binding.somfytahoma/README.md index 3efd9b68e0e06..67b6f5725a257 100644 --- a/bundles/org.openhab.binding.somfytahoma/README.md +++ b/bundles/org.openhab.binding.somfytahoma/README.md @@ -101,7 +101,7 @@ Please see the example below. ## Channels | Thing | Channel | Note | -| ---------------------------------------------------------------------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +|------------------------------------------------------------------------------------|---------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | bridge | N.A | bridge does not expose any channel | | gateway | status | status of your gateway | | gateway | scenarios | used to run the scenarios defined in the cloud portal | @@ -113,7 +113,8 @@ Please see the example below. | 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, bioclimatic pergola | 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) | +| venetian blind, up/down 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) | +| up/down venetian blind | tilt | tilt of the blind's slats, it can have value -5 to 5 (negative or positive tilt). Works even for RTS blinds | | adjustable slats roller shutter | rocker | used for setting the rocker position of the roller shutter, the only position allowing the slats control | | bioclimatic pergola | slats | slats state (open/closed) | | bioclimatic pergola | pergola_command | used for controlling biclimatic pergola (closeSlats, openSlats, stop) | 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 a514893b6c96c..21731e98b3bee 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 @@ -59,6 +59,10 @@ public class SomfyTahomaBindingConstants { // Venetian Blind public static final ThingTypeUID THING_TYPE_VENETIANBLIND = new ThingTypeUID(BINDING_ID, "venetianblind"); + // Up Down Venetian Blind + public static final ThingTypeUID THING_TYPE_UPDOWNVENETIANBLIND = new ThingTypeUID(BINDING_ID, + "updownvenetianblind"); + // Exterior Screen public static final ThingTypeUID THING_TYPE_EXTERIORSCREEN = new ThingTypeUID(BINDING_ID, "exteriorscreen"); @@ -195,6 +199,9 @@ public class SomfyTahomaBindingConstants { public static final String CONTROL = "control"; public static final String MOVING = "moving"; + // Up down venetian blind + public static final String TILT = "tilt"; + // Adjustable slats roller shutter public static final String ROCKER = "rocker"; @@ -399,7 +406,6 @@ public class SomfyTahomaBindingConstants { public static final int TYPE_BOOLEAN = 6; public static final String UNAVAILABLE = "unavailable"; public static final String TEMPORARILY_BANNED = "Too many attempts with an invalid token, temporarily banned."; - public static final String TOO_MANY_REQUESTS = "Too many requests, try again later"; public static final String EVENT_LISTENER_TIMEOUT = "No registered event listener"; public static final String AUTHENTICATION_OAUTH_GRANT_ERROR = "Provided Authorization Grant is invalid."; @@ -439,6 +445,9 @@ public class SomfyTahomaBindingConstants { public static final String COMMAND_SET_TARGET_TEMPERATURE = "setTargetTemperature"; public static final String COMMAND_REFRESH_DHWMODE = "refreshDHWMode"; public static final String COMMAND_REFRESH_BOOST_MODE_DURATION = "refreshBoostModeDuration"; + public static final String COMMAND_TILT_POSITIVE = "tiltPositive"; + public static final String COMMAND_TILT_NEGATIVE = "tiltNegative"; + public static final String COMMAND_REST = "rest"; // States public static final String OPERATING_MODE_STATE = "core:OperatingModeState"; @@ -537,7 +546,7 @@ public class SomfyTahomaBindingConstants { THING_TYPE_DIMMER_LIGHT, THING_TYPE_EXTERIOR_HEATING_SYSTEM, THING_TYPE_VALVE_HEATING_SYSTEM, THING_TYPE_BIOCLIMATIC_PERGOLA, THING_TYPE_WATERHEATINGSYSTEM, THING_TYPE_HITACHI_ATWHZ, THING_TYPE_HITACHI_DHW, THING_TYPE_HITACHI_ATWMC, THING_TYPE_RAINSENSOR, THING_TYPE_SHUTTER, - THING_TYPE_CARBON_DIOXIDE_SENSOR, THING_TYPE_NOISE_SENSOR)); + THING_TYPE_CARBON_DIOXIDE_SENSOR, THING_TYPE_NOISE_SENSOR, THING_TYPE_UPDOWNVENETIANBLIND)); // somfy gateways public static Map gatewayTypes = new HashMap<>() { 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 ef6106806c816..101bf9c51442d 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 @@ -55,6 +55,7 @@ import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaTemperatureSensorHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaThermostatHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaUnoRollerShutterHandler; +import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaUpDownVenetianBlindHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaValveHeatingSystemHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaVenetianBlindHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaWaterHeatingSystemHandler; @@ -126,6 +127,8 @@ protected ThingHandler createHandler(Thing thing) { } else if (thingTypeUID.equals(THING_TYPE_VENETIANBLIND) || thingTypeUID.equals(THING_TYPE_EXTERIORVENETIANBLIND)) { return new SomfyTahomaVenetianBlindHandler(thing); + } else if (thingTypeUID.equals(THING_TYPE_UPDOWNVENETIANBLIND)) { + return new SomfyTahomaUpDownVenetianBlindHandler(thing); } else if (thingTypeUID.equals(THING_TYPE_GARAGEDOOR)) { return new SomfyTahomaRollerShutterHandler(thing); } else if (thingTypeUID.equals(THING_TYPE_AWNING)) { 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 a36a3d0eb59ba..f1235e435a516 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 @@ -208,6 +208,9 @@ private void discoverDevice(SomfyTahomaDevice device, SomfyTahomaSetup setup) { // widget: DynamicVenetianBlind if (hasCommmand(device, "setOrientation")) { deviceDiscovered(device, THING_TYPE_VENETIANBLIND, place); + } else if ("UpDownVenetianBlind".equals(widget)) { + // widget: UpDownVenetianBlind + deviceDiscovered(device, THING_TYPE_UPDOWNVENETIANBLIND, place); } else { // simple venetian blind without orientation deviceDiscovered(device, THING_TYPE_SHUTTER, place); diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaUpDownVenetianBlindHandler.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaUpDownVenetianBlindHandler.java new file mode 100644 index 0000000000000..b5dba44671dd7 --- /dev/null +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaUpDownVenetianBlindHandler.java @@ -0,0 +1,98 @@ +/** + * Copyright (c) 2010-2024 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.thing.ChannelUID; +import org.openhab.core.thing.Thing; +import org.openhab.core.types.Command; +import org.openhab.core.types.RefreshType; + +/** + * The {@link SomfyTahomaUpDownVenetianBlindHandler} is responsible for handling commands, + * which are sent to one of the channels of the up/down venetian blind thing. + * + * @author Ondrej Pecta - Initial contribution + */ +@NonNullByDefault +public class SomfyTahomaUpDownVenetianBlindHandler extends SomfyTahomaBaseThingHandler { + + public SomfyTahomaUpDownVenetianBlindHandler(Thing thing) { + super(thing); + } + + @Override + public void handleCommand(ChannelUID channelUID, Command command) { + super.handleCommand(channelUID, command); + + if (command instanceof RefreshType) { + return; + } + + switch (channelUID.getId()) { + case CONTROL: + case TILT: + String cmd = getTahomaCommand(command.toString(), channelUID.getId()); + if (COMMAND_MY.equals(cmd)) { + sendCommand(COMMAND_MY); + } else if (COMMAND_STOP.equals(cmd)) { + String executionId = getCurrentExecutions(); + if (executionId != null) { + // Check if the venetian blind is moving and STOP is sent => STOP it + cancelExecution(executionId); + } else { + sendCommand(COMMAND_MY); + } + } else { + String param = (COMMAND_TILT_POSITIVE.equals(cmd) || COMMAND_TILT_NEGATIVE.equals(cmd)) + ? "[" + normalizeTilt(toInteger(command)) + ",0]" + : "[]"; + sendCommand(cmd, param); + } + break; + default: + return; + } + } + + private int normalizeTilt(int i) { + i = Math.abs(i); + return (i == 0 || i > 5) ? 1 : i; + } + + private String getTahomaCommand(String command, String channelId) { + switch (command) { + case "OFF": + case "DOWN": + case "CLOSE": + return COMMAND_CLOSE; + case "ON": + case "UP": + case "OPEN": + return COMMAND_OPEN; + case "MOVE": + case "MY": + return COMMAND_MY; + case "STOP": + return COMMAND_STOP; + default: + if (TILT.equals(channelId) && !"0".equals(command)) { + return (command.startsWith("-")) ? COMMAND_TILT_NEGATIVE : COMMAND_TILT_POSITIVE; + } else { + return COMMAND_REST; + } + } + } +} diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/i18n/somfytahoma.properties b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/i18n/somfytahoma.properties index 7e6d1e53d9446..a966e89848e4f 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/i18n/somfytahoma.properties +++ b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/i18n/somfytahoma.properties @@ -52,6 +52,7 @@ thing-type.somfytahoma.siren.label = Somfy Siren thing-type.somfytahoma.smokesensor.label = Somfy Smoke Sensor thing-type.somfytahoma.temperaturesensor.label = Somfy Temperature Sensor thing-type.somfytahoma.thermostat.label = Somfy Thermostat +thing-type.somfytahoma.updownvenetianblind.label = Somfy Up/Down Venetian Blind thing-type.somfytahoma.valveheatingsystem.label = Somfy Thermostatic Valve thing-type.somfytahoma.venetianblind.label = Somfy Venetian Blind thing-type.somfytahoma.waterheatingsystem.label = Somfy Water Heating System @@ -345,6 +346,8 @@ channel-type.somfytahoma.temperature.label = Temperature channel-type.somfytahoma.temperature.description = The temperature value of the sensor channel-type.somfytahoma.thermostat_setting_zone1.label = Zone 1 Thermostat Setting channel-type.somfytahoma.thermostat_setting_zone1.description = Thermostat setting control for the zone 1 +channel-type.somfytahoma.tilt.label = Tilt +channel-type.somfytahoma.tilt.description = Venetian blind tilt (-5..5) channel-type.somfytahoma.unit_control.label = Unit Control channel-type.somfytahoma.unit_control.description = Unit control channel-type.somfytahoma.unit_control.state.option.run = Run 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 d381669b923e8..33c1b0553dee4 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 @@ -885,4 +885,11 @@ + + Number + + Venetian blind tilt (-5..5) + + + diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/updownvenetianblind.xml b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/updownvenetianblind.xml new file mode 100644 index 0000000000000..5aa62af8b98fc --- /dev/null +++ b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/updownvenetianblind.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + url + + + +