Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[anthem] Initial contribution of binding for Anthem AV preamp/processors #14311

Merged
merged 11 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
/bundles/org.openhab.binding.amplipi/ @kaikreuzer
/bundles/org.openhab.binding.androiddebugbridge/ @GiviMAD
/bundles/org.openhab.binding.anel/ @paphko
/bundles/org.openhab.binding.anthem/ @mhilbush
/bundles/org.openhab.binding.astro/ @gerrieg
/bundles/org.openhab.binding.atlona/ @tmrobert8 @mlobstein
/bundles/org.openhab.binding.autelis/ @digitaldan
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@
<artifactId>org.openhab.binding.anel</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.anthem</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.astro</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.anthem/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This content is produced and maintained by the openHAB project.

* Project home: https://www.openhab.org

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.

== Source Code

https://github.com/openhab/openhab-addons
77 changes: 77 additions & 0 deletions bundles/org.openhab.binding.anthem/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Anthem Binding

The binding allows control of Anthem AV processors over an IP connection to the processor.

## Supported Things

The following thing type is supported:

| Thing | ID | Discovery | Description |
|----------|----------|-----------|-------------|
| Anthem | anthem | Manual | Represents a Anthem AV processor |

Tested models include the AVM-60 11.2-channel preamp/processor.


## Thing Configuration

The following configuration parameters are available on the Anthem thing:

| Parameter | Parameter ID | Required/Optional | Description |
|---------------------|---------------------------|-------------------|-------------|
| Host | host | Required | IP address or host name of the Anthem AV processor |
| Port | port | Optional | Port number used by the Anthem |
| Reconnect Interval | reconnectIntervalMinutes | Optional | The time to wait between reconnection attempts (in minutes) |
| Command Delay | commandDelayMsec | Optional | The delay between commands sent to the processor (in milliseconds) |

## Channels

The Anthem AV processor supports the following channels (some zones/channels are model specific):

| Channel | Type | Description |
|-------------------------|---------|--------------|
| *Main Zone* | | |
| 1#power | Switch | Power the zone on or off |
| 1#volume | Dimmer | Increase or decrease the volume level |
| 1#volumeDB | Number | The actual volume setting |
| 1#mute | Switch | Mute the volume |
| 1#activeInput | Number | The currently active input source |
| 1#activeInputShortName | String | Short friendly name of the active input |
| 1#activeInputLongName | String | Long friendly name of the active input |
| *Zone 2* | | |
| 2#power | Switch | Power the zone on or off |
| 2#volume | Dimmer | Increase or decrease the volume level |
| 2#volumeDB | Number | The actual volume setting |
| 2#mute | Switch | Mute the volume |
| 2#activeInput | Number | The currently active input source |
| 2#activeInputShortName | String | Short friendly name of the active input |
| 2#activeInputLongName | String | Long friendly name of the active input |


## Full Example

### Things

```
Thing anthem:anthem:mediaroom "Anthem AVM 60" [ host="192.168.1.100" ]
```

### Items

```
Switch Anthem_Z1_Power "Zone 1 Power [%s]" { channel="anthem:anthem:mediaroom:1#power" }
Dimmer Anthem_Z1_Volume "Zone 1 Volume [%s]" { channel="anthem:anthem:mediaroom:1#volume" }
Number Anthem_Z1_Volume_DB "Zone 1 Volume dB [%.0f]" { channel="anthem:anthem:mediaroom:1#volumeDB" }
Switch Anthem_Z1_Mute "Zone 1 Mute [%s]" { channel="anthem:anthem:mediaroom:1#mute" }
Number Anthem_Z1_ActiveInput "Zone 1 Active Input [%.0f]" { channel="anthem:anthem:mediaroom:1#activeInput" }
String Anthem_Z1_ActiveInputShortName "Zone 1 Active Input Short Name [%s]" { channel="anthem:anthem:mediaroom:1#activeInputShortName" }
String Anthem_Z1_ActiveInputLongName "Zone 1 Active Input Long Name [%s]" { channel="anthem:anthem:mediaroom:1#activeInputLongName" }

Switch Anthem_Z2_Power "Zone 2 Power [%s]" { channel="anthem:anthem:mediaroom:1#power" }
Dimmer Anthem_Z2_Volume "Zone 2 Volume [%s]" { channel="anthem:anthem:mediaroom:1#volume" }
Number Anthem_Z2_Volume_DB "Zone 2 Volume dB [%.0f]" { channel="anthem:anthem:mediaroom:1#volumeDB" }
Switch Anthem_Z2_Mute "Zone 2 Mute [%s]" { channel="anthem:anthem:mediaroom:1#mute" }
Number Anthem_Z2_ActiveInput "Zone 2 Active Input [%.0f]" { channel="anthem:anthem:mediaroom:1#activeInput" }
String Anthem_Z2_ActiveInputShortName "Zone 2 Active Input Short Name [%s]" { channel="anthem:anthem:mediaroom:1#activeInputShortName" }
String Anthem_Z2_ActiveInputLongName "Zone 2 Active Input Long Name [%s]" { channel="anthem:anthem:mediaroom:1#activeInputLongName" }
```
17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.anthem/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.anthem</artifactId>

<name>openHAB Add-ons :: Bundles :: Anthem Binding</name>

</project>
10 changes: 10 additions & 0 deletions bundles/org.openhab.binding.anthem/src/main/feature/feature.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.anthem-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features
</repository>

<feature name="openhab-binding-anthem" description="Anthem Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.anthem/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright (c) 2010-2023 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.anthem.internal;

import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link AnthemBindingConstants} class defines common constants, which are
* used across the entire binding.
*
* @author Mark Hilbush - Initial contribution
*/
@NonNullByDefault
public class AnthemBindingConstants {
public static final String BINDING_ID = "anthem";

public static final ThingTypeUID THING_TYPE_ANTHEM = new ThingTypeUID(BINDING_ID, "anthem");

// List of all Thing Type UIDs
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_ANTHEM);

// Channel Ids
public static final String CHANNEL_POWER = "power";
public static final String CHANNEL_VOLUME = "volume";
public static final String CHANNEL_VOLUME_DB = "volumeDB";
public static final String CHANNEL_MUTE = "mute";
public static final String CHANNEL_ACTIVE_INPUT = "activeInput";
public static final String CHANNEL_ACTIVE_INPUT_SHORT_NAME = "activeInputShortName";
public static final String CHANNEL_ACTIVE_INPUT_LONG_NAME = "activeInputLongName";

// Connection-related configuration parameters
public static final int DEFAULT_PORT = 14999;
public static final int DEFAULT_RECONNECT_INTERVAL_MINUTES = 2;
public static final int DEFAULT_COMMAND_DELAY_MSEC = 100;

public static final char COMMAND_TERMINATION_CHAR = ';';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright (c) 2010-2023 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.anthem.internal;

import static org.openhab.binding.anthem.internal.AnthemBindingConstants.*;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link AnthemConfiguration} is responsible for storing the Anthem thing configuration.
*
* @author Mark Hilbush - Initial contribution
*/
@NonNullByDefault
public class AnthemConfiguration {
public String host = "";

public int port = DEFAULT_PORT;

public int reconnectIntervalMinutes = DEFAULT_RECONNECT_INTERVAL_MINUTES;

public int commandDelayMsec = DEFAULT_COMMAND_DELAY_MSEC;

public boolean isValid() {
return !host.isBlank();
}

@Override
public String toString() {
return "AnthemConfiguration{ host=" + host + ", port=" + port + ", reconectIntervalMinutes="
+ reconnectIntervalMinutes + ", commandDelayMsec=" + commandDelayMsec + " }";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright (c) 2010-2023 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.anthem.internal;

import static org.openhab.binding.anthem.internal.AnthemBindingConstants.SUPPORTED_THING_TYPES_UIDS;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.anthem.internal.handler.AnthemHandler;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerFactory;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;

/**
* The {@link AnthemHandlerFactory} is responsible for creating Anthem thing handlers.
*
* @author Mark Hilbush - Initial contribution
*/
@NonNullByDefault
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.anthem", configurationPolicy = ConfigurationPolicy.OPTIONAL)
public class AnthemHandlerFactory extends BaseThingHandlerFactory {

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) {
return new AnthemHandler(thing);
}
return null;
}
}
Loading