[OmniLink] Use jomnilink for command numbers (#10273)

Signed-off-by: Ethan Dye <mrtops03@gmail.com>
This commit is contained in:
Ethan Dye 2021-03-03 15:04:38 -07:00 committed by GitHub
parent 3af0392724
commit 2939e8b84b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 79 additions and 266 deletions

View File

@ -18,7 +18,7 @@
<dependency>
<groupId>com.github.digitaldan</groupId>
<artifactId>jomnilink</artifactId>
<version>1.4.1</version>
<version>1.4.2</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -37,6 +37,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.Message;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
import com.digitaldan.jomnilinkII.MessageTypes.ObjectStatus;
import com.digitaldan.jomnilinkII.MessageTypes.properties.AudioZoneProperties;
import com.digitaldan.jomnilinkII.MessageTypes.statuses.ExtendedAudioZoneStatus;
@ -97,7 +98,7 @@ public class AudioZoneHandler extends AbstractOmnilinkStatusHandler<ExtendedAudi
switch (channelUID.getId()) {
case CHANNEL_AUDIO_ZONE_POWER:
if (command instanceof OnOffType) {
sendOmnilinkCommand(OmniLinkCmd.CMD_AUDIO_ZONE_SET_ON_MUTE.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_AUDIO_ZONE_SET_ON_AND_MUTE,
OnOffType.OFF.equals(command) ? 0 : 1, thingID);
} else {
logger.debug("Invalid command: {}, must be OnOffType", command);
@ -105,7 +106,7 @@ public class AudioZoneHandler extends AbstractOmnilinkStatusHandler<ExtendedAudi
break;
case CHANNEL_AUDIO_ZONE_MUTE:
if (command instanceof OnOffType) {
sendOmnilinkCommand(OmniLinkCmd.CMD_AUDIO_ZONE_SET_ON_MUTE.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_AUDIO_ZONE_SET_ON_AND_MUTE,
OnOffType.OFF.equals(command) ? 2 : 3, thingID);
} else {
logger.debug("Invalid command: {}, must be OnOffType", command);
@ -113,16 +114,16 @@ public class AudioZoneHandler extends AbstractOmnilinkStatusHandler<ExtendedAudi
break;
case CHANNEL_AUDIO_ZONE_VOLUME:
if (command instanceof PercentType) {
sendOmnilinkCommand(OmniLinkCmd.CMD_AUDIO_ZONE_SET_VOLUME.getNumber(),
((PercentType) command).intValue(), thingID);
sendOmnilinkCommand(CommandMessage.CMD_AUDIO_ZONE_SET_VOLUME, ((PercentType) command).intValue(),
thingID);
} else {
logger.debug("Invalid command: {}, must be PercentType", command);
}
break;
case CHANNEL_AUDIO_ZONE_SOURCE:
if (command instanceof DecimalType) {
sendOmnilinkCommand(OmniLinkCmd.CMD_AUDIO_ZONE_SET_SOURCE.getNumber(),
((DecimalType) command).intValue(), thingID);
sendOmnilinkCommand(CommandMessage.CMD_AUDIO_ZONE_SET_SOURCE, ((DecimalType) command).intValue(),
thingID);
} else {
logger.debug("Invalid command: {}, must be DecimalType", command);
}
@ -149,7 +150,7 @@ public class AudioZoneHandler extends AbstractOmnilinkStatusHandler<ExtendedAudi
Optional<AudioPlayer> audioPlayer = bridgeHandler.getAudioPlayer();
if (audioPlayer.isPresent()) {
AudioPlayer player = audioPlayer.get();
sendOmnilinkCommand(OmniLinkCmd.CMD_AUDIO_ZONE_SET_SOURCE.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_AUDIO_ZONE_SET_SOURCE,
PlayPauseType.PLAY.equals(command) ? player.getPlayCommand() : player.getPauseCommand(),
thingID);
} else {
@ -168,7 +169,7 @@ public class AudioZoneHandler extends AbstractOmnilinkStatusHandler<ExtendedAudi
Optional<AudioPlayer> audioPlayer = bridgeHandler.getAudioPlayer();
if (audioPlayer.isPresent()) {
AudioPlayer player = audioPlayer.get();
sendOmnilinkCommand(OmniLinkCmd.CMD_AUDIO_ZONE_SET_SOURCE.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_AUDIO_ZONE_SET_SOURCE,
NextPreviousType.NEXT.equals(command) ? player.getNextCommand() : player.getPreviousCommand(),
thingID);
} else {

View File

@ -31,6 +31,7 @@ import org.openhab.core.types.RefreshType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
import com.digitaldan.jomnilinkII.MessageTypes.properties.AreaProperties;
import com.digitaldan.jomnilinkII.MessageTypes.properties.ButtonProperties;
@ -97,7 +98,7 @@ public class ButtonHandler extends AbstractOmnilinkHandler {
switch (channelUID.getId()) {
case CHANNEL_BUTTON_PRESS:
if (command instanceof OnOffType) {
sendOmnilinkCommand(OmniLinkCmd.CMD_BUTTON.getNumber(), 0, thingID);
sendOmnilinkCommand(CommandMessage.CMD_BUTTON, 0, thingID);
updateChannels();
} else {
logger.debug("Invalid command: {}, must be OnOffType", command);

View File

@ -27,6 +27,8 @@ import org.openhab.core.types.UnDefType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
/**
* The {@link ConsoleHandler} defines some methods that are used to
* interface with an OmniLink Console. This by extension also defines the
@ -67,7 +69,7 @@ public class ConsoleHandler extends AbstractOmnilinkHandler {
switch (channelUID.getId()) {
case CHANNEL_CONSOLE_ENABLE_DISABLE_BEEPER:
if (command instanceof StringType) {
sendOmnilinkCommand(OmniLinkCmd.CMD_CONSOLE_ENABLE_DISABLE_BEEPER.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_CONSOLE_ENABLE_DISABLE_BEEPER,
((StringType) command).equals(StringType.valueOf("OFF")) ? 0 : 1, thingID);
} else {
logger.debug("Invalid command: {}, must be StringType", command);
@ -75,8 +77,7 @@ public class ConsoleHandler extends AbstractOmnilinkHandler {
break;
case CHANNEL_CONSOLE_BEEP:
if (command instanceof DecimalType) {
sendOmnilinkCommand(OmniLinkCmd.CMD_CONSOLE_BEEP.getNumber(), ((DecimalType) command).intValue(),
thingID);
sendOmnilinkCommand(CommandMessage.CMD_CONSOLE_BEEP, ((DecimalType) command).intValue(), thingID);
} else {
logger.debug("Invalid command: {}, must be DecimalType", command);
}

View File

@ -36,6 +36,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.Message;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
import com.digitaldan.jomnilinkII.MessageTypes.ObjectStatus;
import com.digitaldan.jomnilinkII.MessageTypes.properties.AreaProperties;
import com.digitaldan.jomnilinkII.MessageTypes.properties.AuxSensorProperties;
@ -112,12 +113,12 @@ public class HumiditySensorHandler extends AbstractOmnilinkStatusHandler<Extende
switch (channelUID.getId()) {
case CHANNEL_AUX_LOW_SETPOINT:
sendOmnilinkCommand(OmniLinkCmd.CMD_THERMO_SET_HEAT_LOW_POINT.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_THERMO_SET_HEAT_POINT,
TemperatureFormat.FAHRENHEIT.formatToOmni(((QuantityType<Dimensionless>) command).floatValue()),
thingID);
break;
case CHANNEL_AUX_HIGH_SETPOINT:
sendOmnilinkCommand(OmniLinkCmd.CMD_THERMO_SET_COOL_HIGH_POINT.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_THERMO_SET_COOL_POINT,
TemperatureFormat.FAHRENHEIT.formatToOmni(((QuantityType<Dimensionless>) command).floatValue()),
thingID);
break;

View File

@ -32,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.Message;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
import com.digitaldan.jomnilinkII.MessageTypes.ObjectStatus;
import com.digitaldan.jomnilinkII.MessageTypes.properties.AccessControlReaderProperties;
import com.digitaldan.jomnilinkII.MessageTypes.statuses.ExtendedAccessControlReaderLockStatus;
@ -92,8 +93,8 @@ public class LockHandler extends AbstractOmnilinkStatusHandler<ExtendedAccessCon
switch (channelUID.getId()) {
case CHANNEL_LOCK_SWITCH:
if (command instanceof OnOffType) {
sendOmnilinkCommand(OnOffType.OFF.equals(command) ? OmniLinkCmd.CMD_UNLOCK_DOOR.getNumber()
: OmniLinkCmd.CMD_LOCK_DOOR.getNumber(), 0, thingID);
sendOmnilinkCommand(OnOffType.OFF.equals(command) ? CommandMessage.CMD_UNLOCK_DOOR
: CommandMessage.CMD_LOCK_DOOR, 0, thingID);
} else {
logger.debug("Invalid command {}, must be OnOffType", command);
}

View File

@ -23,6 +23,8 @@ import org.openhab.binding.omnilink.internal.AreaAlarm;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
/**
* The {@link LuminaAreaHandler} defines some methods that are used to
* interface with an OmniLink Lumina Area. This by extension also defines the
@ -44,17 +46,17 @@ public class LuminaAreaHandler extends AbstractAreaHandler {
protected int getMode(ChannelUID channelUID) {
switch (channelUID.getId()) {
case CHANNEL_AREA_SECURITY_MODE_HOME:
return OmniLinkCmd.CMD_SECURITY_LUMINA_HOME_MODE.getNumber();
return CommandMessage.CMD_SECURITY_LUMINA_HOME_MODE;
case CHANNEL_AREA_SECURITY_MODE_SLEEP:
return OmniLinkCmd.CMD_SECURITY_LUMINA_SLEEP_MODE.getNumber();
return CommandMessage.CMD_SECURITY_LUMINA_SLEEP_MODE;
case CHANNEL_AREA_SECURITY_MODE_AWAY:
return OmniLinkCmd.CMD_SECURITY_LUMINA_AWAY_MODE.getNumber();
return CommandMessage.CMD_SECURITY_LUMINA_AWAY_MODE;
case CHANNEL_AREA_SECURITY_MODE_VACATION:
return OmniLinkCmd.CMD_SECURITY_LUMINA_VACATION_MODE.getNumber();
return CommandMessage.CMD_SECURITY_LUMINA_VACATION_MODE;
case CHANNEL_AREA_SECURITY_MODE_PARTY:
return OmniLinkCmd.CMD_SECURITY_LUMINA_PARTY_MODE.getNumber();
return CommandMessage.CMD_SECURITY_LUMINA_PARTY_MODE;
case CHANNEL_AREA_SECURITY_MODE_SPECIAL:
return OmniLinkCmd.CMD_SECURITY_LUMINA_SPECIAL_MODE.getNumber();
return CommandMessage.CMD_SECURITY_LUMINA_SPECIAL_MODE;
default:
throw new IllegalStateException("Unknown channel for area thing " + channelUID);
}

View File

@ -23,6 +23,8 @@ import org.openhab.binding.omnilink.internal.AreaAlarm;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
/**
* The {@link OmniAreaHandler} defines some methods that are used to
* interface with an OmniLink OmniPro Area. This by extension also defines the
@ -45,19 +47,19 @@ public class OmniAreaHandler extends AbstractAreaHandler {
protected int getMode(ChannelUID channelUID) {
switch (channelUID.getId()) {
case CHANNEL_AREA_SECURITY_MODE_DISARM:
return OmniLinkCmd.CMD_SECURITY_OMNI_DISARM.getNumber();
return CommandMessage.CMD_SECURITY_OMNI_DISARM;
case CHANNEL_AREA_SECURITY_MODE_DAY:
return OmniLinkCmd.CMD_SECURITY_OMNI_DAY_MODE.getNumber();
return CommandMessage.CMD_SECURITY_OMNI_DAY_MODE;
case CHANNEL_AREA_SECURITY_MODE_NIGHT:
return OmniLinkCmd.CMD_SECURITY_OMNI_NIGHT_MODE.getNumber();
return CommandMessage.CMD_SECURITY_OMNI_NIGHT_MODE;
case CHANNEL_AREA_SECURITY_MODE_AWAY:
return OmniLinkCmd.CMD_SECURITY_OMNI_AWAY_MODE.getNumber();
return CommandMessage.CMD_SECURITY_OMNI_AWAY_MODE;
case CHANNEL_AREA_SECURITY_MODE_VACATION:
return OmniLinkCmd.CMD_SECURITY_OMNI_VACATION_MODE.getNumber();
return CommandMessage.CMD_SECURITY_OMNI_VACATION_MODE;
case CHANNEL_AREA_SECURITY_MODE_DAY_INSTANT:
return OmniLinkCmd.CMD_SECURITY_OMNI_DAY_INSTANCE_MODE.getNumber();
return CommandMessage.CMD_SECURITY_OMNI_DAY_INSTANT_MODE;
case CHANNEL_AREA_SECURITY_MODE_NIGHT_DELAYED:
return OmniLinkCmd.CMD_SECURITY_OMNI_NIGHT_DELAYED_MODE.getNumber();
return CommandMessage.CMD_SECURITY_OMNI_NIGHT_DELAYED_MODE;
default:
throw new IllegalStateException("Unknown channel for area thing " + channelUID);
}

View File

@ -1,199 +0,0 @@
/**
* 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.omnilink.internal.handler;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
/**
* OmniLink commands
*
* @author Dan Cunningham - Initial contribution
* @author Ethan Dye - openHAB3 rewrite
* @since 1.5.0
*/
@NonNullByDefault
public enum OmniLinkCmd {
CMD_UNIT_OFF(0),
CMD_UNIT_ON(1),
CMD_UNIT_AREA_ALL_OFF(2),
CMD_UNIT_AREA_ALL_ON(3),
CMD_UNIT_PERCENT(9),
CMD_UNIT_LO9_LEVEL_HIGH7(101),
CMD_UNIT_DECREMENT_COUNTER(10),
CMD_UNIT_INCREMENT_COUNTER(11),
CMD_UNIT_SET_COUNTER(12),
CMD_UNIT_LO9_RAMP_HIGH7(13),
CMD_UNIT_LIGHTOLIER(14),
CMD_UNIT_UPB_REQ_STATUS(15),
CMD_UNIT_UNIT_DIM_STEP_1(17),
CMD_UNIT_UNIT_DIM_STEP_2(18),
CMD_UNIT_UNIT_DIM_STEP_3(19),
CMD_UNIT_UNIT_DIM_STEP_4(20),
CMD_UNIT_UNIT_DIM_STEP_5(21),
CMD_UNIT_UNIT_DIM_STEP_6(22),
CMD_UNIT_UNIT_DIM_STEP_7(23),
CMD_UNIT_UNIT_DIM_STEP_8(24),
CMD_UNIT_UNIT_DIM_STEP_9(25),
CMD_UNIT_UNIT_BRIGHTEN_STEP_1(33),
CMD_UNIT_UNIT_BRIGHTEN_STEP_2(34),
CMD_UNIT_UNIT_BRIGHTEN_STEP_3(35),
CMD_UNIT_UNIT_BRIGHTEN_STEP_4(36),
CMD_UNIT_UNIT_BRIGHTEN_STEP_5(37),
CMD_UNIT_UNIT_BRIGHTEN_STEP_6(38),
CMD_UNIT_UNIT_BRIGHTEN_STEP_7(39),
CMD_UNIT_UNIT_BRIGHTEN_STEP_8(40),
CMD_UNIT_UNIT_BRIGHTEN_STEP_9(41),
CMD_UNIT_UPB_LO9_BLINK_HIGH7(26),
CMD_UNIT_UPB_STOP_BLINK(27),
CMD_UNIT_UPB_LINK_OFF(28),
CMD_UNIT_UPB_LINK_ON(29),
CMD_UNIT_UPB_LINK_SET(30),
CMD_UNIT_CENTRALITE_SCENE_OFF(42),
CMD_UNIT_CENTRALITE_SCENE_ON(43),
CMD_UNIT_UPB_LED_OFF(44),
CMD_UNIT_UPB_LED_ON(45),
CMD_UNIT_RADIORA_PHANTOM_BUTTON_OFF(46),
CMD_UNIT_RADIORA_PHANTM_BUTTON_ON(46),
CMD_UNIT_LEVITON_SCENE_OFF(60),
CMD_UNIT_LEVITON_SCENE_ON(61),
CMD_UNIT_LEVITON_SCENE_SET(62),
CMD_SECURITY_OMNI_DISARM(48),
CMD_SECURITY_OMNI_DAY_MODE(49),
CMD_SECURITY_OMNI_NIGHT_MODE(50),
CMD_SECURITY_OMNI_AWAY_MODE(51),
CMD_SECURITY_OMNI_VACATION_MODE(52),
CMD_SECURITY_OMNI_DAY_INSTANCE_MODE(53),
CMD_SECURITY_OMNI_NIGHT_DELAYED_MODE(54),
CMD_SECURITY_BYPASS_ZONE(4),
CMD_SECURITY_RESTORE_ZONE(5),
CMD_SECURITY_RESTORE_ALL_ZONES(6),
CMD_SECURITY_LUMINA_HOME_MODE(49),
CMD_SECURITY_LUMINA_SLEEP_MODE(50),
CMD_SECURITY_LUMINA_AWAY_MODE(51),
CMD_SECURITY_LUMINA_VACATION_MODE(52),
CMD_SECURITY_LUMINA_PARTY_MODE(53),
CMD_SECURITY_LUMINA_SPECIAL_MODE(54),
CMD_BUTTON(7),
CMD_ENERGY_SAVER_OFF(64),
CMD_ENERGY_SAVER_ON(65),
CMD_THERMO_SET_HEAT_LOW_POINT(66),
CMD_THERMO_SET_COOL_HIGH_POINT(67),
CMD_THERMO_SET_SYSTEM_MODE(68),
CMD_THERMO_SET_FAN_MODE(69),
CMD_THERMO_SET_HOLD_MODE(70),
CMD_THERMO_RAISE_LOWER_HEAT(71),
CMD_THERMO_RAISE_LOWER_COOL(72),
CMD_THERMO_SET_HUMDIFY_POINT(73),
CMD_THERMO_SET_DEHUMIDIFY_POINT(74),
CMD_MESSAGE_SHOW_MESSAGE_WITH_BEEP_AND_LED(80),
CMD_MESSAGE_SHOW_MESSAGE_WITH_BEEP_OR_LED(86),
CMD_MESSAGE_LOG_MESSAGE(81),
CMD_MESSAGE_CLEAR_MESSAGE(82),
CMD_MESSAGE_SAY_MESSAGE(83),
CMD_MESSAGE_PHONE_AND_SAY_MESSAGE(84),
CMD_MESSAGE_SEND_MESSAGE_TO_SERIAL_PORT(85),
CMD_CONSOLE_ENABLE_DISABLE_BEEPER(102),
CMD_CONSOLE_BEEP(103),
CMD_LOCK_DOOR(105),
CMD_UNLOCK_DOOR(106),
CMD_AUDIO_ZONE_SET_ON_MUTE(112),
CMD_AUDIO_ZONE_SET_VOLUME(113),
CMD_AUDIO_ZONE_SET_SOURCE(114),
CMD_AUDIO_ZONE_SELECT_KEY(115),
SENSOR_UNIT_POWER(1001),
SENSOR_UNIT_LEVEL(1002),
SENSOR_UNIT_DISPLAY(1003),
SENSOR_THERMO_HEAT_POINTC(2001),
SENSOR_THERMO_HEAT_POINTF(2002),
SENSOR_THERMO_COOL_POINTC(2003),
SENSOR_THERMO_COOL_POINTF(2004),
SENSOR_THERMO_SYSTEM_MODE(2005),
SENSOR_THERMO_FAN_MODE(2006),
SENSOR_THERMO_HOLD_MODE(2007),
SENSOR_THERMO_TEMPC(2006),
SENSOR_THERMO_TEMPF(2007),
SENSOR_ZONE_STATUS_CURRENT(3001),
SENSOR_ZONE_STATUS_LATCHED(3002),
SENSOR_ZONE_STATUS_ARMING(3003),
SENSOR_AREA_STATUS_MODE(4001),
SENSOR_AREA_STATUS_ALARM(4002),
SENSOR_AREA_STATUS_EXIT_DELAY(4003),
SENSOR_AREA_STATUS_ENTRY_DELAY(4003),
SENSOR_AREA_EXIT_TIMER(4004),
SENSOR_AREA_ENTRY_TIMER(4005),
SENSOR_AUX_STATUS(5001),
SENSOR_AUX_CURRENTC(5002),
SENSOR_AUX_CURRENTF(5003),
SENSOR_AUX_LOWC(5004),
SENSOR_AUX_LOWF(5005),
SENSOR_AUX_HIGHC(5006),
SENSOR_AUX_HIGHF(5007),
SENSOR_AUDIOZONE_POWER(6001),
SENSOR_AUDIOZONE_SOURCE(6002),
SENSOR_AUDIOZONE_VOLUME(6003),
SENSOR_AUDIOZONE_MUTE(6004),
SENSOR_AUDIOZONE_TEXT(6005),
SENSOR_AUDIOZONE_TEXT_FIELD1(6006),
SENSOR_AUDIOZONE_TEXT_FIELD2(6007),
SENSOR_AUDIOZONE_TEXT_FIELD3(6008),
SENSOR_AUDIOSOURCE_TEXT(7001),
SENSOR_AUDIOSOURCE_TEXT_FIELD1(7002),
SENSOR_AUDIOSOURCE_TEXT_FIELD2(7003),
SENSOR_AUDIOSOURCE_TEXT_FIELD3(7004);
private int number;
OmniLinkCmd(int number) {
this.number = number;
}
public int getNumber() {
return number;
}
public static @Nullable OmniLinkCmd getCommand(String name) {
for (OmniLinkCmd command : OmniLinkCmd.values()) {
if (name.equals(command.toString())) {
return command;
}
}
return null;
}
public static @Nullable OmniLinkCmd getCommand(int ordinal) {
OmniLinkCmd[] values = OmniLinkCmd.values();
if (ordinal < values.length) {
return values[ordinal];
} else {
return null;
}
}
public static String toList() {
StringBuilder sb = new StringBuilder();
for (OmniLinkCmd command : OmniLinkCmd.values()) {
sb.append(command.toString()).append(",");
}
return sb.toString();
}
}

View File

@ -50,6 +50,7 @@ import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.Connection;
import com.digitaldan.jomnilinkII.DisconnectListener;
import com.digitaldan.jomnilinkII.Message;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
import com.digitaldan.jomnilinkII.MessageTypes.EventLogData;
import com.digitaldan.jomnilinkII.MessageTypes.ObjectStatus;
import com.digitaldan.jomnilinkII.MessageTypes.SecurityCodeValidation;
@ -194,7 +195,7 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
case CHANNEL_CONSOLE_ENABLE_DISABLE_BEEPER:
if (command instanceof StringType) {
try {
sendOmnilinkCommand(OmniLinkCmd.CMD_CONSOLE_ENABLE_DISABLE_BEEPER.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_CONSOLE_ENABLE_DISABLE_BEEPER,
((StringType) command).equals(StringType.valueOf("OFF")) ? 0 : 1, 0);
updateState(CHANNEL_CONSOLE_ENABLE_DISABLE_BEEPER, UnDefType.UNDEF);
} catch (NumberFormatException | OmniInvalidResponseException | OmniUnknownMessageTypeException
@ -208,8 +209,7 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
case CHANNEL_CONSOLE_BEEP:
if (command instanceof DecimalType) {
try {
sendOmnilinkCommand(OmniLinkCmd.CMD_CONSOLE_BEEP.getNumber(),
((DecimalType) command).intValue(), 0);
sendOmnilinkCommand(CommandMessage.CMD_CONSOLE_BEEP, ((DecimalType) command).intValue(), 0);
updateState(CHANNEL_CONSOLE_BEEP, UnDefType.UNDEF);
} catch (NumberFormatException | OmniInvalidResponseException | OmniUnknownMessageTypeException
| BridgeOfflineException e) {

View File

@ -37,6 +37,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.Message;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
import com.digitaldan.jomnilinkII.MessageTypes.ObjectStatus;
import com.digitaldan.jomnilinkII.MessageTypes.properties.AreaProperties;
import com.digitaldan.jomnilinkII.MessageTypes.properties.AuxSensorProperties;
@ -125,12 +126,12 @@ public class TempSensorHandler extends AbstractOmnilinkStatusHandler<ExtendedAux
switch (channelUID.getId()) {
case CHANNEL_AUX_LOW_SETPOINT:
sendOmnilinkCommand(OmniLinkCmd.CMD_THERMO_SET_HEAT_LOW_POINT.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_THERMO_SET_HEAT_POINT,
temperatureFormat.get().formatToOmni(((QuantityType<Temperature>) command).floatValue()),
thingID);
break;
case CHANNEL_AUX_HIGH_SETPOINT:
sendOmnilinkCommand(OmniLinkCmd.CMD_THERMO_SET_COOL_HIGH_POINT.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_THERMO_SET_COOL_POINT,
temperatureFormat.get().formatToOmni(((QuantityType<Temperature>) command).floatValue()),
thingID);
break;

View File

@ -42,6 +42,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.Message;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
import com.digitaldan.jomnilinkII.MessageTypes.ObjectStatus;
import com.digitaldan.jomnilinkII.MessageTypes.properties.AreaProperties;
import com.digitaldan.jomnilinkII.MessageTypes.properties.ThermostatProperties;
@ -144,34 +145,34 @@ public class ThermostatHandler extends AbstractOmnilinkStatusHandler<ExtendedThe
switch (channelUID.getId()) {
case CHANNEL_THERMO_SYSTEM_MODE:
sendOmnilinkCommand(OmniLinkCmd.CMD_THERMO_SET_SYSTEM_MODE.getNumber(),
((DecimalType) command).intValue(), thingID);
sendOmnilinkCommand(CommandMessage.CMD_THERMO_SET_SYSTEM_MODE, ((DecimalType) command).intValue(),
thingID);
break;
case CHANNEL_THERMO_FAN_MODE:
sendOmnilinkCommand(OmniLinkCmd.CMD_THERMO_SET_FAN_MODE.getNumber(), ((DecimalType) command).intValue(),
sendOmnilinkCommand(CommandMessage.CMD_THERMO_SET_FAN_MODE, ((DecimalType) command).intValue(),
thingID);
break;
case CHANNEL_THERMO_HOLD_STATUS:
sendOmnilinkCommand(OmniLinkCmd.CMD_THERMO_SET_HOLD_MODE.getNumber(),
((DecimalType) command).intValue(), thingID);
sendOmnilinkCommand(CommandMessage.CMD_THERMO_SET_HOLD_MODE, ((DecimalType) command).intValue(),
thingID);
break;
case CHANNEL_THERMO_HEAT_SETPOINT:
sendOmnilinkCommand(OmniLinkCmd.CMD_THERMO_SET_HEAT_LOW_POINT.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_THERMO_SET_HEAT_POINT,
temperatureFormat.get().formatToOmni(((QuantityType<Temperature>) command).floatValue()),
thingID);
break;
case CHANNEL_THERMO_COOL_SETPOINT:
sendOmnilinkCommand(OmniLinkCmd.CMD_THERMO_SET_COOL_HIGH_POINT.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_THERMO_SET_COOL_POINT,
temperatureFormat.get().formatToOmni(((QuantityType<Temperature>) command).floatValue()),
thingID);
break;
case CHANNEL_THERMO_HUMIDIFY_SETPOINT:
sendOmnilinkCommand(OmniLinkCmd.CMD_THERMO_SET_HUMDIFY_POINT.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_THERMO_SET_HUMDIFY_POINT,
TemperatureFormat.FAHRENHEIT.formatToOmni(((QuantityType<Dimensionless>) command).floatValue()),
thingID);
break;
case CHANNEL_THERMO_DEHUMIDIFY_SETPOINT:
sendOmnilinkCommand(OmniLinkCmd.CMD_THERMO_SET_DEHUMIDIFY_POINT.getNumber(),
sendOmnilinkCommand(CommandMessage.CMD_THERMO_SET_DEHUMIDIFY_POINT,
TemperatureFormat.FAHRENHEIT.formatToOmni(((QuantityType<Dimensionless>) command).floatValue()),
thingID);
break;

View File

@ -35,6 +35,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.Message;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
import com.digitaldan.jomnilinkII.MessageTypes.ObjectStatus;
import com.digitaldan.jomnilinkII.MessageTypes.properties.AreaProperties;
import com.digitaldan.jomnilinkII.MessageTypes.properties.UnitProperties;
@ -144,15 +145,14 @@ public class UnitHandler extends AbstractOmnilinkStatusHandler<ExtendedUnitStatu
return;
}
sendOmnilinkCommand(
channelID.startsWith("on") ? OmniLinkCmd.CMD_UNIT_ON.getNumber() : OmniLinkCmd.CMD_UNIT_OFF.getNumber(),
sendOmnilinkCommand(channelID.startsWith("on") ? CommandMessage.CMD_UNIT_ON : CommandMessage.CMD_UNIT_OFF,
duration, thingID);
}
protected void handleOnOff(ChannelUID channelUID, OnOffType command) {
logger.debug("handleOnOff called for channel: {}, command: {}", channelUID, command);
sendOmnilinkCommand(OnOffType.ON.equals(command) ? OmniLinkCmd.CMD_UNIT_ON.getNumber()
: OmniLinkCmd.CMD_UNIT_OFF.getNumber(), 0, thingID);
sendOmnilinkCommand(OnOffType.ON.equals(command) ? CommandMessage.CMD_UNIT_ON : CommandMessage.CMD_UNIT_OFF, 0,
thingID);
}
@Override

View File

@ -38,6 +38,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.Message;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
import com.digitaldan.jomnilinkII.MessageTypes.ObjectStatus;
import com.digitaldan.jomnilinkII.MessageTypes.SecurityCodeValidation;
import com.digitaldan.jomnilinkII.MessageTypes.properties.AreaProperties;
@ -115,10 +116,10 @@ public class ZoneHandler extends AbstractOmnilinkStatusHandler<ExtendedZoneStatu
switch (channelUID.getId()) {
case CHANNEL_ZONE_BYPASS:
mode = OmniLinkCmd.CMD_SECURITY_BYPASS_ZONE.getNumber();
mode = CommandMessage.CMD_SECURITY_BYPASS_ZONE;
break;
case CHANNEL_ZONE_RESTORE:
mode = OmniLinkCmd.CMD_SECURITY_RESTORE_ZONE.getNumber();
mode = CommandMessage.CMD_SECURITY_RESTORE_ZONE;
break;
default:
mode = -1;

View File

@ -16,7 +16,6 @@ import static org.openhab.binding.omnilink.internal.OmnilinkBindingConstants.CHA
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.omnilink.internal.handler.OmniLinkCmd;
import org.openhab.binding.omnilink.internal.handler.UnitHandler;
import org.openhab.core.library.types.IncreaseDecreaseType;
import org.openhab.core.library.types.OnOffType;
@ -27,6 +26,8 @@ import org.openhab.core.types.Command;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
/**
* The {@link DimmableUnitHandler} defines some methods that are used to
* interface with an OmniLink Dimmable Unit. This by extension also defines the
@ -79,15 +80,13 @@ public class DimmableUnitHandler extends UnitHandler {
} else if (lightLevel == 100) {
super.handleOnOff(channelUID, OnOffType.ON);
} else {
sendOmnilinkCommand(OmniLinkCmd.CMD_UNIT_PERCENT.getNumber(), lightLevel, thingID);
sendOmnilinkCommand(CommandMessage.CMD_UNIT_PERCENT, lightLevel, thingID);
}
}
private void handleIncreaseDecrease(ChannelUID channelUID, IncreaseDecreaseType command) {
logger.debug("handleIncreaseDecrease called for channel: {}, command: {}", channelUID, command);
sendOmnilinkCommand(
IncreaseDecreaseType.INCREASE.equals(command) ? OmniLinkCmd.CMD_UNIT_UNIT_BRIGHTEN_STEP_1.getNumber()
: OmniLinkCmd.CMD_UNIT_UNIT_DIM_STEP_1.getNumber(),
0, thingID);
sendOmnilinkCommand(IncreaseDecreaseType.INCREASE.equals(command) ? CommandMessage.CMD_UNIT_UPB_BRIGHTEN_STEP_1
: CommandMessage.CMD_UNIT_UPB_DIM_STEP_1, 0, thingID);
}
}

View File

@ -16,7 +16,6 @@ import static org.openhab.binding.omnilink.internal.OmnilinkBindingConstants.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.omnilink.internal.handler.OmniLinkCmd;
import org.openhab.binding.omnilink.internal.handler.UnitHandler;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
@ -29,6 +28,7 @@ import org.openhab.core.types.RefreshType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
import com.digitaldan.jomnilinkII.MessageTypes.statuses.ExtendedUnitStatus;
/**
@ -62,8 +62,8 @@ public class FlagHandler extends UnitHandler {
switch (channelUID.getId()) {
case CHANNEL_FLAG_VALUE:
if (command instanceof DecimalType) {
sendOmnilinkCommand(OmniLinkCmd.CMD_UNIT_SET_COUNTER.getNumber(),
((DecimalType) command).intValue(), thingID);
sendOmnilinkCommand(CommandMessage.CMD_UNIT_SET_COUNTER, ((DecimalType) command).intValue(),
thingID);
} else {
logger.debug("Invalid command: {}, must be DecimalType", command);
}

View File

@ -16,7 +16,6 @@ import static org.openhab.binding.omnilink.internal.OmnilinkBindingConstants.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.omnilink.internal.handler.OmniLinkCmd;
import org.openhab.binding.omnilink.internal.handler.UnitHandler;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
@ -29,6 +28,7 @@ import org.openhab.core.types.RefreshType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
import com.digitaldan.jomnilinkII.MessageTypes.statuses.ExtendedUnitStatus;
/**
@ -113,8 +113,8 @@ public class UpbRoomHandler extends UnitHandler {
}
int roomNum = (thingID + 7) / 8;
int param2 = ((roomNum * 6) - 3) + linkNum;
sendOmnilinkCommand(OnOffType.ON.equals(command) ? OmniLinkCmd.CMD_UNIT_UPB_LINK_ON.getNumber()
: OmniLinkCmd.CMD_UNIT_UPB_LINK_OFF.getNumber(), 0, param2);
sendOmnilinkCommand(OnOffType.ON.equals(command) ? CommandMessage.CMD_UNIT_UPB_LINK_ON
: CommandMessage.CMD_UNIT_UPB_LINK_OFF, 0, param2);
}
private void handleRoomState(ChannelUID channelUID, DecimalType command) {
@ -125,18 +125,18 @@ public class UpbRoomHandler extends UnitHandler {
switch (cmdValue) {
case 0:
cmd = OmniLinkCmd.CMD_UNIT_OFF.getNumber();
cmd = CommandMessage.CMD_UNIT_OFF;
param2 = thingID;
break;
case 1:
cmd = OmniLinkCmd.CMD_UNIT_ON.getNumber();
cmd = CommandMessage.CMD_UNIT_ON;
param2 = thingID;
break;
case 2:
case 3:
case 4:
case 5:
cmd = OmniLinkCmd.CMD_UNIT_UPB_LINK_ON.getNumber();
cmd = CommandMessage.CMD_UNIT_UPB_LINK_ON;
/*
* A little magic with the link #'s: 0 and 1 are off and on, respectively.
* So A ends up being 2, but OmniLink Protocol expects an offset of 0. That

View File

@ -16,7 +16,6 @@ import static org.openhab.binding.omnilink.internal.OmnilinkBindingConstants.CHA
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.omnilink.internal.handler.OmniLinkCmd;
import org.openhab.binding.omnilink.internal.handler.units.DimmableUnitHandler;
import org.openhab.core.library.types.StringType;
import org.openhab.core.thing.ChannelUID;
@ -27,6 +26,8 @@ import org.openhab.core.types.UnDefType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.digitaldan.jomnilinkII.MessageTypes.CommandMessage;
/**
* The {@link UpbUnitHandler} defines some methods that are used to
* interface with an OmniLink UPB Unit. This by extension also defines the
@ -57,7 +58,7 @@ public class UpbUnitHandler extends DimmableUnitHandler {
switch (channelUID.getId()) {
case CHANNEL_UPB_STATUS:
if (command instanceof StringType) {
sendOmnilinkCommand(OmniLinkCmd.CMD_UNIT_UPB_REQ_STATUS.getNumber(), 0, thingID);
sendOmnilinkCommand(CommandMessage.CMD_UNIT_UPB_REQ_STATUS, 0, thingID);
updateState(CHANNEL_UPB_STATUS, UnDefType.UNDEF);
} else {
logger.debug("Invalid command: {}, must be StringType", command);