Skip to content

Commit

Permalink
[emotiva] Initial contribution
Browse files Browse the repository at this point in the history
Signed-off-by: Espen Fossen <espenaf@junta.no>
  • Loading branch information
espenaf committed Mar 12, 2024
1 parent 6139368 commit e3162e3
Show file tree
Hide file tree
Showing 73 changed files with 7,390 additions and 0 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
/bundles/org.openhab.binding.electroluxair/ @jannegpriv
/bundles/org.openhab.binding.elerotransmitterstick/ @vbier
/bundles/org.openhab.binding.elroconnects/ @mherwege
/bundles/org.openhab.binding.emotiva/ @espenaf
/bundles/org.openhab.binding.energenie/ @hmerk
/bundles/org.openhab.binding.energidataservice/ @jlaur
/bundles/org.openhab.binding.enigma2/ @gdolfen
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 @@ -466,6 +466,11 @@
<artifactId>org.openhab.binding.elroconnects</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.emotiva</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.energenie</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.emotiva/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
134 changes: 134 additions & 0 deletions bundles/org.openhab.binding.emotiva/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Emotiva Binding

This binding integrates Emotiva AV processors by using the Emotiva Network Remote Control protocol.

## Supported Things

This binding supports Emotiva processors with Emotiva Network Remote Control protocol support.
The thing type for all of them is `processor`.

Tested models: Emotiva XMC-2

## Discovery

The binding automatically discovers devices on your network.

## Thing Configuration

The Emotiva Processor thing requires the `ipAddress` it can connect to.
There are more parameters which all have defaults set.

| Parameter | Values | Default |
|-----------------|---------------------------------------------------------------|---------|
| ipAddress | IP address of the processor | - |
| controlPort | port number, e.g. 7002 | 7002 |
| notifyPort | port number, e.g. 7003 | 7003 |
| setupPortTCP | port number, e.g. 7100 | 7100 |
| menuNotifyPort | port number, e.g. 7005 | 7005 |
| protocolVersion | Emotiva Network Protocol version, e.g. 3.0 | 2.0 |
| keepAlive | Time between notification update from device, in milliseconds | 7500 |


## Channels

The Emotiva Processor supports the following channels (some channels are model specific):

| Channel Type ID | Item Type | Description |
|------------------------------|-------------|-----------------------------------------------------------|
| _Main zone_ | | |
| mainZone#power | Switch (RW) | Main zone power on/off |
| mainZone#volume | Dimmer (RW) | Main zone volume |
| mainZone#volumeDB | Number (RW) | Main zone volume in dB (-96 to 15) |
| mainZone#mute | Switch (RW) | Main zone mute |
| mainZone#source | String (RW) | Main zone input (HDMI1, TUNER, ARC, ...) |
| _Zone 2_ | | |
| zone2#power | Switch (RW) | Zone 2 power on/off |
| zone2#volume | Dimmer (RW) | Zone 2 volume |
| zone2#volumeDB | Number (RW) | Zone 2 volume in dB (-80 offset) |
| zone2#mute | Switch (RW) | Zone 2 mute |
| zone2#input | String (RW) | Zone 2 input |
| _General_ | | |
| general#power | Switch (RW) | Power on/off |
| general#standby | Switch (RW) | Set in standby mode |
| general#dim | Switch (RW) | Cycle through FP dimness settings |
| general#mode | String (RW) | Select audio mode (auto, dts, ...) |
| general#speaker_preset | String (RW) | Select speaker presets (preset1, preset2) |
| general#center | Number (RW) | Center Volume increment up/down (0.5 step) |
| general#subwoofer | Number (RW) | Subwoofer Volume increment up/down (0.5 step) |
| general#surround | Number (RW) | Surround Volume increment up/down (0.5 step) |
| general#back | Number (RW) | Back Volume increment up/down (0.5 step) |
| general#loudness | Switch (RW) | Loudness on/off |
| general#treble | Number (RW) | Treble Volume increment up/down (0.5 step) |
| general#bass | Number (RW) | Bass Volume increment up/down (0.5 step) |
| general#tuner_band | String (R) | Tuner band, (AM, FM) |
| general#tuner_channel | String (RW) | User–assigned station name |
| general#tuner_signal | String (R) | Tuner signal quality |
| general#tuner_program | String (R) | Tuner program: "Country", "Rock", ... |
| general#tuner_RDS | String (R) | Tuner RDS string |
| general#audio_input | String (R) | Audio input source |
| general#audio_bitstream | String (R) | Audio input bitstream type: "PCM 2.0", "ATMOS", etc. |
| general#audio_bits | String (R) | Audio input bits: "32kHZ 24bits", etc. |
| general#video_input | String (R) | Video input source |
| general#video_format | String (R) | Video input format: "1920x1080i/60", "3840x2160p/60", etc. |
| general#video_space | String (R) | Video input space: "YcbCr 8bits", etc. |
| general#input_[1-8] | String (R) | User assigned input names |
| general#selected_mode | String (R) | User selected mode for the main zone |
| general#selected_movie_music | String (R) | User selected movie or music mode for main zone |
| general#mode_ref_stereo | String (R) | Label for mode: Reference Stereo |
| general#mode_stereo | String (R) | Label for mode: Stereo |
| general#mode_music | String (R) | Label for mode: Music |
| general#mode_movie | String (R) | Label for mode: Movie |
| general#mode_direct | String (R) | Label for mode: Direct |
| general#mode_dolby | String (R) | Label for mode: Dolby |
| general#mode_dts | String (R) | Label for mode: DTS |
| general#mode_all_stereo | String (R) | Label for mode: All Stereo |
| general#mode_auto | String (R) | Label for mode: Auto |
| general#mode_surround | String (RW) | Select audio mode (Auto, Stereo, Dolby, ...) |
| general#bar | String (R) | Text displayed on front panel bar of device |

(R) = read-only (no updates possible)
(RW) = read-write

## Full Example

`.things` file:

```perl
Thing emotiva:processor:1 "XMC-2" @ "Living room" [ipAddress="10.0.0.100", protocolVersion="3.0"]
```

`.items` file:

```perl
Switch emotiva_power "Processor" {channel="emotiva:processor:1:general#power"}
Dimmer emotiva_volume "Volume [%d %%]" {channel="emotiva:processor:1:mainZone#volume"}
Number:Dimensionless emotiva_volume_db "Volume [%d dB]" {channel="emotiva:processor:1:mainzone#volume_db"}
Switch emotiva_mute "Mute" {channel="emotiva:processor:1:mainZone#mute"}
String emotiva_source "Source [%s]" {channel="emotiva:processor:1:mainZone#input" }
String emotiva_mode_surround "Surround Mode: [%s]" {channel="emotiva:processor:1:general#mode_surround"}
Number:Dimensionless emotiva_speakers_center "Center Trim [%.1f dB]" { channel = "emotiva:processor:xmc2:general#center" }
Switch emotiva_zone2power "Zone 2" {channel="emotiva:processor:1:zone2#power"}
```

`.sitemap` file:

```perl
...
Group item=emotiva_input label="Processor" icon="receiver" {
Default item=emotiva_power
Default item=emotiva_mute
Setpoint item=emotiva_volume
Default item=emotiva_volume_db step=2 minValue=-96.0 maxValue=15.0
Selection item=emotiva_source
Text item=emotiva_mode_surround
Setpoint item=emotiva_speakers_center step=0.5 minValue=-12.0 maxValue=12.0
Default item=emotiva_zone2power
}
...
```

## Network Remote Control protocol Reference

These resources can be useful to learn what to send using the `command`channel:

- [Emotiva Remote Interface Description](https://www.dropbox.com/sh/lvo9lbhu89jqfdb/AACa4iguvWK3I6ONjIpyM5Zca/Emotiva_Remote_Interface_Description%20V3.1.docx)
25 changes: 25 additions & 0 deletions bundles/org.openhab.binding.emotiva/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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.2.0-SNAPSHOT</version>
</parent>

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

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

<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.emotiva-${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-emotiva" description="Emotiva Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.emotiva/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/**
* Copyright (c) 2010-2024 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.emotiva.internal;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

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

/**
* The {@link EmotivaBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Espen Fossen - Initial contribution
*/
@NonNullByDefault
public class EmotivaBindingConstants {

public static final String BINDING_ID = "emotiva";
/** Property name to uniquely identify (discovered) things. */
public static final String UNIQUE_PROPERTY_NAME = "ip4Address";

/** Default port used to discover Emotiva devices. */
public static final int DEFAULT_PING_PORT = 7000;

/** Default port used to receive transponder (discovered) Emotiva devices. */
public static final int DEFAULT_TRANSPONDER_PORT = 7001;

/** Thing is set OFFLINE after so many communication errors. */
static int CONNECTION_RETRIES = 3;

// List of all Thing Type UIDs
public static final ThingTypeUID THING_PROCESSOR = new ThingTypeUID(BINDING_ID, "processor");

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashSet<>(List.of(THING_PROCESSOR));

/* Default values for Emotiva communication */
public static final String DEFAULT_CONTROL_MESSAGE_SET_DEFAULT_VALUE = "0";
public static final String DEFAULT_SUBSCRIPTION_PROPERTY_ACK = "yes";

/* Default values for Emotiva channels */
public static final int DEFAULT_TRIM_MIN_DECIBEL = -12;
public static final int DEFAULT_TRIM_MAX_DECIBEL = 12;
public static int DEFAULT_VOLUME_MIN_DECIBEL = -96;
public static int DEFAULT_VOLUME_MAX_DECIBEL = 15;
public static final String NAME_SOURCES_MAP = "sources";

/* Protocol V1 channels */
public static final String CHANNEL_STANDBY = "general#standby";
public static final String CHANNEL_MAIN_ZONE_POWER = "mainZone#power";
public static final String CHANNEL_SOURCE = "mainZone#source";
public static final String CHANNEL_MUTE = "mainZone#mute";
public static final String CHANNEL_DIM = "general#dim";
public static final String CHANNEL_MODE = "general#mode";
public static final String CHANNEL_CENTER = "general#center";
public static final String CHANNEL_SUBWOOFER = "general#subwoofer";
public static final String CHANNEL_SURROUND = "general#surround";
public static final String CHANNEL_BACK = "general#back";
public static final String CHANNEL_MODE_SURROUND = "general#mode_surround";
public static final String CHANNEL_SPEAKER_PRESET = "general#speaker_preset";
public static final String CHANNEL_MAIN_VOLUME = "mainZone#volume";
public static final String CHANNEL_MAIN_VOLUME_DB = "mainZone#volume_db";
public static final String CHANNEL_LOUDNESS = "general#loudness";
public static final String CHANNEL_ZONE2_POWER = "zone2#zone2_power";
public static final String CHANNEL_ZONE2_VOLUME = "zone2#zone2_volume";
public static final String CHANNEL_ZONE2_VOLUME_DB = "zone2#zone2_volume_db";
public static final String CHANNEL_ZONE2_MUTE = "zone2#zone2_mute";
public static final String CHANNEL_ZONE2_INPUT = "zone2#zone2_input";
public static final String CHANNEL_FREQUENCY = "general#frequency";
public static final String CHANNEL_SEEK = "general#seek";
public static final String CHANNEL_CHANNEL = "general#channel";
public static final String CHANNEL_TUNER_BAND = "general#tuner_band";
public static final String CHANNEL_TUNER_CHANNEL = "general#tuner_channel";
public static final String CHANNEL_TUNER_CHANNEL_SELECT = "general#tuner_channel_select";
public static final String CHANNEL_TUNER_SIGNAL = "general#tuner_signal";
public static final String CHANNEL_TUNER_PROGRAM = "general#tuner_program";
public static final String CHANNEL_TUNER_RDS = "general#tuner_RDS";
public static final String CHANNEL_AUDIO_INPUT = "general#audio_input";
public static final String CHANNEL_AUDIO_BITSTREAM = "general#audio_bitstream";
public static final String CHANNEL_AUDIO_BITS = "general#audio_bits";
public static final String CHANNEL_VIDEO_INPUT = "general#video_input";
public static final String CHANNEL_VIDEO_FORMAT = "general#video_format";
public static final String CHANNEL_VIDEO_SPACE = "general#video_space";
public static final String CHANNEL_INPUT1 = "general#input_1";
public static final String CHANNEL_INPUT2 = "general#input_2";
public static final String CHANNEL_INPUT3 = "general#input_3";
public static final String CHANNEL_INPUT4 = "general#input_4";
public static final String CHANNEL_INPUT5 = "general#input_5";
public static final String CHANNEL_INPUT6 = "general#input_6";
public static final String CHANNEL_INPUT7 = "general#input_7";
public static final String CHANNEL_INPUT8 = "general#input_8";
public static final String CHANNEL_MODE_REF_STEREO = "general#mode_ref_stereo";
public static final String CHANNEL_MODE_STEREO = "general#mode_stereo";
public static final String CHANNEL_MODE_MUSIC = "general#mode_music";
public static final String CHANNEL_MODE_MOVIE = "general#mode_movie";
public static final String CHANNEL_MODE_DIRECT = "general#mode_direct";
public static final String CHANNEL_MODE_DOLBY = "general#mode_dolby";
public static final String CHANNEL_MODE_DTS = "general#mode_dts";
public static final String CHANNEL_MODE_ALL_STEREO = "general#mode_all_stereo";
public static final String CHANNEL_MODE_AUTO = "general#mode_auto";

/* Protocol V2 channels */
public static final String CHANNEL_SELECTED_MODE = "general#selected_mode";
public static final String CHANNEL_SELECTED_MOVIE_MUSIC = "general#selected_movie_music";

/* Protocol V3 channels */
public static final String CHANNEL_MENU = "general#menu";
public static final String CHANNEL_TREBLE = "general#treble";
public static final String CHANNEL_BASS = "general#bass";
public static final String CHANNEL_WIDTH = "general#width";
public static final String CHANNEL_HEIGHT = "general#height";
public static final String CHANNEL_BAR = "general#bar";
}

0 comments on commit e3162e3

Please sign in to comment.