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

[somfytahoma] Add support for the dimmer light #8323

Merged
merged 3 commits into from Aug 22, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.somfytahoma/README.md
Expand Up @@ -22,6 +22,7 @@ home automation systems.
- pergolas (UP, DOWN, STOP control of a pergola). IO Homecontrol devices are allowed to set exact position of a pergola (0-100%)
- 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)
- light sensors (luminance value)
- occupancy sensors (OPEN/CLOSE contact)
- smoke sensors (OPEN/CLOSE contact, alarm check)
Expand All @@ -30,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)
- exterior heating systems (set heating level)
- alarms (both interior/external)
- pods
- docks (battery info, siren control)
Expand Down Expand Up @@ -74,6 +76,7 @@ Please see the example below.
| 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 |
| 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) |
Expand Down Expand Up @@ -107,6 +110,7 @@ Please see the example below.
| 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 |
| 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) |
Expand Down Expand Up @@ -159,6 +163,7 @@ Bridge somfytahoma:bridge:237dbae7 "Somfy Tahoma Bridge" [ email="my@email.com",
Thing electricitysensor 9998e6ff-c17e-40d7-a4b4-3e797eca5bf7 "Electricity sensor" [ url="io://0204-4510-8041/288702124" ]
Thing dock 1212f2e3-bcde-21dd-b3a6-13ef7abcd134 "Dock" [ url="io://0204-4510-8041/244402124" ]
Thing siren 1212f2e3-aeae-21dd-b3a6-13ef7abcd134 "Siren" [ url="io://0204-4510-8041/244405678" ]
Thing extheatingsystem 1212f2e3-aeae-21dd-b3a6-13ef7abcd155 "Ext heating system" [ url="io://0204-4510-8041/144405678" ]
}
```

Expand Down Expand Up @@ -186,6 +191,9 @@ Switch Rollers2DOWN "Rollers 2nd floor DOWN" {channel="somfytahoma:actiongroup:2
Switch TahomaZwaveSwitch "Switch" { channel="somfytahoma:onoff:237dbae7:095d6c49-9712-4220-a4c3-d3bb7a6cc5f0:switch" }
Switch TahomaLightSwitch "Light Switch" { channel="somfytahoma:light:237dbae7:1b8e7d29-bf1e-4ae1-9432-3dfef52ef14d:switch" }

Switch DimmerLightSwitch "Dimmer Light Switch" { channel="somfytahoma:dimmerlight:237dbae7:1b8e7d29-bf1e-4ae1-9432-3dfef52ef14e:switch" }
Dimmer DimmerLightIntensity "Dimmer Light intensity [%.1f]" {channel="somfytahoma:dimmerlight:237dbae7:1b8e7d29-bf1e-4ae1-9432-3dfef52ef14e:light_intensity"}

Number LightSensor "Light Sensor [%.1f lux]" { channel="somfytahoma:lightsensor:237dbae7:2c90808c3a0c193f013a743f2f660f12:luminance" }
Number:Energy EnergyConsumptionSensor "Energy Consumption [%.1f W]" { channel="somfytahoma:electricitysensor:237dbae7:9998e6ff-c17e-40d7-a4b4-3e797eca5bf7:energy_consumption" }

Expand All @@ -208,6 +216,8 @@ Switch DockLongBeep "Dock long beep" { somfytahoma:dock:237dbae7:1212f2e3-bcde-2
String SirenBattery "Siren battery [%s]" { somfytahoma:siren:237dbae7:1212f2e3-aeae-21dd-b3a6-13ef7abcd134:battery }
Switch SirenSwitch "Siren switch" { somfytahoma:siren:237dbae7:1212f2e3-aeae-21dd-b3a6-13ef7abcd134:onoff }
String SirenVolume "Siren volume [%s]" { somfytahoma:siren:237dbae7:1212f2e3-aeae-21dd-b3a6-13ef7abcd134:memorized_volume }

Dimmer HeatingLevel "Ext heating level [%.1f]" {channel="somfytahoma:exteriorheatingsystem:237dbae7:1212f2e3-aeae-21dd-b3a6-13ef7abcd155:heating_level"}
```

.sitemap file
Expand All @@ -224,6 +234,8 @@ Switch item=RollerShutterLiving
Slider item=RollerShutterLivingD
Switch item=TahomaZwaveSwitch
Switch item=TahomaLightSwitch
Switch item=DimmerLightSwitch
Slider item=DimmerLightIntensity
Text item=LightSensor
Text item=OccupancySensor
Text item=SmokeSensor
Expand All @@ -242,6 +254,7 @@ Switch item=DockLongBeep
String item=SirenBattery
Switch item=SirenSwitch
Selection item=SirenVolume mappings=["normal"="NORMAL", "highest"="HIGHEST"]
Slider item=HeatingLevel
```

## Alexa compatibility
Expand Down
Expand Up @@ -73,6 +73,9 @@ public class SomfyTahomaBindingConstants {
// Light
public static final ThingTypeUID THING_TYPE_LIGHT = new ThingTypeUID(BINDING_ID, "light");

// DimmerLight
public static final ThingTypeUID THING_TYPE_DIMMER_LIGHT = new ThingTypeUID(BINDING_ID, "dimmerlight");

// Light sensor
public static final ThingTypeUID THING_TYPE_LIGHTSENSOR = new ThingTypeUID(BINDING_ID, "lightsensor");

Expand Down Expand Up @@ -106,6 +109,8 @@ public class SomfyTahomaBindingConstants {
public static final ThingTypeUID THING_TYPE_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,
"exteriorheatingsystem");

// Door lock
public static final ThingTypeUID THING_TYPE_DOOR_LOCK = new ThingTypeUID(BINDING_ID, "doorlock");
Expand Down Expand Up @@ -169,6 +174,9 @@ public class SomfyTahomaBindingConstants {
// OnOff, Light
public static final String SWITCH = "switch";

// Dimmer Light
public static final String LIGHT_INTENSITY = "light_intensity";

// Door lock
public static final String LOCK = "lock";
public static final String OPEN = "open";
Expand Down Expand Up @@ -208,6 +216,7 @@ public class SomfyTahomaBindingConstants {
public static final String CURRENT_STATE = "current_state";
public static final String BATTERY_LEVEL = "battery_level";
public static final String TARGET_HEATING_LEVEL = "target_heating_level";
public static final String HEATING_LEVEL = "heating_level";

// Thermostat
public static final String HEATING_MODE = "heating_mode";
Expand Down Expand Up @@ -324,6 +333,7 @@ public class SomfyTahomaBindingConstants {
public static final String CLASS_ALARM = "Alarm";
public static final String CLASS_POD = "Pod";
public static final String CLASS_HEATING_SYSTEM = "HeatingSystem";
public static final String CLASS_EXTERIOR_HEATING_SYSTEM = "ExteriorHeatingSystem";
public static final String CLASS_DOOR_LOCK = "DoorLock";
public static final String CLASS_PERGOLA = "Pergola";
public static final String CLASS_WINDOW_HANDLE = "WindowHandle";
Expand Down Expand Up @@ -355,7 +365,8 @@ public class SomfyTahomaBindingConstants {
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_WATERSENSOR, THING_TYPE_HUMIDITYSENSOR, THING_TYPE_MYFOX_ALARM, THING_TYPE_THERMOSTAT,
THING_TYPE_DIMMER_LIGHT, THING_TYPE_EXTERIOR_HEATING_SYSTEM));

// somfy gateways
public static Map<Integer, String> gatewayTypes = new HashMap<Integer, String>() {
Expand Down
Expand Up @@ -30,40 +30,7 @@
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.eclipse.smarthome.io.net.http.HttpClientFactory;
import org.openhab.binding.somfytahoma.internal.discovery.SomfyTahomaItemDiscoveryService;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaActionGroupHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaAdjustableSlatsRollerShutterHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaAwningHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaBridgeHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaContactSensorHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaCurtainHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaDockHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaDoorLockHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaElectricitySensorHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaExternalAlarmHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaGateHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaGatewayHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaHeatingSystemHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaHumiditySensorHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaInternalAlarmHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaLightSensorHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaMyfoxAlarmHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaMyfoxCameraHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOccupancySensorHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOnOffHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOnOffHeatingSystemHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaPergolaHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaPodHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaRollerShutterHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSilentRollerShutterHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSirenHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSmokeSensorHandler;
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.SomfyTahomaVenetianBlindHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaWaterSensorHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaWindowHandleHandler;
import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaWindowHandler;
import org.openhab.binding.somfytahoma.internal.handler.*;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
Expand Down Expand Up @@ -131,6 +98,8 @@ protected ThingHandler createHandler(Thing thing) {
return new SomfyTahomaOnOffHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_LIGHT)) {
return new SomfyTahomaOnOffHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_DIMMER_LIGHT)) {
return new SomfyTahomaDimmerLightHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_LIGHTSENSOR)) {
return new SomfyTahomaLightSensorHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_SMOKESENSOR)) {
Expand All @@ -155,6 +124,8 @@ protected ThingHandler createHandler(Thing thing) {
return new SomfyTahomaHeatingSystemHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_ONOFF_HEATING_SYSTEM)) {
return new SomfyTahomaOnOffHeatingSystemHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_EXTERIOR_HEATING_SYSTEM)) {
return new SomfyTahomaExteriorHeatingSystemHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_DOOR_LOCK)) {
return new SomfyTahomaDoorLockHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_PERGOLA)) {
Expand Down
Expand Up @@ -142,6 +142,7 @@ private void discoverDevice(SomfyTahomaDevice device) {
logger.debug("url: {}", device.getDeviceURL());
switch (device.getUiClass()) {
case CLASS_AWNING:
// widget: PositionableHorizontalAwning
deviceDiscovered(device, THING_TYPE_AWNING);
break;
case CLASS_CONTACT_SENSOR:
Expand All @@ -163,9 +164,14 @@ private void discoverDevice(SomfyTahomaDevice device) {
deviceDiscovered(device, THING_TYPE_GARAGEDOOR);
break;
case CLASS_LIGHT:
// widget: TimedOnOffLight
// widget: StatefulOnOffLight
deviceDiscovered(device, THING_TYPE_LIGHT);
if ("DimmerLight".equals(device.getWidget())) {
// widget: DimmerLight
deviceDiscovered(device, THING_TYPE_DIMMER_LIGHT);
} else {
// widget: TimedOnOffLight
// widget: StatefulOnOffLight
deviceDiscovered(device, THING_TYPE_LIGHT);
}
break;
case CLASS_LIGHT_SENSOR:
deviceDiscovered(device, THING_TYPE_LIGHTSENSOR);
Expand Down Expand Up @@ -231,6 +237,14 @@ private void discoverDevice(SomfyTahomaDevice device) {
deviceDiscovered(device, THING_TYPE_HEATING_SYSTEM);
}
break;
case CLASS_EXTERIOR_HEATING_SYSTEM:
if ("DimmerExteriorHeating".equals(device.getWidget())) {
// widget: DimmerExteriorHeating
deviceDiscovered(device, THING_TYPE_EXTERIOR_HEATING_SYSTEM);
} else {
logUnsupportedDevice(device);
}
break;
case CLASS_HUMIDITY_SENSOR:
if (hasState(device, WATER_DETECTION_STATE)) {
deviceDiscovered(device, THING_TYPE_WATERSENSOR);
Expand Down
@@ -0,0 +1,52 @@
/**
* 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.LIGHT_INTENSITY;
import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.SWITCH;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.library.types.PercentType;
import org.eclipse.smarthome.core.thing.ChannelUID;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.types.Command;
import org.eclipse.smarthome.core.types.RefreshType;

/**
* The {@link SomfyTahomaDimmerLightHandler} is responsible for handling commands,
* which are sent to one of the channels of the dimmer light thing.
*
* @author Ondrej Pecta - Initial contribution
*/
@NonNullByDefault
public class SomfyTahomaDimmerLightHandler extends SomfyTahomaBaseThingHandler {

public SomfyTahomaDimmerLightHandler(Thing thing) {
super(thing);
stateNames.put(SWITCH, "core:OnOffState");
stateNames.put(LIGHT_INTENSITY, "core:LightIntensityState");
}

@Override
public void handleCommand(ChannelUID channelUID, Command command) {
super.handleCommand(channelUID, command);
if (command instanceof RefreshType) {
return;
} else if (SWITCH.equals(channelUID.getId()) && command instanceof OnOffType) {
sendCommand(command.toString().toLowerCase());
} else if (LIGHT_INTENSITY.equals(channelUID.getId())) {
sendCommand("setIntensity", "[" + toInteger(command) + "]");
}
}
}