[deconz] support for thermostat windowopen (#9306)
* add support for windowopen in thermostats * fix documentation Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
parent
f5e16ae5f8
commit
dca815b73f
|
@ -146,6 +146,7 @@ The sensor devices support some of the following channels:
|
|||
| battery_low | Switch | R | Battery level low: `ON`; `OFF` | any battery-powered sensor |
|
||||
| carbonmonoxide | Switch | R | `ON` = carbon monoxide detected | carbonmonoxide |
|
||||
| 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.
|
||||
The specification of your sensor depends on the deCONZ capabilities.
|
||||
|
|
|
@ -102,6 +102,7 @@ public class BindingConstants {
|
|||
public static final String CHANNEL_THERMOSTAT_MODE = "mode";
|
||||
public static final String CHANNEL_TEMPERATURE_OFFSET = "offset";
|
||||
public static final String CHANNEL_VALVE_POSITION = "valve";
|
||||
public static final String CHANNEL_WINDOWOPEN = "windowopen";
|
||||
|
||||
// group + light channel ids
|
||||
public static final String CHANNEL_SWITCH = "switch";
|
||||
|
|
|
@ -76,6 +76,8 @@ public class SensorState {
|
|||
public @Nullable Integer gesture;
|
||||
/** Thermostat may provide this value. */
|
||||
public @Nullable Integer valve;
|
||||
/** Thermostats may provide this value */
|
||||
public @Nullable String windowopen;
|
||||
/** deCONZ sends a last update string with every event. */
|
||||
public @Nullable String lastupdated;
|
||||
/** color controllers send xy values */
|
||||
|
@ -89,7 +91,7 @@ public class SensorState {
|
|||
+ ", carbonmonoxide=" + carbonmonoxide + ", pressure=" + pressure + ", presence=" + presence
|
||||
+ ", power=" + power + ", battery=" + battery + ", consumption=" + consumption + ", voltage=" + voltage
|
||||
+ ", current=" + current + ", status=" + status + ", buttonevent=" + buttonevent + ", gesture="
|
||||
+ gesture + ", valve=" + valve + ", lastupdated='" + lastupdated + '\'' + ", xy=" + Arrays.toString(xy)
|
||||
+ '}';
|
||||
+ gesture + ", valve=" + valve + ", windowopen='" + windowopen + '\'' + ", lastupdated='" + lastupdated
|
||||
+ '\'' + ", xy=" + Arrays.toString(xy) + '}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,16 +26,18 @@ import javax.measure.quantity.Temperature;
|
|||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.deconz.internal.dto.SensorConfig;
|
||||
import org.openhab.binding.deconz.internal.dto.SensorState;
|
||||
import org.openhab.binding.deconz.internal.dto.ThermostatConfig;
|
||||
import org.openhab.binding.deconz.internal.dto.*;
|
||||
import org.openhab.binding.deconz.internal.types.ThermostatMode;
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
import org.openhab.core.library.types.OpenClosedType;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.types.StringType;
|
||||
import org.openhab.core.thing.ChannelUID;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
import org.openhab.core.thing.binding.builder.ChannelBuilder;
|
||||
import org.openhab.core.thing.binding.builder.ThingBuilder;
|
||||
import org.openhab.core.thing.type.ChannelTypeUID;
|
||||
import org.openhab.core.types.Command;
|
||||
import org.openhab.core.types.RefreshType;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -153,6 +155,12 @@ public class SensorThermostatThingHandler extends SensorBaseThingHandler {
|
|||
case CHANNEL_VALVE_POSITION:
|
||||
updateQuantityTypeChannel(channelID, newState.valve, PERCENT, 100.0 / 255);
|
||||
break;
|
||||
case CHANNEL_WINDOWOPEN:
|
||||
String open = newState.windowopen;
|
||||
if (open != null) {
|
||||
updateState(channelID, "Closed".equals(open) ? OpenClosedType.CLOSED : OpenClosedType.OPEN);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,4 +190,21 @@ public class SensorThermostatThingHandler extends SensorBaseThingHandler {
|
|||
}
|
||||
return newTemperature.scaleByPowerOfTen(2).intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processStateResponse(DeconzBaseMessage stateResponse) {
|
||||
if (!(stateResponse instanceof SensorMessage)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SensorMessage sensorMessage = (SensorMessage) stateResponse;
|
||||
if (sensorMessage.state.windowopen != null && thing.getChannel(CHANNEL_WINDOWOPEN) == null) {
|
||||
ThingBuilder thingBuilder = editThing();
|
||||
thingBuilder.withChannel(ChannelBuilder.create(new ChannelUID(thing.getUID(), CHANNEL_WINDOWOPEN), "String")
|
||||
.withType(new ChannelTypeUID(BINDING_ID, "open")).build());
|
||||
updateThing(thingBuilder.build());
|
||||
}
|
||||
|
||||
super.processStateResponse(stateResponse);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue