Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ public boolean isSet(BigInteger alarmBits) {
return alarmBits.testBit(bit);
}

public boolean isSet(int alarmBits) {
return isSet(BigInteger.valueOf(alarmBits));
}

public String getChannelUID() {
return channelUID;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ public class OmnilinkBindingConstants {
public static final String TRIGGER_CHANNEL_DCM_EVENT = "dcm_event";
public static final String TRIGGER_CHANNEL_ENERGY_COST_EVENT = "energy_cost_event";
public static final String TRIGGER_CHANNEL_CAMERA_TRIGGER_EVENT = "camera_trigger_event";
public static final String TRIGGER_CHANNEL_ACCESS_CONTROL_READER_EVENT = "access_control_reader_event";
public static final String TRIGGER_CHANNEL_AREA_ALL_ON_OFF_EVENT = "all_on_off_event";
public static final String TRIGGER_CHANNEL_SWITCH_PRESS_EVENT = "switch_press_event";
public static final String TRIGGER_CHANNEL_UPB_LINK_ACTIVATED_EVENT = "upb_link_activated_event";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public int formatToOmni(float fahrenheit) {

private final int formatNumber;

private TemperatureFormat(int formatNumber) {
TemperatureFormat(int formatNumber) {
this.formatNumber = formatNumber;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,8 @@ public void synchronizeControllerTime(
zdt = ZonedDateTime.now(ZoneId.of(zone));
} else {
logger.debug("Time zone provided invalid, using system default!");
if (timeZoneProvider.isPresent()) {
zdt = ZonedDateTime.now(timeZoneProvider.get().getTimeZone());
} else {
zdt = ZonedDateTime.now(ZoneId.systemDefault());
}
zdt = timeZoneProvider.map(zoneProvider -> ZonedDateTime.now(zoneProvider.getTimeZone()))
.orElseGet(() -> ZonedDateTime.now(ZoneId.systemDefault()));
}
actionsHandler.synchronizeControllerTime(zdt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ protected synchronized void stopScan() {
}

/**
* Calculate the area filter the a supplied area
* Calculate the area filter of a supplied area
*
* @param area Area to calculate filter for.
* @param areaProperties Area to calculate filter for.
* @return Calculated Bit Filter for the supplied area. Bit 0 is area 1, bit 2 is area 2 and so on.
*/
private static int bitFilterForArea(AreaProperties areaProperties) {
Expand Down Expand Up @@ -328,7 +328,7 @@ private void discoverThermostats() {
/**
* Discovers OmniLink areas
*/
private @Nullable List<AreaProperties> discoverAreas() {
private List<AreaProperties> discoverAreas() {
final ThingUID bridgeUID = thingHandler.getThing().getUID();
List<AreaProperties> areas = new LinkedList<>();

Expand Down Expand Up @@ -356,22 +356,18 @@ private void discoverThermostats() {

final String name = thingName;
systemType.ifPresentOrElse(t -> {
ThingUID thingUID = null;
switch (t) {
case LUMINA:
thingUID = new ThingUID(THING_TYPE_LUMINA_AREA, bridgeUID, thingID);
break;
default:
thingUID = new ThingUID(THING_TYPE_OMNI_AREA, bridgeUID, thingID);
ThingUID thingUID;
if (t == SystemType.LUMINA) {
thingUID = new ThingUID(THING_TYPE_LUMINA_AREA, bridgeUID, thingID);
} else {
thingUID = new ThingUID(THING_TYPE_OMNI_AREA, bridgeUID, thingID);
}
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
.withProperty(THING_PROPERTIES_NUMBER, thingID)
.withRepresentationProperty(THING_PROPERTIES_NUMBER).withBridge(bridgeUID).withLabel(name)
.build();
thingDiscovered(discoveryResult);
}, () -> {
logger.warn("Unknown System Type");
});
}, () -> logger.warn("Unknown System Type"));

areas.add(areaProperties);
}
Expand All @@ -397,7 +393,7 @@ private void discoverUnits() {
int thingType = unitProperties.getUnitType();
String thingName = unitProperties.getName();
String thingID = Integer.toString(unitProperties.getNumber());
ThingUID thingUID = null;
ThingUID thingUID;

Map<String, Object> properties = new HashMap<>();
properties.put(THING_PROPERTIES_NAME, thingName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* @author Craig Hamilton - Initial contribution
*/
@NonNullByDefault
@SuppressWarnings("serial")
public class BridgeOfflineException extends Exception {
public BridgeOfflineException(Exception e) {
super(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ public void initialize() {

super.initialize();
if (bridgeHandler != null) {
updateAreaProperties(bridgeHandler);
updateAreaProperties();
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR,
"Received null bridge while initializing Area!");
}
}

private void updateAreaProperties(OmnilinkBridgeHandler bridgeHandler) {
private void updateAreaProperties() {
final List<AreaProperties> areas = getAreaProperties();
if (areas != null) {
for (AreaProperties areaProperties : areas) {
Expand All @@ -99,13 +99,10 @@ public void handleCommand(ChannelUID channelUID, Command command) {
return;
}

switch (channelUID.getId()) {
case CHANNEL_AREA_ACTIVATE_KEYPAD_EMERGENCY:
handleKeypadEmergency(channelUID, command);
break;
default:
handleSecurityMode(channelUID, command);
break;
if (channelUID.getId().equals(CHANNEL_AREA_ACTIVATE_KEYPAD_EMERGENCY)) {
handleKeypadEmergency(command);
} else {
handleSecurityMode(channelUID, command);
}
}

Expand Down Expand Up @@ -176,7 +173,7 @@ private void handleSecurityMode(ChannelUID channelUID, Command command) {
*/
protected abstract EnumSet<AreaAlarm> getAlarms();

private void handleKeypadEmergency(ChannelUID channelUID, Command command) {
private void handleKeypadEmergency(Command command) {
if (command instanceof DecimalType decimalCommand) {
try {
final OmnilinkBridgeHandler bridge = getOmnilinkBridgeHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected void sendOmnilinkCommand(int message, int param1, int param2) {
}

/**
* Calculate the area filter the a supplied area
* Calculate the area filter of a supplied area
*
* @param areaProperties Area to calculate filter for.
* @return Calculated Bit Filter for the supplied area. Bit 0 is area 1, bit 2 is area 2 and so on.
Expand Down Expand Up @@ -120,7 +120,7 @@ protected int getThingNumber() {
protected int getAreaNumber() {
String areaNumber = getThing().getProperties().get(THING_PROPERTIES_AREA);
if (areaNumber != null) {
return Integer.valueOf(areaNumber);
return Integer.parseInt(areaNumber);
} else {
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/**
* The {@link AbstractOmnilinkStatusHandler} defines some methods that can be used across
* the many different units exposed by the OmniLink protocol to retrive updated status information.
* the many different units exposed by the OmniLink protocol to retrieve updated status information.
*
* @author Craig Hamilton - Initial contribution
* @author Ethan Dye - openHAB3 rewrite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
@NonNullByDefault
public class AudioSourceHandler extends AbstractOmnilinkHandler {
private final Logger logger = LoggerFactory.getLogger(AudioSourceHandler.class);
private final int pollDelaySeconds = 5;
private final int thingID = getThingNumber();
private @Nullable ScheduledFuture<?> scheduledPolling = null;
public @Nullable String number;
Expand All @@ -64,7 +63,7 @@ public void initialize() {
final OmnilinkBridgeHandler bridgeHandler = getOmnilinkBridgeHandler();
if (bridgeHandler != null) {
updateStatus(ThingStatus.ONLINE);
if (((Boolean) getThing().getConfiguration().get(THING_PROPERTIES_AUTOSTART)).booleanValue()) {
if ((Boolean) getThing().getConfiguration().get(THING_PROPERTIES_AUTOSTART)) {
logger.debug("Autostart enabled, scheduling polling for Audio Source: {}", thingID);
schedulePolling();
} else {
Expand Down Expand Up @@ -104,6 +103,7 @@ private synchronized void cancelPolling() {
private synchronized void schedulePolling() {
cancelPolling();
logger.debug("Scheduling polling for Audio Source: {}", thingID);
int pollDelaySeconds = 5;
scheduledPolling = super.scheduler.scheduleWithFixedDelay(this::pollAudioSource, 0, pollDelaySeconds,
TimeUnit.SECONDS);
}
Expand All @@ -113,19 +113,17 @@ public void handleCommand(ChannelUID channelUID, Command command) {
logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command);
final ScheduledFuture<?> scheduledPolling = this.scheduledPolling;

switch (channelUID.getId()) {
case CHANNEL_AUDIO_SOURCE_POLLING:
if (command instanceof RefreshType) {
updateState(CHANNEL_AUDIO_SOURCE_POLLING,
OnOffType.from((scheduledPolling != null && !scheduledPolling.isDone())));
} else if (command instanceof OnOffType onOffCommand) {
handlePolling(channelUID, onOffCommand);
} else {
logger.debug("Invalid command: {}, must be RefreshType or OnOffType", command);
}
break;
default:
logger.warn("Unknown channel for Audio Source thing: {}", channelUID);
if (channelUID.getId().equals(CHANNEL_AUDIO_SOURCE_POLLING)) {
if (command instanceof RefreshType) {
updateState(CHANNEL_AUDIO_SOURCE_POLLING,
OnOffType.from((scheduledPolling != null && !scheduledPolling.isDone())));
} else if (command instanceof OnOffType onOffCommand) {
handlePolling(channelUID, onOffCommand);
} else {
logger.debug("Invalid command: {}, must be RefreshType or OnOffType", command);
}
} else {
logger.warn("Unknown channel for Audio Source thing: {}", channelUID);
}
}

Expand Down Expand Up @@ -174,7 +172,7 @@ public void pollAudioSource() {
logger.debug("Received null bridge while polling Audio Source statuses!");
}
} catch (OmniInvalidResponseException | OmniUnknownMessageTypeException | BridgeOfflineException e) {
logger.debug("Exception recieved while polling for Audio Source statuses: {}", e.getMessage());
logger.debug("Exception received while polling for Audio Source statuses: {}", e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,15 @@ public void handleCommand(ChannelUID channelUID, Command command) {
return;
}

switch (channelUID.getId()) {
case CHANNEL_BUTTON_PRESS:
if (command instanceof OnOffType) {
sendOmnilinkCommand(CommandMessage.CMD_BUTTON, 0, thingID);
updateChannels();
} else {
logger.debug("Invalid command: {}, must be OnOffType", command);
}
break;
default:
logger.warn("Unknown channel for Button thing: {}", channelUID);
if (channelUID.getId().equals(CHANNEL_BUTTON_PRESS)) {
if (command instanceof OnOffType) {
sendOmnilinkCommand(CommandMessage.CMD_BUTTON, 0, thingID);
updateChannels();
} else {
logger.debug("Invalid command: {}, must be OnOffType", command);
}
} else {
logger.warn("Unknown channel for Button thing: {}", channelUID);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
thingID);
break;
default:
logger.warn("Unknown channel for Humdity Sensor thing: {}", channelUID);
logger.warn("Unknown channel for Humidity Sensor thing: {}", channelUID);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,16 @@ public void handleCommand(ChannelUID channelUID, Command command) {
return;
}

switch (channelUID.getId()) {
case CHANNEL_LOCK_SWITCH:
if (command instanceof OnOffType) {
sendOmnilinkCommand(OnOffType.OFF.equals(command) ? CommandMessage.CMD_UNLOCK_DOOR
: CommandMessage.CMD_LOCK_DOOR, 0, thingID);
} else {
logger.debug("Invalid command {}, must be OnOffType", command);
}
break;
default:
logger.warn("Unknown channel for Lock thing: {}", channelUID);
if (channelUID.getId().equals(CHANNEL_LOCK_SWITCH)) {
if (command instanceof OnOffType) {
sendOmnilinkCommand(
OnOffType.OFF.equals(command) ? CommandMessage.CMD_UNLOCK_DOOR : CommandMessage.CMD_LOCK_DOOR,
0, thingID);
} else {
logger.debug("Invalid command {}, must be OnOffType", command);
}
} else {
logger.warn("Unknown channel for Lock thing: {}", channelUID);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,15 @@ public LuminaAreaHandler(Thing thing) {

@Override
protected int getMode(ChannelUID channelUID) {
switch (channelUID.getId()) {
case CHANNEL_AREA_SECURITY_MODE_HOME:
return CommandMessage.CMD_SECURITY_LUMINA_HOME_MODE;
case CHANNEL_AREA_SECURITY_MODE_SLEEP:
return CommandMessage.CMD_SECURITY_LUMINA_SLEEP_MODE;
case CHANNEL_AREA_SECURITY_MODE_AWAY:
return CommandMessage.CMD_SECURITY_LUMINA_AWAY_MODE;
case CHANNEL_AREA_SECURITY_MODE_VACATION:
return CommandMessage.CMD_SECURITY_LUMINA_VACATION_MODE;
case CHANNEL_AREA_SECURITY_MODE_PARTY:
return CommandMessage.CMD_SECURITY_LUMINA_PARTY_MODE;
case CHANNEL_AREA_SECURITY_MODE_SPECIAL:
return CommandMessage.CMD_SECURITY_LUMINA_SPECIAL_MODE;
default:
throw new IllegalStateException("Unknown channel for area thing " + channelUID);
}
return switch (channelUID.getId()) {
case CHANNEL_AREA_SECURITY_MODE_HOME -> CommandMessage.CMD_SECURITY_LUMINA_HOME_MODE;
case CHANNEL_AREA_SECURITY_MODE_SLEEP -> CommandMessage.CMD_SECURITY_LUMINA_SLEEP_MODE;
case CHANNEL_AREA_SECURITY_MODE_AWAY -> CommandMessage.CMD_SECURITY_LUMINA_AWAY_MODE;
case CHANNEL_AREA_SECURITY_MODE_VACATION -> CommandMessage.CMD_SECURITY_LUMINA_VACATION_MODE;
case CHANNEL_AREA_SECURITY_MODE_PARTY -> CommandMessage.CMD_SECURITY_LUMINA_PARTY_MODE;
case CHANNEL_AREA_SECURITY_MODE_SPECIAL -> CommandMessage.CMD_SECURITY_LUMINA_SPECIAL_MODE;
default -> throw new IllegalStateException("Unknown channel for area thing " + channelUID);
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,16 @@ public OmniAreaHandler(Thing thing) {

@Override
protected int getMode(ChannelUID channelUID) {
switch (channelUID.getId()) {
case CHANNEL_AREA_SECURITY_MODE_DISARM:
return CommandMessage.CMD_SECURITY_OMNI_DISARM;
case CHANNEL_AREA_SECURITY_MODE_DAY:
return CommandMessage.CMD_SECURITY_OMNI_DAY_MODE;
case CHANNEL_AREA_SECURITY_MODE_NIGHT:
return CommandMessage.CMD_SECURITY_OMNI_NIGHT_MODE;
case CHANNEL_AREA_SECURITY_MODE_AWAY:
return CommandMessage.CMD_SECURITY_OMNI_AWAY_MODE;
case CHANNEL_AREA_SECURITY_MODE_VACATION:
return CommandMessage.CMD_SECURITY_OMNI_VACATION_MODE;
case CHANNEL_AREA_SECURITY_MODE_DAY_INSTANT:
return CommandMessage.CMD_SECURITY_OMNI_DAY_INSTANT_MODE;
case CHANNEL_AREA_SECURITY_MODE_NIGHT_DELAYED:
return CommandMessage.CMD_SECURITY_OMNI_NIGHT_DELAYED_MODE;
default:
throw new IllegalStateException("Unknown channel for area thing " + channelUID);
}
return switch (channelUID.getId()) {
case CHANNEL_AREA_SECURITY_MODE_DISARM -> CommandMessage.CMD_SECURITY_OMNI_DISARM;
case CHANNEL_AREA_SECURITY_MODE_DAY -> CommandMessage.CMD_SECURITY_OMNI_DAY_MODE;
case CHANNEL_AREA_SECURITY_MODE_NIGHT -> CommandMessage.CMD_SECURITY_OMNI_NIGHT_MODE;
case CHANNEL_AREA_SECURITY_MODE_AWAY -> CommandMessage.CMD_SECURITY_OMNI_AWAY_MODE;
case CHANNEL_AREA_SECURITY_MODE_VACATION -> CommandMessage.CMD_SECURITY_OMNI_VACATION_MODE;
case CHANNEL_AREA_SECURITY_MODE_DAY_INSTANT -> CommandMessage.CMD_SECURITY_OMNI_DAY_INSTANT_MODE;
case CHANNEL_AREA_SECURITY_MODE_NIGHT_DELAYED -> CommandMessage.CMD_SECURITY_OMNI_NIGHT_DELAYED_MODE;
default -> throw new IllegalStateException("Unknown channel for area thing " + channelUID);
};
}

@Override
Expand Down
Loading