Here is an example with minimal configuration parameters (using default values with no telnet login):
-```java
+```
atlona:pro3-88m:home [ ipAddress="192.168.1.30" ]
```
Here is another example with minimal configuration parameters (using default values with telnet login):
-```java
+```
atlona:pro3-88m:home [ ipAddress="192.168.1.30", userName="me", password="12345" ]
```
Here is a full configuration example:
-```java
+```
atlona:pro3-88m:home [ ipAddress="192.168.1.30", userName="me", password="12345", polling=600, ping=30, retryPolling=10 ]
```
Here is an example of items for the AT-UHD-PRO33-88M:
-```java
+```
Switch Atlona_Power "Power" { channel = "atlona:pro3-88m:home:primary#power" }
Switch Atlona_PanelLock "Panel Lock" { channel = "atlona:pro3-88m:home:primary#panellock" }
Switch Atlona_Presets "Preset Command" { channel = "atlona:pro3-88m:home:primary#presetcmd" }
### SiteMap
-```perl
+```
sitemap demo label="Main Menu" {
Frame label="Atlona" {
Text label="Device" {
### atlonainputports.map
-```text
+```
1=CableBox
2=BluRay Player
3=Roku
### atlonaoutputports.map
-```text
+```
1=Living Room
2=Master Bed
3=Kitchen
*/
package org.openhab.binding.atlona.internal;
-import org.openhab.binding.atlona.internal.handler.AtlonaHandler;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.types.State;
*
* @author Tim Roberts - Initial contribution
*/
+@NonNullByDefault
public interface AtlonaHandlerCallback {
/**
* Callback to the {@link AtlonaHandler} to update the status of the thing.
* @param detail a non-null {@link org.openhab.core.thing.ThingStatusDetail}
* @param msg a possibly null, possibly empty message
*/
- void statusChanged(ThingStatus status, ThingStatusDetail detail, String msg);
+ void statusChanged(ThingStatus status, ThingStatusDetail detail, @Nullable String msg);
/**
* Callback to the {@link AtlonaHandler} to update the state of an item
import java.util.Collections;
import java.util.Set;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.atlona.internal.pro3.AtlonaPro3Capabilities;
import org.openhab.binding.atlona.internal.pro3.AtlonaPro3Handler;
import org.openhab.core.thing.Thing;
* @author Tim Roberts - Initial contribution
* @author Michael Lobstein - Add support for AT-PRO3HD66M
*/
+@NonNullByDefault
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.atlona")
public class AtlonaHandlerFactory extends BaseThingHandlerFactory {
* Creates the handler for the given thing given its thingTypeUID
*/
@Override
- protected ThingHandler createHandler(Thing thing) {
+ protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (thingTypeUID.equals(THING_TYPE_PRO3_44M)) {
*/
@Override
public void stateChanged(String channelId, State state) {
- if (channelId == null || "".equals(channelId)) {
+ if ("".equals(channelId)) {
return;
}
multiSocket.receive(receivePacket);
String message = new String(receivePacket.getData()).trim();
- if (message != null && message.length() > 0) {
+ if (message.length() > 0) {
messageReceive(message);
}
} catch (SocketTimeoutException e) {
if (idx > 0) {
String name = msg.substring(0, idx);
- if (name.equalsIgnoreCase("Host")) {
+ if ("Host".equalsIgnoreCase(name)) {
host = msg.substring(idx + 1).trim().replaceAll("\"", "");
int sep = host.indexOf('_');
if (sep >= 0) {
host = host.substring(sep + 1);
}
- } else if (name.equalsIgnoreCase("Model")) {
+ } else if ("Model".equalsIgnoreCase(name)) {
model = msg.substring(idx + 1).trim().replaceAll("\"", "");
- } else if (name.equalsIgnoreCase("Manufacturer")) {
+ } else if ("Manufacturer".equalsIgnoreCase(name)) {
manufacturer = msg.substring(idx + 1).trim().replaceAll("\"", "");
- } else if (name.equalsIgnoreCase("From")) {
+ } else if ("From".equalsIgnoreCase(name)) {
from = msg.substring(idx + 1).trim().replaceAll("\"", "");
int sep = from.indexOf(':');
if (sep >= 0) {
if (host != null && model != null && from != null) {
ThingTypeUID typeId = null;
- if (model.equalsIgnoreCase("AT-UHD-PRO3-44M")) {
+ if ("AT-UHD-PRO3-44M".equalsIgnoreCase(model)) {
typeId = THING_TYPE_PRO3_44M;
- } else if (model.equalsIgnoreCase("AT-UHD-PRO3-66M")) {
+ } else if ("AT-UHD-PRO3-66M".equalsIgnoreCase(model)) {
typeId = THING_TYPE_PRO3_66M;
- } else if (model.equalsIgnoreCase("AT-UHD-PRO3-88M")) {
+ } else if ("AT-UHD-PRO3-88M".equalsIgnoreCase(model)) {
typeId = THING_TYPE_PRO3_88M;
- } else if (model.equalsIgnoreCase("AT-UHD-PRO3-1616M")) {
+ } else if ("AT-UHD-PRO3-1616M".equalsIgnoreCase(model)) {
typeId = THING_TYPE_PRO3_1616M;
} else {
logger.warn("Unknown model #: {}", model);
*/
package org.openhab.binding.atlona.internal.handler;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
/**
* Any model specific capabilities class should inherit from this base class. Currently doesn't provide any generic
* functionality.
*
* @author Tim Roberts - Initial contribution
*/
+@NonNullByDefault
public abstract class AtlonaCapabilities {
}
@Override
public void addListener(SocketSessionListener listener) {
- if (listener == null) {
- throw new IllegalArgumentException("listener cannot be null");
- }
listeners.add(listener);
}
@Override
public synchronized void sendCommand(String command) throws IOException {
- if (command == null) {
- throw new IllegalArgumentException("command cannot be null");
- }
-
if (!isConnected()) {
throw new IOException("Cannot send message - disconnected");
}
import java.io.IOException;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
/**
* This is a socket session interface that defines the contract for a socket session. A socket session will initiate
* communications with the underlying device and provide message back via the {@link SocketSessionListener}
*
* @author Tim Roberts - Initial contribution
*/
+@NonNullByDefault
public interface SocketSession {
/**
*/
package org.openhab.binding.atlona.internal.net;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
/**
* Interface defining a listener to a {@link SocketSession} that will receive responses and/or exceptions from the
* socket
*
* @author Tim Roberts - Initial contribution
*/
+@NonNullByDefault
public interface SocketSessionListener {
/**
* Called when a command has completed with the response for the command
import java.util.HashSet;
import java.util.Set;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.atlona.internal.handler.AtlonaCapabilities;
/**
* @author Tim Roberts - Initial contribution
* @author Michael Lobstein - Add support for AT-PRO3HD66M
*/
+@NonNullByDefault
public class AtlonaPro3Capabilities extends AtlonaCapabilities {
/**
public AtlonaPro3Capabilities(int nbrPowerPorts, int nbrAudioPorts, Set<Integer> hdmiPorts, boolean isUHDModel) {
super();
- if (hdmiPorts == null) {
- throw new IllegalArgumentException("hdmiPorts cannot be null");
- }
-
if (hdmiPorts.isEmpty()) {
throw new IllegalArgumentException("hdmiPorts cannot be empty");
}
*/
package org.openhab.binding.atlona.internal.pro3;
-import org.openhab.binding.atlona.internal.discovery.AtlonaDiscovery;
-
/**
* Configuration class for the Atlona Pro3 line of switchers
*
*/
package org.openhab.binding.atlona.internal.pro3;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
/**
* The {@link AtlonaPro3Binding} class defines common constants, which are
* used across the whole binding.
*
* @author Tim Roberts - Initial contribution
*/
+@NonNullByDefault
class AtlonaPro3Constants {
// Properties
static final String CHANNEL_VOLUME = "volume";
static final String CHANNEL_VOLUME_MUTE = "volumemute";
- // static final String CHANNEL_RS232 = "rs232cmd";
static final String CONFIG_HOSTNAME = "hostname";
static final String CONFIG_OUTPUT = "output";
ping = null;
}
- try {
- session.disconnect();
- } catch (IOException e) {
- // ignore - we don't care
+ if (session != null) {
+ try {
+ session.disconnect();
+ } catch (IOException e) {
+ // ignore - we don't care
+ }
}
if (retryConnection) {
/**
* Simple gets the {@link AtlonaPro3Config} from the {@link Thing} and will set the status to offline if not found.
*
- * @return a possible null {@link AtlonaPro3Config}
+ * @return {@link AtlonaPro3Config}
*/
private AtlonaPro3Config getAtlonaConfig() {
- final AtlonaPro3Config config = getThing().getConfiguration().as(AtlonaPro3Config.class);
-
- if (config == null) {
- updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
- }
-
- return config;
+ return getThing().getConfiguration().as(AtlonaPro3Config.class);
}
/**
String response;
try {
response = callback.getResponse();
- if (!response.equals("")) {
+ if (!"".equals(response)) {
logger.debug("Atlona protocol violation - didn't start with an inital empty response: '{}'", response);
}
} catch (Exception e) {
// We should have been presented with a new "\r\nLogin: "
response = callback.getResponse();
- if (!response.equals("")) {
+ if (!"".equals(response)) {
logger.debug("Atlona protocol violation - didn't start with an inital empty response: '{}'", response);
}
// Get the new "Login: " prompt response
response = callback.getResponse();
- if (response.equals(RSP_LOGIN)) {
+ if (RSP_LOGIN.equals(response)) {
if (config.getUserName() == null || config.getUserName().trim().length() == 0) {
return "Atlona PRO3 has enabled Telnet/IP Login but no username was provided in the configuration.";
}
response = callback.getResponse();
// Burn the empty response if we got one (
- if (response.equals("")) {
+ if ("".equals(response)) {
response = callback.getResponse();
}
- if (!response.equals(RSP_PASSWORD)) {
+ if (!RSP_PASSWORD.equals(response)) {
// If we got another login response, username wasn't valid
- if (response.equals(RSP_LOGIN)) {
+ if (RSP_LOGIN.equals(response)) {
return "Username " + config.getUserName() + " is not a valid user on the atlona";
}
return "Atlona protocol violation - invalid response to a login: " + response;
// Send an invalid command to see if we get the failed command response
// First make sure we had an empty response (the "\r\n" part)
- if (!response.equals("")) {
+ if (!"".equals(response)) {
logger.debug("Atlona protocol violation - not an empty response after password: '{}'", response);
}
String response;
try {
response = callback.getResponse();
- if (!response.equals("")) {
+ if (!"".equals(response)) {
logger.debug("Atlona protocol violation - didn't start with an inital empty response: '{}'", response);
}
} catch (Exception e) {
// Check for an empty response after the login prompt (the "\r\n" part)
response = callback.getResponse();
- if (!response.equals("")) {
+ if (!"".equals(response)) {
logger.debug("Atlona protocol violation - not an empty response after password: '{}'", response);
}
// could be "off" (if mirror off), "on"/"Out" (with 3rd group representing out)
String oper = (m.group(2) == null ? "" : m.group(2).trim()).toLowerCase();
- if (oper.equals("off")) {
+ if ("off".equals(oper)) {
callback.stateChanged(AtlonaPro3Utilities.createChannelID(AtlonaPro3Constants.GROUP_MIRROR,
hdmiPortNbr, AtlonaPro3Constants.CHANNEL_PORTMIRRORENABLED), OnOffType.OFF);
} else {
@Override
public void responseReceived(String response) {
- if (response == null || response.isEmpty()) {
+ if (response.isEmpty()) {
return;
}
*/
package org.openhab.binding.atlona.internal.pro3;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
/**
*
* @author Tim Roberts - Initial contribution
*/
+@NonNullByDefault
public class AtlonaPro3Utilities {
/**
* Helper method to create a channel id from a group with no port number attached