[somfytahoma] added support for the Shutter thing (#12495)

Signed-off-by: Ondrej Pecta <opecta@gmail.com>
This commit is contained in:
Ondrej Pecta 2022-03-27 19:04:00 +02:00 committed by GitHub
parent c81506b44d
commit 0c2901f3ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 228 additions and 113 deletions

View File

@ -21,6 +21,7 @@ Any home automation system based on the OverKiz API is potentially supported.
- awnings (UP, DOWN, STOP control of an awning). IO Homecontrol devices are allowed to set exact position of an awning (0-100%)
- windows (UP, DOWN, STOP control of a window). IO Homecontrol devices are allowed to set exact position of a window (0-100%)
- pergolas (UP, DOWN, STOP control of a pergola). IO Homecontrol devices are allowed to set exact position of a pergola (0-100%)
- shutters (OPEN, CLOSE, STOP control of a shutter)
- on/off switches (connected by RTS, IO protocol or supported by USB stick - z-wave, enocean, ..)
- light switches (similar to on/off)
- dimmer lights (light switches with intensity setting)
@ -64,14 +65,14 @@ 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 |
| 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 |
| roller shutter, shutter, screen, ven. 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, bioclimatic pergola | orientation | percentual orientation of the blind's slats, it can have value 0-100. For IO Homecontrol devices only (non RTS) |

View File

@ -50,6 +50,9 @@ public class SomfyTahomaBindingConstants {
// Uno Roller Shutter
public static final ThingTypeUID THING_TYPE_ROLLERSHUTTER_UNO = new ThingTypeUID(BINDING_ID, "rollershutter_uno");
// Shutter
public static final ThingTypeUID THING_TYPE_SHUTTER = new ThingTypeUID(BINDING_ID, "shutter");
// Screen
public static final ThingTypeUID THING_TYPE_SCREEN = new ThingTypeUID(BINDING_ID, "screen");
@ -182,7 +185,7 @@ public class SomfyTahomaBindingConstants {
public static final String STATUS = "status";
public static final String SCENARIOS = "scenarios";
// Roller shutter, Awning, Screen, Blind, Garage door, Window, Curtain
// Roller shutter, Shutter, Awning, Screen, Blind, Garage door, Window, Curtain
public static final String CONTROL = "control";
// Adjustable slats roller shutter
@ -445,6 +448,7 @@ public class SomfyTahomaBindingConstants {
// supported uiClasses
public static final String CLASS_ROLLER_SHUTTER = "RollerShutter";
public static final String CLASS_SHUTTER = "Shutter";
public static final String CLASS_SCREEN = "Screen";
public static final String CLASS_VENETIAN_BLIND = "VenetianBlind";
public static final String CLASS_EXTERIOR_SCREEN = "ExteriorScreen";
@ -501,7 +505,7 @@ public class SomfyTahomaBindingConstants {
THING_TYPE_WATERSENSOR, THING_TYPE_HUMIDITYSENSOR, THING_TYPE_MYFOX_ALARM, THING_TYPE_THERMOSTAT,
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_HITACHI_DHW, THING_TYPE_HITACHI_ATWMC, THING_TYPE_RAINSENSOR, THING_TYPE_SHUTTER));
// somfy gateways
public static Map<Integer, String> gatewayTypes = new HashMap<Integer, String>() {

View File

@ -46,6 +46,7 @@ import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaPergolaHandle
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaPodHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaRainSensorHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaRollerShutterHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaShutterHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSilentRollerShutterHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSirenHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSmokeSensorHandler;
@ -118,6 +119,8 @@ public class SomfyTahomaHandlerFactory extends BaseThingHandlerFactory {
return new SomfyTahomaUnoRollerShutterHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_SCREEN) || thingTypeUID.equals(THING_TYPE_EXTERIORSCREEN)) {
return new SomfyTahomaRollerShutterHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_SHUTTER)) {
return new SomfyTahomaShutterHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_VENETIANBLIND)
|| thingTypeUID.equals(THING_TYPE_EXTERIORVENETIANBLIND)) {
return new SomfyTahomaVenetianBlindHandler(thing);

View File

@ -213,6 +213,10 @@ public class SomfyTahomaItemDiscoveryService extends AbstractDiscoveryService
deviceDiscovered(device, THING_TYPE_ROLLERSHUTTER, place);
}
break;
case CLASS_SHUTTER:
// widget: DynamicShutter
deviceDiscovered(device, THING_TYPE_SHUTTER, place);
break;
case CLASS_SCREEN:
// widget: PositionableTiltedScreen
deviceDiscovered(device, THING_TYPE_SCREEN, place);
@ -223,7 +227,12 @@ public class SomfyTahomaItemDiscoveryService extends AbstractDiscoveryService
break;
case CLASS_VENETIAN_BLIND:
// widget: DynamicVenetianBlind
if (hasCommmand(device, "setOrientation")) {
deviceDiscovered(device, THING_TYPE_VENETIANBLIND, place);
} else {
// simple venetian blind without orientation
deviceDiscovered(device, THING_TYPE_SHUTTER, place);
}
break;
case CLASS_WINDOW:
// widget: PositionableTiltedWindow

View File

@ -0,0 +1,78 @@
/**
* Copyright (c) 2010-2022 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.eclipse.jdt.annotation.Nullable;
import org.openhab.core.library.types.DecimalType;
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 SomfyTahomaShutterHandler} is responsible for handling commands,
* which are sent to one of the channels of the shutter thing.
*
* @author Ondrej Pecta - Initial contribution
*/
@NonNullByDefault
public class SomfyTahomaShutterHandler extends SomfyTahomaBaseThingHandler {
public SomfyTahomaShutterHandler(Thing thing) {
super(thing);
}
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
super.handleCommand(channelUID, command);
if (!CONTROL.equals(channelUID.getId())) {
return;
}
if (command instanceof RefreshType) {
return;
} else {
if (command instanceof DecimalType) {
sendCommand(toInteger(command) == 0 ? COMMAND_OPEN : COMMAND_CLOSE);
} else {
// Shutter understands "open", "close" and "stop" commands
String cmd = getTahomaCommand(command.toString());
if (cmd != null) {
sendCommand(cmd);
} else {
getLogger().debug("unsupported command: {}", command);
}
}
}
}
private @Nullable String getTahomaCommand(String command) {
switch (command) {
case "OFF":
case "DOWN":
case "CLOSE":
return COMMAND_CLOSE;
case "ON":
case "UP":
case "OPEN":
return COMMAND_OPEN;
case "STOP":
return COMMAND_STOP;
default:
return null;
}
}
}

View File

@ -45,6 +45,7 @@ thing-type.somfytahoma.rollershutter.label = Somfy Roller Shutter
thing-type.somfytahoma.rollershutter_silent.label = Somfy Silent Roller Shutter
thing-type.somfytahoma.rollershutter_uno.label = Somfy Roller Shutter Uno
thing-type.somfytahoma.screen.label = Somfy Screen
thing-type.somfytahoma.shutter.label = Somfy Shutter
thing-type.somfytahoma.siren.label = Somfy Siren
thing-type.somfytahoma.smokesensor.label = Somfy Smoke Sensor
thing-type.somfytahoma.temperaturesensor.label = Somfy Temperature Sensor

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="somfytahoma"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="shutter">
<supported-bridge-type-refs>
<bridge-type-ref id="bridge"/>
</supported-bridge-type-refs>
<label>Somfy Shutter</label>
<channels>
<channel id="control" typeId="control"></channel>
</channels>
<representation-property>url</representation-property>
<config-description-ref uri="thing-type:somfytahoma:device"/>
</thing-type>
</thing:thing-descriptions>