| effect | String | R/W | Effect selection. Allowed commands are set dynamically | `colorlight` |
| effectSpeed | Number | W | Effect Speed | `colorlight` |
| lock | Switch | R/W | Lock (ON) or unlock (OFF) the doorlock| `doorlock` |
+| ontime | Number:Time | W | Timespan for which the light is turned on | all lights |
| position | Rollershutter | R/W | Position of the blind | `windowcovering` |
| heatsetpoint | Number:Temperature | R/W | Target Temperature in °C | `thermostat` |
| valve | Number:Dimensionless | R | Valve position in % | `thermostat` |
public static final String CHANNEL_EFFECT = "effect";
public static final String CHANNEL_EFFECT_SPEED = "effectSpeed";
public static final String CHANNEL_SCENE = "scene";
+ public static final String CHANNEL_ONTIME = "ontime";
// channel uids
public static final ChannelTypeUID CHANNEL_EFFECT_TYPE_UID = new ChannelTypeUID(BINDING_ID, CHANNEL_EFFECT);
public @Nullable String colormode;
public @Nullable String effect;
public @Nullable Integer effectSpeed;
+ public @Nullable Integer ontime;
// depending on the type of light
public @Nullable Integer hue;
colormode = null;
effect = null;
effectSpeed = null;
+ ontime = null;
hue = null;
sat = null;
public String toString() {
return "LightState{" + "reachable=" + reachable + ", on=" + on + ", bri=" + bri + ", alert='" + alert + '\''
+ ", colormode='" + colormode + '\'' + ", effect='" + effect + '\'' + ", effectSpeed=" + effectSpeed
- + ", hue=" + hue + ", sat=" + sat + ", ct=" + ct + ", xy=" + Arrays.toString(xy) + ", transitiontime="
- + transitiontime + '}';
+ + ", ontime=" + ontime + ", hue=" + hue + ", sat=" + sat + ", ct=" + ct + ", xy=" + Arrays.toString(xy)
+ + ", transitiontime=" + transitiontime + '}';
}
}
import org.openhab.binding.deconz.internal.dto.LightState;
import org.openhab.binding.deconz.internal.types.ResourceType;
import org.openhab.core.library.types.*;
+import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
*/
private LightState lightStateCache = new LightState();
private LightState lastCommand = new LightState();
+ private int onTime = 0; // in 0.1s
private String colorMode = "";
// set defaults, we can override them later if we receive better values
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
+ if (channelUID.getId().equals(CHANNEL_ONTIME)) {
+ if (command instanceof QuantityType<?>) {
+ QuantityType<?> onTimeSeconds = ((QuantityType<?>) command).toUnit(Units.SECOND);
+ if (onTimeSeconds != null) {
+ onTime = 10 * onTimeSeconds.intValue();
+ } else {
+ logger.warn("Channel '{}' received command '{}', could not be converted to seconds.", channelUID,
+ command);
+ }
+ }
+ return;
+ }
+
if (command instanceof RefreshType) {
valueUpdated(channelUID.getId(), lightStateCache);
return;
// if light shall be off, no other commands are allowed, so reset the new light state
newLightState.clear();
newLightState.on = false;
+ } else if (newOn != null && newOn) {
+ newLightState.ontime = onTime;
}
sendCommand(newLightState, command, channelUID, () -> {
<description>A light that can be turned on or off.</description>
<channels>
<channel typeId="onoff" id="switch"/>
+ <channel typeId="ontime" id="ontime"/>
</channels>
<representation-property>uid</representation-property>
<category>Lightbulb</category>
<channels>
<channel typeId="brightness" id="brightness"/>
+ <channel typeId="ontime" id="ontime"/>
<channel id="alert" typeId="alert"></channel>
</channels>
<channels>
<channel typeId="brightness" id="brightness"/>
<channel typeId="ct" id="color_temperature"/>
+ <channel typeId="ontime" id="ontime"/>
<channel id="alert" typeId="alert"></channel>
</channels>
<category>Lightbulb</category>
<channels>
<channel typeId="color" id="color"/>
+ <channel typeId="ontime" id="ontime"/>
<channel id="alert" typeId="alert"></channel>
</channels>
<channels>
<channel typeId="color" id="color"/>
<channel typeId="ct" id="color_temperature"/>
+ <channel typeId="ontime" id="ontime"/>
<channel id="alert" typeId="alert"></channel>
</channels>
<state pattern="%d K" min="15" max="100000" step="100"/>
</channel-type>
+ <channel-type id="ontime">
+ <item-type>Number:Time</item-type>
+ <label>On Time</label>
+ <description>Time that the light stays on before switched off automatically (0=forever)</description>
+ </channel-type>
+
<channel-type id="effect">
<item-type>String</item-type>
<label>Effect Channel</label>