mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[somfytahoma] add support for the Up/Down Venetian Blind thing (#17583)
Signed-off-by: Ondrej Pecta <opecta@gmail.com>
This commit is contained in:
parent
1c649d88b6
commit
ec998ac4bb
@ -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) |
|
||||
|
@ -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<Integer, String> gatewayTypes = new HashMap<>() {
|
||||
|
@ -55,6 +55,7 @@ import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSmokeSensorHa
|
||||
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 @@ public class SomfyTahomaHandlerFactory extends BaseThingHandlerFactory {
|
||||
} 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)) {
|
||||
|
@ -208,6 +208,9 @@ public class SomfyTahomaItemDiscoveryService extends AbstractThingHandlerDiscove
|
||||
// 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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -885,4 +885,11 @@
|
||||
</state>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="tilt">
|
||||
<item-type>Number</item-type>
|
||||
<label>Tilt</label>
|
||||
<description>Venetian blind tilt (-5..5)</description>
|
||||
<state min="-5" max="5" step="1" pattern="%d" readOnly="false"/>
|
||||
</channel-type>
|
||||
|
||||
</thing:thing-descriptions>
|
||||
|
@ -0,0 +1,20 @@
|
||||
<?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="updownvenetianblind">
|
||||
<supported-bridge-type-refs>
|
||||
<bridge-type-ref id="bridge"/>
|
||||
</supported-bridge-type-refs>
|
||||
<label>Somfy Up/Down Venetian Blind</label>
|
||||
<channels>
|
||||
<channel id="control" typeId="control"></channel>
|
||||
<channel id="tilt" typeId="tilt"></channel>
|
||||
</channels>
|
||||
<representation-property>url</representation-property>
|
||||
<config-description-ref uri="thing-type:somfytahoma:device"/>
|
||||
</thing-type>
|
||||
|
||||
</thing:thing-descriptions>
|
Loading…
Reference in New Issue
Block a user