[deconz] Added channel to enable / disable motion sensor (#9686)

* Added channel to enable / disable motion sensor

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2021-01-09 22:53:23 +01:00 committed by GitHub
parent ef87af3712
commit 382ce10a0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 173 additions and 113 deletions

View File

@ -120,37 +120,38 @@ Bridge deconz:deconz:homeserver [ host="192.168.0.10", apikey="ABCDEFGHIJ" ]
The sensor devices support some of the following channels: The sensor devices support some of the following channels:
| Channel Type ID | Item Type | Access Mode | Description | Thing types | | Channel Type ID | Item Type | Access Mode | Description | Thing types |
|-----------------|--------------------------|:-----------:|-------------------------------------------------------------------------------------------|----------------------------------------------| |-----------------|--------------------------|-------------|-------------------------------------------------------------------------------------------|---------------------------------------------------|
| presence | Switch | R | Status of presence: `ON` = presence; `OFF` = no-presence | presencesensor | | presence | Switch | R | Status of presence: `ON` = presence; `OFF` = no-presence | presencesensor |
| last_updated | DateTime | R | Timestamp when the sensor was last updated | all, except daylightsensor | | enabled | Switch | R/W | This channel activates or deactivates the sensor | presencesensor |
| last_seen | DateTime | R | Timestamp when the sensor was last seen | all, except daylightsensor | | last_updated | DateTime | R | Timestamp when the sensor was last updated | all, except daylightsensor |
| power | Number:Power | R | Current power usage in Watts | powersensor, sometimes for consumptionsensor | | last_seen | DateTime | R | Timestamp when the sensor was last seen | all, except daylightsensor |
| consumption | Number:Energy | R | Current power usage in Watts/Hour | consumptionsensor | | power | Number:Power | R | Current power usage in Watts | powersensor, sometimes for consumptionsensor |
| voltage | Number:ElectricPotential | R | Current voltage in V | some powersensors | | consumption | Number:Energy | R | Current power usage in Watts/Hour | consumptionsensor |
| current | Number:ElectricCurrent | R | Current current in mA | some powersensors | | voltage | Number:ElectricPotential | R | Current voltage in V | some powersensors |
| button | Number | R | Last pressed button id on a switch | switch, colorcontrol | | current | Number:ElectricCurrent | R | Current current in mA | some powersensors |
| gesture | Number | R | A gesture that was performed with the switch | switch | | button | Number | R | Last pressed button id on a switch | switch, colorcontrol |
| lightlux | Number:Illuminance | R | Current light illuminance in Lux | lightsensor | | gesture | Number | R | A gesture that was performed with the switch | switch |
| light_level | Number | R | Current light level | lightsensor | | lightlux | Number:Illuminance | R | Current light illuminance in Lux | lightsensor |
| dark | Switch | R | Light level is below the darkness threshold | lightsensor, sometimes for presencesensor | | light_level | Number | R | Current light level | lightsensor |
| daylight | Switch | R | Light level is above the daylight threshold | lightsensor | | dark | Switch | R | Light level is below the darkness threshold | lightsensor, sometimes for presencesensor |
| temperature | Number:Temperature | R | Current temperature in ˚C | temperaturesensor, some Xiaomi sensors,thermostat| | daylight | Switch | R | Light level is above the daylight threshold | lightsensor |
| humidity | Number:Dimensionless | R | Current humidity in % | humiditysensor | | temperature | Number:Temperature | R | Current temperature in ˚C | temperaturesensor, some Xiaomi sensors,thermostat |
| pressure | Number:Pressure | R | Current pressure in hPa | pressuresensor | | humidity | Number:Dimensionless | R | Current humidity in % | humiditysensor |
| open | Contact | R | Status of contacts: `OPEN`; `CLOSED` | openclosesensor | | pressure | Number:Pressure | R | Current pressure in hPa | pressuresensor |
| waterleakage | Switch | R | Status of water leakage: `ON` = water leakage detected; `OFF` = no water leakage detected | waterleakagesensor | | open | Contact | R | Status of contacts: `OPEN`; `CLOSED` | openclosesensor |
| fire | Switch | R | Status of a fire: `ON` = fire was detected; `OFF` = no fire detected | firesensor | | waterleakage | Switch | R | Status of water leakage: `ON` = water leakage detected; `OFF` = no water leakage detected | waterleakagesensor |
| alarm | Switch | R | Status of an alarm: `ON` = alarm was triggered; `OFF` = no alarm | alarmsensor | | fire | Switch | R | Status of a fire: `ON` = fire was detected; `OFF` = no fire detected | firesensor |
| tampered | Switch | R | Status of a zone: `ON` = zone is being tampered; `OFF` = zone is not tampered | any IAS sensor | | alarm | Switch | R | Status of an alarm: `ON` = alarm was triggered; `OFF` = no alarm | alarmsensor |
| vibration | Switch | R | Status of vibration: `ON` = vibration was detected; `OFF` = no vibration | alarmsensor | | tampered | Switch | R | Status of a zone: `ON` = zone is being tampered; `OFF` = zone is not tampered | any IAS sensor |
| light | String | R | Light level: `Daylight`; `Sunset`; `Dark` | daylightsensor | | vibration | Switch | R | Status of vibration: `ON` = vibration was detected; `OFF` = no vibration | alarmsensor |
| value | Number | R | Sun position: `130` = dawn; `140` = sunrise; `190` = sunset; `210` = dusk | daylightsensor | | light | String | R | Light level: `Daylight`; `Sunset`; `Dark` | daylightsensor |
| battery_level | Number | R | Battery level (in %) | any battery-powered sensor | | value | Number | R | Sun position: `130` = dawn; `140` = sunrise; `190` = sunset; `210` = dusk | daylightsensor |
| battery_low | Switch | R | Battery level low: `ON`; `OFF` | any battery-powered sensor | | battery_level | Number | R | Battery level (in %) | any battery-powered sensor |
| carbonmonoxide | Switch | R | `ON` = carbon monoxide detected | carbonmonoxide | | battery_low | Switch | R | Battery level low: `ON`; `OFF` | any battery-powered sensor |
| color | Color | R | Color set by remote | colorcontrol | | carbonmonoxide | Switch | R | `ON` = carbon monoxide detected | carbonmonoxide |
| windowopen | Contact | R | `windowopen` status is reported by some thermostats | thermostat | | color | Color | R | Color set by remote | colorcontrol |
| windowopen | Contact | R | `windowopen` status is reported by some thermostats | thermostat |
**NOTE:** Beside other non mandatory channels, the `battery_level` and `battery_low` channels will be added to the Thing during runtime if the sensor is battery-powered. **NOTE:** Beside other non mandatory channels, the `battery_level` and `battery_low` channels will be added to the Thing during runtime if the sensor is battery-powered.
The specification of your sensor depends on the deCONZ capabilities. The specification of your sensor depends on the deCONZ capabilities.

View File

@ -70,6 +70,7 @@ public class BindingConstants {
// sensor channel ids // sensor channel ids
public static final String CHANNEL_PRESENCE = "presence"; public static final String CHANNEL_PRESENCE = "presence";
public static final String CHANNEL_ENABLED = "enabled";
public static final String CHANNEL_LAST_UPDATED = "last_updated"; public static final String CHANNEL_LAST_UPDATED = "last_updated";
public static final String CHANNEL_LAST_SEEN = "last_seen"; public static final String CHANNEL_LAST_SEEN = "last_seen";
public static final String CHANNEL_POWER = "power"; public static final String CHANNEL_POWER = "power";

View File

@ -39,6 +39,6 @@ public class SensorConfig {
@Override @Override
public String toString() { public String toString() {
return "SensorConfig{" + "on=" + on + ", reachable=" + reachable + ", battery=" + battery + ", temperature=" return "SensorConfig{" + "on=" + on + ", reachable=" + reachable + ", battery=" + battery + ", temperature="
+ temperature + ", heatsetpoint=" + heatsetpoint + ", mode=" + mode + ", offset=" + offset + '}'; + temperature + ", heatsetpoint=" + heatsetpoint + ", mode=" + mode + ", offset=" + offset + "}";
} }
} }

View File

@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2021 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.deconz.internal.dto;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
/**
* The {@link SensorUpdateConfig} is send to the Rest API to configure presence sensors.
*
* @author Christoph Weitkamp - Initial contribution
*/
@NonNullByDefault
public class SensorUpdateConfig {
public @Nullable Boolean on;
}

View File

@ -17,12 +17,12 @@ import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.deconz.internal.types.ThermostatMode; import org.openhab.binding.deconz.internal.types.ThermostatMode;
/** /**
* The {@link ThermostatConfig} is send to the Rest API to configure Thermostat. * The {@link ThermostatUpdateConfig} is send to the Rest API to configure Thermostat.
* *
* @author Lukas Agethen - Initial contribution * @author Lukas Agethen - Initial contribution
*/ */
@NonNullByDefault @NonNullByDefault
public class ThermostatConfig { public class ThermostatUpdateConfig {
public @Nullable Integer heatsetpoint; public @Nullable Integer heatsetpoint;
public @Nullable ThermostatMode mode; public @Nullable ThermostatMode mode;
public @Nullable Integer offset; public @Nullable Integer offset;

View File

@ -24,7 +24,12 @@ import org.openhab.binding.deconz.internal.dto.DeconzBaseMessage;
import org.openhab.binding.deconz.internal.netutils.WebSocketConnection; import org.openhab.binding.deconz.internal.netutils.WebSocketConnection;
import org.openhab.binding.deconz.internal.netutils.WebSocketMessageListener; import org.openhab.binding.deconz.internal.netutils.WebSocketMessageListener;
import org.openhab.binding.deconz.internal.types.ResourceType; import org.openhab.binding.deconz.internal.types.ResourceType;
import org.openhab.core.thing.*; import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.thing.ThingStatusInfo;
import org.openhab.core.thing.binding.BaseThingHandler; import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.types.Command; import org.openhab.core.types.Command;
import org.slf4j.Logger; import org.slf4j.Logger;

View File

@ -121,17 +121,14 @@ public abstract class SensorBaseThingHandler extends DeconzBaseThingHandler {
return; return;
} }
if (!sensorConfig.on) {
updateStatus(ThingStatus.OFFLINE);
return;
}
Map<String, String> editProperties = editProperties(); Map<String, String> editProperties = editProperties();
editProperties.put(UNIQUE_ID, sensorMessage.uniqueid); editProperties.put(UNIQUE_ID, sensorMessage.uniqueid);
editProperties.put(Thing.PROPERTY_FIRMWARE_VERSION, sensorMessage.swversion); editProperties.put(Thing.PROPERTY_FIRMWARE_VERSION, sensorMessage.swversion);
editProperties.put(Thing.PROPERTY_VENDOR, sensorMessage.manufacturername); editProperties.put(Thing.PROPERTY_VENDOR, sensorMessage.manufacturername);
editProperties.put(Thing.PROPERTY_MODEL_ID, sensorMessage.modelid); editProperties.put(Thing.PROPERTY_MODEL_ID, sensorMessage.modelid);
ignoreConfigurationUpdate = true; ignoreConfigurationUpdate = true;
updateProperties(editProperties); updateProperties(editProperties);
// Some sensors support optional channels // Some sensors support optional channels
@ -228,16 +225,16 @@ public abstract class SensorBaseThingHandler extends DeconzBaseThingHandler {
/** /**
* Update channel value from {@link SensorState} object - override to include further channels * Update channel value from {@link SensorState} object - override to include further channels
* *
* @param channelID * @param channelUID
* @param newState * @param newState
* @param initializing * @param initializing
*/ */
protected void valueUpdated(String channelID, SensorState newState, boolean initializing) { protected void valueUpdated(ChannelUID channelUID, SensorState newState, boolean initializing) {
switch (channelID) { switch (channelUID.getId()) {
case CHANNEL_LAST_UPDATED: case CHANNEL_LAST_UPDATED:
String lastUpdated = newState.lastupdated; String lastUpdated = newState.lastupdated;
if (lastUpdated != null && !"none".equals(lastUpdated)) { if (lastUpdated != null && !"none".equals(lastUpdated)) {
updateState(channelID, Util.convertTimestampToDateTime(lastUpdated)); updateState(channelUID, Util.convertTimestampToDateTime(lastUpdated));
} }
break; break;
default: default:
@ -271,31 +268,32 @@ public abstract class SensorBaseThingHandler extends DeconzBaseThingHandler {
protected void updateChannels(SensorState newState, boolean initializing) { protected void updateChannels(SensorState newState, boolean initializing) {
sensorState = newState; sensorState = newState;
thing.getChannels().forEach(channel -> valueUpdated(channel.getUID().getId(), newState, initializing)); thing.getChannels().forEach(channel -> valueUpdated(channel.getUID(), newState, initializing));
} }
protected void updateSwitchChannel(String channelID, @Nullable Boolean value) { protected void updateSwitchChannel(ChannelUID channelUID, @Nullable Boolean value) {
if (value == null) { if (value == null) {
return; return;
} }
updateState(channelID, OnOffType.from(value)); updateState(channelUID, OnOffType.from(value));
} }
protected void updateDecimalTypeChannel(String channelID, @Nullable Number value) { protected void updateDecimalTypeChannel(ChannelUID channelUID, @Nullable Number value) {
if (value == null) { if (value == null) {
return; return;
} }
updateState(channelID, new DecimalType(value.longValue())); updateState(channelUID, new DecimalType(value.longValue()));
} }
protected void updateQuantityTypeChannel(String channelID, @Nullable Number value, Unit<?> unit) { protected void updateQuantityTypeChannel(ChannelUID channelUID, @Nullable Number value, Unit<?> unit) {
updateQuantityTypeChannel(channelID, value, unit, 1.0); updateQuantityTypeChannel(channelUID, value, unit, 1.0);
} }
protected void updateQuantityTypeChannel(String channelID, @Nullable Number value, Unit<?> unit, double scaling) { protected void updateQuantityTypeChannel(ChannelUID channelUID, @Nullable Number value, Unit<?> unit,
double scaling) {
if (value == null) { if (value == null) {
return; return;
} }
updateState(channelID, new QuantityType<>(value.doubleValue() * scaling, unit)); updateState(channelUID, new QuantityType<>(value.doubleValue() * scaling, unit));
} }
} }

View File

@ -26,7 +26,11 @@ import javax.measure.quantity.Temperature;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.deconz.internal.dto.*; import org.openhab.binding.deconz.internal.dto.DeconzBaseMessage;
import org.openhab.binding.deconz.internal.dto.SensorConfig;
import org.openhab.binding.deconz.internal.dto.SensorMessage;
import org.openhab.binding.deconz.internal.dto.SensorState;
import org.openhab.binding.deconz.internal.dto.ThermostatUpdateConfig;
import org.openhab.binding.deconz.internal.types.ThermostatMode; import org.openhab.binding.deconz.internal.types.ThermostatMode;
import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OpenClosedType; import org.openhab.core.library.types.OpenClosedType;
@ -76,12 +80,11 @@ public class SensorThermostatThingHandler extends SensorBaseThingHandler {
public void handleCommand(ChannelUID channelUID, Command command) { public void handleCommand(ChannelUID channelUID, Command command) {
if (command instanceof RefreshType) { if (command instanceof RefreshType) {
sensorState.buttonevent = null; sensorState.buttonevent = null;
valueUpdated(channelUID.getId(), sensorState, false); valueUpdated(channelUID, sensorState, false);
return; return;
} }
ThermostatConfig newConfig = new ThermostatConfig(); ThermostatUpdateConfig newConfig = new ThermostatUpdateConfig();
String channelId = channelUID.getId(); switch (channelUID.getId()) {
switch (channelId) {
case CHANNEL_HEATSETPOINT: case CHANNEL_HEATSETPOINT:
Integer newHeatsetpoint = getTemperatureFromCommand(command); Integer newHeatsetpoint = getTemperatureFromCommand(command);
if (newHeatsetpoint == null) { if (newHeatsetpoint == null) {
@ -131,13 +134,12 @@ public class SensorThermostatThingHandler extends SensorBaseThingHandler {
super.valueUpdated(channelUID, newConfig); super.valueUpdated(channelUID, newConfig);
ThermostatMode thermostatMode = newConfig.mode; ThermostatMode thermostatMode = newConfig.mode;
String mode = thermostatMode != null ? thermostatMode.name() : ThermostatMode.UNKNOWN.name(); String mode = thermostatMode != null ? thermostatMode.name() : ThermostatMode.UNKNOWN.name();
String channelID = channelUID.getId(); switch (channelUID.getId()) {
switch (channelID) {
case CHANNEL_HEATSETPOINT: case CHANNEL_HEATSETPOINT:
updateQuantityTypeChannel(channelID, newConfig.heatsetpoint, CELSIUS, 1.0 / 100); updateQuantityTypeChannel(channelUID, newConfig.heatsetpoint, CELSIUS, 1.0 / 100);
break; break;
case CHANNEL_TEMPERATURE_OFFSET: case CHANNEL_TEMPERATURE_OFFSET:
updateQuantityTypeChannel(channelID, newConfig.offset, CELSIUS, 1.0 / 100); updateQuantityTypeChannel(channelUID, newConfig.offset, CELSIUS, 1.0 / 100);
break; break;
case CHANNEL_THERMOSTAT_MODE: case CHANNEL_THERMOSTAT_MODE:
updateState(channelUID, new StringType(mode)); updateState(channelUID, new StringType(mode));
@ -146,19 +148,19 @@ public class SensorThermostatThingHandler extends SensorBaseThingHandler {
} }
@Override @Override
protected void valueUpdated(String channelID, SensorState newState, boolean initializing) { protected void valueUpdated(ChannelUID channelUID, SensorState newState, boolean initializing) {
super.valueUpdated(channelID, newState, initializing); super.valueUpdated(channelUID, newState, initializing);
switch (channelID) { switch (channelUID.getId()) {
case CHANNEL_TEMPERATURE: case CHANNEL_TEMPERATURE:
updateQuantityTypeChannel(channelID, newState.temperature, CELSIUS, 1.0 / 100); updateQuantityTypeChannel(channelUID, newState.temperature, CELSIUS, 1.0 / 100);
break; break;
case CHANNEL_VALVE_POSITION: case CHANNEL_VALVE_POSITION:
updateQuantityTypeChannel(channelID, newState.valve, PERCENT, 100.0 / 255); updateQuantityTypeChannel(channelUID, newState.valve, PERCENT, 100.0 / 255);
break; break;
case CHANNEL_WINDOWOPEN: case CHANNEL_WINDOWOPEN:
String open = newState.windowopen; String open = newState.windowopen;
if (open != null) { if (open != null) {
updateState(channelID, "Closed".equals(open) ? OpenClosedType.CLOSED : OpenClosedType.OPEN); updateState(channelUID, "Closed".equals(open) ? OpenClosedType.CLOSED : OpenClosedType.OPEN);
} }
break; break;
} }

View File

@ -17,14 +17,16 @@ import static org.openhab.core.library.unit.MetricPrefix.*;
import static org.openhab.core.library.unit.SIUnits.*; import static org.openhab.core.library.unit.SIUnits.*;
import static org.openhab.core.library.unit.Units.*; import static org.openhab.core.library.unit.Units.*;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.deconz.internal.dto.*; import org.openhab.binding.deconz.internal.dto.SensorConfig;
import org.openhab.binding.deconz.internal.dto.SensorState;
import org.openhab.binding.deconz.internal.dto.SensorUpdateConfig;
import org.openhab.core.library.types.HSBType; import org.openhab.core.library.types.HSBType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType; import org.openhab.core.library.types.OpenClosedType;
import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType; import org.openhab.core.library.types.StringType;
@ -60,8 +62,8 @@ public class SensorThingHandler extends SensorBaseThingHandler {
THING_TYPE_ALARM_SENSOR, THING_TYPE_VIBRATION_SENSOR, THING_TYPE_BATTERY_SENSOR, THING_TYPE_ALARM_SENSOR, THING_TYPE_VIBRATION_SENSOR, THING_TYPE_BATTERY_SENSOR,
THING_TYPE_CARBONMONOXIDE_SENSOR, THING_TYPE_COLOR_CONTROL); THING_TYPE_CARBONMONOXIDE_SENSOR, THING_TYPE_COLOR_CONTROL);
private static final List<String> CONFIG_CHANNELS = Arrays.asList(CHANNEL_BATTERY_LEVEL, CHANNEL_BATTERY_LOW, private static final List<String> CONFIG_CHANNELS = List.of(CHANNEL_BATTERY_LEVEL, CHANNEL_BATTERY_LOW,
CHANNEL_TEMPERATURE); CHANNEL_ENABLED, CHANNEL_TEMPERATURE);
public SensorThingHandler(Thing thing, Gson gson) { public SensorThingHandler(Thing thing, Gson gson) {
super(thing, gson); super(thing, gson);
@ -69,21 +71,31 @@ public class SensorThingHandler extends SensorBaseThingHandler {
@Override @Override
public void handleCommand(ChannelUID channelUID, Command command) { public void handleCommand(ChannelUID channelUID, Command command) {
if (!(command instanceof RefreshType)) { if (command instanceof RefreshType) {
sensorState.buttonevent = null;
valueUpdated(channelUID, sensorState, false);
return; return;
} }
switch (channelUID.getId()) {
sensorState.buttonevent = null; case CHANNEL_ENABLED:
valueUpdated(channelUID.getId(), sensorState, false); if (command instanceof OnOffType) {
SensorUpdateConfig newConfig = new SensorUpdateConfig();
newConfig.on = OnOffType.ON.equals(command);
sendCommand(newConfig, command, channelUID, null);
}
break;
}
} }
@Override @Override
protected void valueUpdated(ChannelUID channelUID, SensorConfig newConfig) { protected void valueUpdated(ChannelUID channelUID, SensorConfig newConfig) {
super.valueUpdated(channelUID, newConfig); super.valueUpdated(channelUID, newConfig);
Float temperature = newConfig.temperature;
switch (channelUID.getId()) { switch (channelUID.getId()) {
case CHANNEL_ENABLED:
updateState(channelUID, OnOffType.from(newConfig.on));
break;
case CHANNEL_TEMPERATURE: case CHANNEL_TEMPERATURE:
Float temperature = newConfig.temperature;
if (temperature != null) { if (temperature != null) {
updateState(channelUID, new QuantityType<>(temperature / 100, CELSIUS)); updateState(channelUID, new QuantityType<>(temperature / 100, CELSIUS));
} }
@ -92,114 +104,114 @@ public class SensorThingHandler extends SensorBaseThingHandler {
} }
@Override @Override
protected void valueUpdated(String channelID, SensorState newState, boolean initializing) { protected void valueUpdated(ChannelUID channelUID, SensorState newState, boolean initializing) {
super.valueUpdated(channelID, newState, initializing); super.valueUpdated(channelUID, newState, initializing);
switch (channelID) { switch (channelUID.getId()) {
case CHANNEL_BATTERY_LEVEL: case CHANNEL_BATTERY_LEVEL:
updateDecimalTypeChannel(channelID, newState.battery); updateDecimalTypeChannel(channelUID, newState.battery);
break; break;
case CHANNEL_LIGHT: case CHANNEL_LIGHT:
Boolean dark = newState.dark; Boolean dark = newState.dark;
if (dark != null) { if (dark != null) {
Boolean daylight = newState.daylight; Boolean daylight = newState.daylight;
if (dark) { // if it's dark, it's dark ;) if (dark) { // if it's dark, it's dark ;)
updateState(channelID, new StringType("Dark")); updateState(channelUID, new StringType("Dark"));
} else if (daylight != null) { // if its not dark, it might be between darkness and daylight } else if (daylight != null) { // if its not dark, it might be between darkness and daylight
if (daylight) { if (daylight) {
updateState(channelID, new StringType("Daylight")); updateState(channelUID, new StringType("Daylight"));
} else { } else {
updateState(channelID, new StringType("Sunset")); updateState(channelUID, new StringType("Sunset"));
} }
} else { // if no daylight value is known, we assume !dark means daylight } else { // if no daylight value is known, we assume !dark means daylight
updateState(channelID, new StringType("Daylight")); updateState(channelUID, new StringType("Daylight"));
} }
} }
break; break;
case CHANNEL_POWER: case CHANNEL_POWER:
updateQuantityTypeChannel(channelID, newState.power, WATT); updateQuantityTypeChannel(channelUID, newState.power, WATT);
break; break;
case CHANNEL_CONSUMPTION: case CHANNEL_CONSUMPTION:
updateQuantityTypeChannel(channelID, newState.consumption, WATT_HOUR); updateQuantityTypeChannel(channelUID, newState.consumption, WATT_HOUR);
break; break;
case CHANNEL_VOLTAGE: case CHANNEL_VOLTAGE:
updateQuantityTypeChannel(channelID, newState.voltage, VOLT); updateQuantityTypeChannel(channelUID, newState.voltage, VOLT);
break; break;
case CHANNEL_CURRENT: case CHANNEL_CURRENT:
updateQuantityTypeChannel(channelID, newState.current, MILLI(AMPERE)); updateQuantityTypeChannel(channelUID, newState.current, MILLI(AMPERE));
break; break;
case CHANNEL_LIGHT_LUX: case CHANNEL_LIGHT_LUX:
updateQuantityTypeChannel(channelID, newState.lux, LUX); updateQuantityTypeChannel(channelUID, newState.lux, LUX);
break; break;
case CHANNEL_COLOR: case CHANNEL_COLOR:
final double @Nullable [] xy = newState.xy; final double @Nullable [] xy = newState.xy;
if (xy != null && xy.length == 2) { if (xy != null && xy.length == 2) {
updateState(channelID, HSBType.fromXY((float) xy[0], (float) xy[1])); updateState(channelUID, HSBType.fromXY((float) xy[0], (float) xy[1]));
} }
break; break;
case CHANNEL_LIGHT_LEVEL: case CHANNEL_LIGHT_LEVEL:
updateDecimalTypeChannel(channelID, newState.lightlevel); updateDecimalTypeChannel(channelUID, newState.lightlevel);
break; break;
case CHANNEL_DARK: case CHANNEL_DARK:
updateSwitchChannel(channelID, newState.dark); updateSwitchChannel(channelUID, newState.dark);
break; break;
case CHANNEL_DAYLIGHT: case CHANNEL_DAYLIGHT:
updateSwitchChannel(channelID, newState.daylight); updateSwitchChannel(channelUID, newState.daylight);
break; break;
case CHANNEL_TEMPERATURE: case CHANNEL_TEMPERATURE:
updateQuantityTypeChannel(channelID, newState.temperature, CELSIUS, 1.0 / 100); updateQuantityTypeChannel(channelUID, newState.temperature, CELSIUS, 1.0 / 100);
break; break;
case CHANNEL_HUMIDITY: case CHANNEL_HUMIDITY:
updateQuantityTypeChannel(channelID, newState.humidity, PERCENT, 1.0 / 100); updateQuantityTypeChannel(channelUID, newState.humidity, PERCENT, 1.0 / 100);
break; break;
case CHANNEL_PRESSURE: case CHANNEL_PRESSURE:
updateQuantityTypeChannel(channelID, newState.pressure, HECTO(PASCAL)); updateQuantityTypeChannel(channelUID, newState.pressure, HECTO(PASCAL));
break; break;
case CHANNEL_PRESENCE: case CHANNEL_PRESENCE:
updateSwitchChannel(channelID, newState.presence); updateSwitchChannel(channelUID, newState.presence);
break; break;
case CHANNEL_VALUE: case CHANNEL_VALUE:
updateDecimalTypeChannel(channelID, newState.status); updateDecimalTypeChannel(channelUID, newState.status);
break; break;
case CHANNEL_OPENCLOSE: case CHANNEL_OPENCLOSE:
Boolean open = newState.open; Boolean open = newState.open;
if (open != null) { if (open != null) {
updateState(channelID, open ? OpenClosedType.OPEN : OpenClosedType.CLOSED); updateState(channelUID, open ? OpenClosedType.OPEN : OpenClosedType.CLOSED);
} }
break; break;
case CHANNEL_WATERLEAKAGE: case CHANNEL_WATERLEAKAGE:
updateSwitchChannel(channelID, newState.water); updateSwitchChannel(channelUID, newState.water);
break; break;
case CHANNEL_FIRE: case CHANNEL_FIRE:
updateSwitchChannel(channelID, newState.fire); updateSwitchChannel(channelUID, newState.fire);
break; break;
case CHANNEL_ALARM: case CHANNEL_ALARM:
updateSwitchChannel(channelID, newState.alarm); updateSwitchChannel(channelUID, newState.alarm);
break; break;
case CHANNEL_TAMPERED: case CHANNEL_TAMPERED:
updateSwitchChannel(channelID, newState.tampered); updateSwitchChannel(channelUID, newState.tampered);
break; break;
case CHANNEL_VIBRATION: case CHANNEL_VIBRATION:
updateSwitchChannel(channelID, newState.vibration); updateSwitchChannel(channelUID, newState.vibration);
break; break;
case CHANNEL_CARBONMONOXIDE: case CHANNEL_CARBONMONOXIDE:
updateSwitchChannel(channelID, newState.carbonmonoxide); updateSwitchChannel(channelUID, newState.carbonmonoxide);
break; break;
case CHANNEL_BUTTON: case CHANNEL_BUTTON:
updateDecimalTypeChannel(channelID, newState.buttonevent); updateDecimalTypeChannel(channelUID, newState.buttonevent);
break; break;
case CHANNEL_BUTTONEVENT: case CHANNEL_BUTTONEVENT:
Integer buttonevent = newState.buttonevent; Integer buttonevent = newState.buttonevent;
if (buttonevent != null && !initializing) { if (buttonevent != null && !initializing) {
triggerChannel(channelID, String.valueOf(buttonevent)); triggerChannel(channelUID, String.valueOf(buttonevent));
} }
break; break;
case CHANNEL_GESTURE: case CHANNEL_GESTURE:
updateDecimalTypeChannel(channelID, newState.gesture); updateDecimalTypeChannel(channelUID, newState.gesture);
break; break;
case CHANNEL_GESTUREEVENT: case CHANNEL_GESTUREEVENT:
Integer gesture = newState.gesture; Integer gesture = newState.gesture;
if (gesture != null && !initializing) { if (gesture != null && !initializing) {
triggerChannel(channelID, String.valueOf(gesture)); triggerChannel(channelUID, String.valueOf(gesture));
} }
break; break;
} }

View File

@ -41,8 +41,8 @@
</parameter> </parameter>
<parameter name="lastSeenPolling" type="integer" min="0" unit="min"> <parameter name="lastSeenPolling" type="integer" min="0" unit="min">
<label>LastSeen Poll Interval</label> <label>LastSeen Poll Interval</label>
<description>Interval to poll the deCONZ Gateway for this sensor's "lastSeen" channel. Polling is disabled when set <description>Interval to poll the deCONZ Gateway for this sensor's "last_seen" channel. Polling is disabled when set
to 1440 (once per day).</description> to 0 (default: 1440, once per day).</description>
<default>1440</default> <default>1440</default>
</parameter> </parameter>
</config-description> </config-description>

View File

@ -2,3 +2,17 @@
binding.deconz.name = Dresden Elektronik deCONZ Binding binding.deconz.name = Dresden Elektronik deCONZ Binding
binding.deconz.description = Unterstützt die Raspbee und Conbee Zigbee Dongles via deCONZ binding.deconz.description = Unterstützt die Raspbee und Conbee Zigbee Dongles via deCONZ
thing-type.deconz.presencesensor.label = Bewegungsmelder
thing-type.deconz.presencesensor.description = Bewegungsmelder mit einstellbarer Sensitivität.
thing-type.config.deconz.sensor.id.label = ID des Sensors
thing-type.config.deconz.sensor.id.description = ID zur Identifikation des Sensors.
thing-type.config.deconz.sensor.lastSeenPolling.label = Abfrageintervall
thing-type.config.deconz.sensor.lastSeenPolling.description = Intervall zur Abfrage des deCONZ-Gateways nach dem "last_seen" Channel dieses Sensors. Polling wird deaktiviert, wenn der Wert auf 0 eingestellt wird (Standard: 1440, einmal pro Tag).
channel-type.deconz.last_updated.label = Letzte Aktualisierung
channel-type.deconz.last_updated.description = Zeit, zu der sich dieser Wert geändert hat.
channel-type.deconz.last_updated.options.pattern = %1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS
channel-type.deconz.last_seen.label = Zuletzt Gesehen
channel-type.deconz.last_seen.description = Zeit, zu der sich dieser Wert geändert hat.
channel-type.deconz.last_seen.options.pattern = %1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS

View File

@ -13,6 +13,7 @@
<channels> <channels>
<channel typeId="system.motion" id="presence"/> <channel typeId="system.motion" id="presence"/>
<channel typeId="last_updated" id="last_updated"/> <channel typeId="last_updated" id="last_updated"/>
<channel typeId="system.power" id="enabled"/>
</channels> </channels>
<representation-property>uid</representation-property> <representation-property>uid</representation-property>