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

[emotiva] Initial contribution #16499

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[emotiva] Initial contribution #16499

wants to merge 1 commit into from

Conversation

espenaf
Copy link
Contributor

@espenaf espenaf commented Mar 7, 2024

This PR adds support for Emotiva Audio Corporation AV processors based on the Emotiva Network Remote Control protocol. Discovery is supported.

Binding has only been tested with an XMC-2, so please test and give feedback for other devices.

Has support for all Emotiva notification types in version 2.0 and 3.0 of the protocol, and adds support for almost all commands, has support for Zone 2 controls, browsing and controlling the menu and using the radio tuner.

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/emotiva-av-processor-binding/154406/1

@mlobstein mlobstein added the new binding If someone has started to work on a binding. For a new binding PR. label Mar 9, 2024
@mlobstein
Copy link
Contributor

The build is failing because your commit it not signed. See here for instructions to fix it: https://github.com/openhab/openhab-addons/pull/16499/checks?check_run_id=22412921872

"@text/message.processor.connection.failed");
disconnect();
scheduleConnectRetry(retryConnectInMinutes);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking out loud: could (some of) this status updating be moved to handleStatusUpdate()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, the connection method is synchronized and try to make sure the connection is either working or we need to schedule a retry. Suggestions are welcome.

@espenaf espenaf force-pushed the emotiva branch 3 times, most recently from bf10246 to 612fde5 Compare April 30, 2024 16:47
@espenaf espenaf changed the title [emotiva][WIP] Initial contribution [emotiva] Initial contribution Apr 30, 2024
@espenaf espenaf marked this pull request as ready for review April 30, 2024 16:53
@espenaf espenaf requested a review from a team as a code owner April 30, 2024 16:53
Signed-off-by: Espen Fossen <espenaf@junta.no>
Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution. Looked at all except the key controller/handlers, will do in a next round.
For each comment, try to check if it can also apply to other parts of the code.

Please check that al SAT errors are fxied and the build comes without any warnings.

xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

<thing-type id="processor">
<label>Emotiva Processor Binding Thing</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<label>Emotiva Processor Binding Thing</label>
<label>Emotiva Processor</label>

</channel-group>
<channel-group id="zone2" typeId="zone">
<label>Zone 2 Control</label>
<description>Channels for zone2 of this processor.</description>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<description>Channels for zone2 of this processor.</description>
<description>Channels for zone 2 of this processor.</description>

<label>General Control</label>
<description>General channels for this processor.</description>
<channels>
<channel id="power" typeId="mainPower"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please adapt all channel names and types to the naming convention.
Details here:
https://www.openhab.org/docs/developer/guidelines.html#naming-convention

<channel-type id="dim">
<item-type>Number:Percentage</item-type>
<label>Front Panel Dimness</label>
<description>Percentage of dimness: "0", "20", "40", "60", "80", "100"</description>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ony those presets are possible, you could provide an option list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dim command only cycles through these values, so one cannot select a specific value.

<name>Emotiva Binding</name>
<description>This is the binding for devices from the Emotiva Audio Corporation.</description>
<connection>local</connection>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if this can be extended with suggestion finder details
https://www.openhab.org/docs/developer/addons/addon.html#discovery-methods

Comment on lines +15 to +36
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.CHANNEL_SOURCE;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.CHANNEL_TUNER_BAND;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.CHANNEL_TUNER_CHANNEL_SELECT;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.CHANNEL_ZONE2_SOURCE;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.DEFAULT_TRIM_MAX_DECIBEL;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.DEFAULT_TRIM_MIN_DECIBEL;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.DEFAULT_VOLUME_MAX_DECIBEL;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.DEFAULT_VOLUME_MIN_DECIBEL;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.MAP_SOURCES_MAIN_ZONE;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.MAP_SOURCES_ZONE_2;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.PROTOCOL_V3_LEVEL_MULTIPLIER;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.TRIM_SET_COMMAND_SUFFIX;
import static org.openhab.binding.emotiva.internal.EmotivaCommandHelper.clamp;
import static org.openhab.binding.emotiva.internal.EmotivaCommandHelper.volumePercentageToDecibel;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaCommandType.NUMBER;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaCommandType.SET;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaCommandType.TOGGLE;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaCommandType.UP_DOWN_HALF;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaCommandType.UP_DOWN_SINGLE;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaDataType.FREQUENCY_HERTZ;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaSubscriptionTags.tuner_band;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaSubscriptionTags.tuner_channel;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.CHANNEL_SOURCE;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.CHANNEL_TUNER_BAND;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.CHANNEL_TUNER_CHANNEL_SELECT;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.CHANNEL_ZONE2_SOURCE;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.DEFAULT_TRIM_MAX_DECIBEL;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.DEFAULT_TRIM_MIN_DECIBEL;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.DEFAULT_VOLUME_MAX_DECIBEL;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.DEFAULT_VOLUME_MIN_DECIBEL;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.MAP_SOURCES_MAIN_ZONE;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.MAP_SOURCES_ZONE_2;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.PROTOCOL_V3_LEVEL_MULTIPLIER;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.TRIM_SET_COMMAND_SUFFIX;
import static org.openhab.binding.emotiva.internal.EmotivaCommandHelper.clamp;
import static org.openhab.binding.emotiva.internal.EmotivaCommandHelper.volumePercentageToDecibel;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaCommandType.NUMBER;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaCommandType.SET;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaCommandType.TOGGLE;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaCommandType.UP_DOWN_HALF;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaCommandType.UP_DOWN_SINGLE;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaDataType.FREQUENCY_HERTZ;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaSubscriptionTags.tuner_band;
import static org.openhab.binding.emotiva.internal.protocol.EmotivaSubscriptionTags.tuner_channel;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.*
import static org.openhab.binding.emotiva.internal.protocol.*

}

public EmotivaControlDTO createDTO(Command ohCommand, @Nullable State previousState) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

}
case UP_DOWN_HALF -> {
if (ohCommand instanceof Number value) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +15 to +17
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.DISCOVERY_BROADCAST_ADDRESS;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.DISCOVERY_TIMEOUT_SECONDS;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.SUPPORTED_THING_TYPES_UIDS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.DISCOVERY_BROADCAST_ADDRESS;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.DISCOVERY_TIMEOUT_SECONDS;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.SUPPORTED_THING_TYPES_UIDS;
import static org.openhab.binding.emotiva.internal.EmotivaBindingConstants.*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new binding If someone has started to work on a binding. For a new binding PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants