Skip to content

Commit

Permalink
[atlona] Add support for the AT-PRO3HD66M (openhab#9385)
Browse files Browse the repository at this point in the history
* Add support for the AT-PRO3HD66M
  • Loading branch information
mlobstein authored Dec 25, 2020
1 parent 83f31b1 commit dc8fa86
Show file tree
Hide file tree
Showing 9 changed files with 277 additions and 196 deletions.
14 changes: 14 additions & 0 deletions bundles/org.openhab.binding.atlona/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Atlona Binding

This binding integrates Atlona AT-UHD-PRO3 HdBaseT matrix switches [Atlona AT-UHD-PRO3 HdBaseT matrix switches](https://www.atlona.com) into your openHAB installation.
The older HD model 6x6 matrix [AT-PRO3HD66M] (https://atlona.com/product/at-pro3hd66m/) is also supported.

## Supported Things

Expand All @@ -12,6 +13,7 @@ This binding supports the following thing types:
| pro3-66m | Thing | The AT-UHD-PRO3-66M 6x6 HDBaseT matrix. |
| pro3-88m | Thing | The AT-UHD-PRO3-88M 8x8 HDBaseT matrix. |
| pro3-1616m | Thing | The AT-UHD-PRO3-1616M 16x16 HDBaseT matrix. |
| pro3-hd66m | Thing | The AT-PRO3HD66M 6x6 HDBaseT matrix. |

## Discovery

Expand Down Expand Up @@ -145,6 +147,18 @@ If it is higher than the "IP Timeout" value, the switch will timeout our connect
| pro3-1616m | volume11#volumemute | Switch | RW | Mutes/Unmutes audio port #11 |
| pro3-1616m | volume12#volume | Number | RW | Sets the volume of audio port #12 to the specified decibel level (between -79db to +15db) |
| pro3-1616m | volume12#volumemute | Switch | RW | Mutes/Unmutes audio port #12 |
| | | | | |
| pro3-hd66m | primary#power | Switch | RW | Matrix Power Switch |
| pro3-hd66m | primary#panellock | Switch | RW | Sets the front panel locked or unlocked |
| pro3-hd66m | primary#irenable | Switch | RW | Enables/Disabled the front panel IR |
| pro3-hd66m | primary#presetcmd | Switch | W | Sends a preset command ('saveX', 'recallX', 'clearX') - see notes below |
| pro3-hd66m | primary#matrixcmd | Switch | W | Sends a matrix command ('resetmatrix', 'resetports', 'allportsX') - see notes below |
| pro3-hd66m | port1#portoutput | Number | RW | Sets output port #1 to the specified input port |
| pro3-hd66m | port2#portoutput | Number | RW | Sets output port #2 to the specified input port |
| pro3-hd66m | port3#portoutput | Number | RW | Sets output port #3 to the specified input port |
| pro3-hd66m | port4#portoutput | Number | RW | Sets output port #4 to the specified input port |
| pro3-hd66m | port5#portoutput | Number | RW | Sets output port #5 to the specified input port |
| pro3-hd66m | port5#portoutput | Number | RW | Sets output port #6 to the specified input port |

### presetcmd

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* The {@link AtlonaBinding} class defines common constants, which are used across the whole binding.
*
* @author Tim Roberts - Initial contribution
* @author Michael Lobstein - Add support for AT-PRO3HD66M
*/
@NonNullByDefault
public class AtlonaBindingConstants {
Expand Down Expand Up @@ -47,4 +48,9 @@ public class AtlonaBindingConstants {
* Thing ID for the AT-UHD-PRO3-1616m (16x16 hdbaset matrix)
*/
public static final ThingTypeUID THING_TYPE_PRO3_1616M = new ThingTypeUID(BINDING_ID, "pro3-1616m");

/**
* Thing ID for the AT-PRO3HD66M (HD 6x6 hdbaset matrix)
*/
public static final ThingTypeUID THING_TYPE_PRO3HD_66M = new ThingTypeUID(BINDING_ID, "pro3-hd66m");
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.openhab.binding.atlona.internal.pro3.AtlonaPro3Capabilities;
import org.openhab.binding.atlona.internal.pro3.AtlonaPro3Handler;
Expand All @@ -35,6 +33,7 @@
* handlers.
*
* @author Tim Roberts - Initial contribution
* @author Michael Lobstein - Add support for AT-PRO3HD66M
*/
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.atlona")
public class AtlonaHandlerFactory extends BaseThingHandlerFactory {
Expand All @@ -44,9 +43,8 @@ public class AtlonaHandlerFactory extends BaseThingHandlerFactory {
/**
* The set of supported Atlona products
*/
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet(
Stream.of(THING_TYPE_PRO3_44M, THING_TYPE_PRO3_66M, THING_TYPE_PRO3_88M, THING_TYPE_PRO3_1616M)
.collect(Collectors.toSet()));
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_PRO3_44M, THING_TYPE_PRO3_66M,
THING_TYPE_PRO3_88M, THING_TYPE_PRO3_1616M, THING_TYPE_PRO3HD_66M);

/**
* {@inheritDoc}
Expand All @@ -65,30 +63,26 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
*/
@Override
protected ThingHandler createHandler(Thing thing) {
if (thing == null) {
logger.error("createHandler was given a null thing!");
return null;
}

ThingTypeUID thingTypeUID = thing.getThingTypeUID();

if (thingTypeUID.equals(THING_TYPE_PRO3_44M)) {
return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(5, 3, Collections.singleton(5)));
return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(5, 3, Collections.singleton(5), true));
}

if (thingTypeUID.equals(THING_TYPE_PRO3_66M)) {
return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(8, 4,
Collections.unmodifiableSet(Stream.of(6, 8).collect(Collectors.toSet()))));
return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(8, 4, Set.of(6, 8), true));
}

if (thingTypeUID.equals(THING_TYPE_PRO3_88M)) {
return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(10, 6,
Collections.unmodifiableSet(Stream.of(8, 10).collect(Collectors.toSet()))));
return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(10, 6, Set.of(8, 10), true));
}

if (thingTypeUID.equals(THING_TYPE_PRO3_1616M)) {
return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(5, 3,
Collections.unmodifiableSet(Stream.of(17, 18, 19, 20).collect(Collectors.toSet()))));
return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(5, 3, Set.of(17, 18, 19, 20), true));
}

if (thingTypeUID.equals(THING_TYPE_PRO3HD_66M)) {
return new AtlonaPro3Handler(thing, new AtlonaPro3Capabilities(0, 0, Set.of(1, 2, 3, 4, 5, 6), false));
}

logger.warn("Unknown binding: {}: {}", thingTypeUID.getId(), thingTypeUID.getBindingId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public void setProperty(String propertyName, String propertyValue) {
* @return the {@link State} for the propertyName or null if not found
*/
public State getState(String propertyName) {
// TODO Auto-generated method stub
return state.get(propertyName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* powered, the number of audio ports there are and which (output) ports are HDMI ports.
*
* @author Tim Roberts - Initial contribution
* @author Michael Lobstein - Add support for AT-PRO3HD66M
*/
public class AtlonaPro3Capabilities extends AtlonaCapabilities {

Expand All @@ -41,24 +42,21 @@ public class AtlonaPro3Capabilities extends AtlonaCapabilities {
*/
private final Set<Integer> hdmiPorts;

/**
* Indicates if the thing is a 4K/UHD model vs an older HD model
*/
private final boolean isUHDModel;

/**
* Constructs the capabilities from the parms
*
* @param nbrPowerPorts a greater than 0 number of power ports
* @param nbrAudioPorts a greater than 0 number of audio ports
* @param hdmiPorts a non-null, non-empty set of hdmi ports
*/
public AtlonaPro3Capabilities(int nbrPowerPorts, int nbrAudioPorts, Set<Integer> hdmiPorts) {
public AtlonaPro3Capabilities(int nbrPowerPorts, int nbrAudioPorts, Set<Integer> hdmiPorts, boolean isUHDModel) {
super();

if (nbrPowerPorts < 1) {
throw new IllegalArgumentException("nbrPowerPorts must be greater than 0");
}

if (nbrAudioPorts < 1) {
throw new IllegalArgumentException("nbrAudioPorts must be greater than 0");
}

if (hdmiPorts == null) {
throw new IllegalArgumentException("hdmiPorts cannot be null");
}
Expand All @@ -70,6 +68,7 @@ public AtlonaPro3Capabilities(int nbrPowerPorts, int nbrAudioPorts, Set<Integer>
this.nbrPowerPorts = nbrPowerPorts;
this.nbrAudioPorts = nbrAudioPorts;
this.hdmiPorts = Collections.unmodifiableSet(new HashSet<>(hdmiPorts));
this.isUHDModel = isUHDModel;
}

/**
Expand Down Expand Up @@ -98,4 +97,13 @@ int getNbrAudioPorts() {
Set<Integer> getHdmiPorts() {
return hdmiPorts;
}

/**
* Returns a flag indicating the model type
*
* @return boolean true if the thing is a 4K/UHD model
*/
boolean isUHDModel() {
return isUHDModel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,12 @@ private void connect() {
session.clearListeners();
session.connect();

response = atlonaHandler.login();
if (this.getCapabilities().isUHDModel()) {
response = atlonaHandler.loginUHD();
} else {
response = atlonaHandler.loginHD();
}

if (response == null) {
final AtlonaPro3Config config = getAtlonaConfig();
if (config != null) {
Expand Down
Loading

0 comments on commit dc8fa86

Please sign in to comment.