By definition the DimmerItem accepts the following data types and commands:
acceptedDataTypes.add(OnOffType.class);
acceptedDataTypes.add(PercentType.class);
acceptedDataTypes.add(UnDefType.class);
Hi @rossko57,
Yes, we are currently creating an openHAB binding. We have a Dimmer device, and we want to create a channel that supports all types of commands
You can just check for the type of the incoming command, and handle it as appropriate. Here is a simplified example:
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if (channelUID.getId().equals(CHANNEL_LIGHTLEVEL)) {
if (command instanceof Number) {
int level = ((Number) command).intValue();
// Send the percent level to your dimmer
} else if (command.equals(OnOffType.ON)) {
// Send on command to your dimmer
} else if (command.equals(OnOffType.OFF)) {
// Send off command to your dimmer
}
}
}
For a full example check out the DimmerHandler class in the Lutron binding: