From 872013a70030b9a8ce1b3535b1bbf8da565d06d1 Mon Sep 17 00:00:00 2001 From: mlobstein Date: Wed, 13 Dec 2023 05:27:46 -0600 Subject: [PATCH] Add support for 4 zone model (#16043) Signed-off-by: Michael Lobstein --- .../README.md | 14 +- .../MonopriceAudioBindingConstants.java | 1 + .../MonopriceAudioHandlerFactory.java | 9 +- .../communication/AmplifierModel.java | 15 ++ .../handler/MonopriceAudioHandler.java | 3 +- .../OH-INF/i18n/monopriceaudio.properties | 56 +++++ .../resources/OH-INF/thing/monoprice4.xml | 238 ++++++++++++++++++ 7 files changed, 328 insertions(+), 8 deletions(-) create mode 100644 bundles/org.openhab.binding.monopriceaudio/src/main/resources/OH-INF/thing/monoprice4.xml diff --git a/bundles/org.openhab.binding.monopriceaudio/README.md b/bundles/org.openhab.binding.monopriceaudio/README.md index f6a866fde..5c60d9909 100644 --- a/bundles/org.openhab.binding.monopriceaudio/README.md +++ b/bundles/org.openhab.binding.monopriceaudio/README.md @@ -3,6 +3,7 @@ This binding can be used to control the following types of whole house multi-zone amplifier systems: - Monoprice MPR-SG6Z (10761), Monoprice Passive Matrix (39261), Dayton Audio DAX66 or compatible clones +- Monoprice 44519 4 zone / 6 source variant of the 10761 **(untested)** - Monoprice 31028 or OSD Audio PAM1270 **(untested)** - Dayton Audio DAX88 **(untested)** - Xantech MRC88, MX88, MRAUDIO8X8 or CM8X8 **(untested)** @@ -21,9 +22,11 @@ Or you can connect it for example to a Raspberry Pi and use [ser2net Linux tool] ## Supported Things Monoprice 10761 & 39261 or Dayton Audio DAX66 amplifiers use the `amplifier` thing id. Up to 18 zones with 3 linked amps and 6 source inputs are supported. -Note: Compatible clones (including 4 zone versions) from McLELLAND, Factor, Soundavo, etc. should work as well. +Note: Compatible clones from McLELLAND, Factor, Soundavo, etc. should work as well. -***The following three thing types were implemented via available documentation only and have not been tested. Please open an issue for any bugs found when using these thing types.*** +***The following thing types were implemented via available documentation only and have not been tested. Please open an issue for any bugs found when using these thing types.*** + +Monoprice 44519 4 zone variants use the `monoprice4` thing id. Up to 12 zones with 3 linked amps and 6 source inputs are supported. Monoprice 31028 or OSD Audio PAM1270 70 volt amplifiers use the `monoprice70` thing id. 6 zones per amp (not linkable) and 2 source inputs are supported. @@ -63,7 +66,7 @@ The thing has the following configuration parameters (number of sources and zone Some notes: -- On the 10761/DAX66 amp, activating the 'Page All Zones' feature can only be done through the +12v trigger input on the back of the amplifier. +- On the 10761/44519/DAX66 amp, activating the 'Page All Zones' feature can only be done through the +12v trigger input on the back of the amplifier. - On Linux, you may get an error stating the serial port cannot be opened when the MonopriceAudio binding tries to load. - You can get around this by adding the `openhab` user to the `dialout` group like this: `usermod -a -G dialout openhab`. @@ -121,6 +124,9 @@ monopriceaudio:amplifier:myamp "Monoprice WHA" [ serialPort="COM5", pollingInter // Monoprice 10761, 39261 / DAX66 (serial over IP connection) monopriceaudio:amplifier:myamp "Monoprice WHA" [ host="192.168.0.10", port=8080, pollingInterval=15, numZones=6, inputLabel1="Chromecast", inputLabel2="Radio", inputLabel3="CD Player", inputLabel4="Bluetooth Audio", inputLabel5="HTPC", inputLabel6="Phono" ] +// Monoprice 44519 +monopriceaudio:monoprice4:myamp "Monoprice WHA" [ serialPort="COM5", pollingInterval=15, numZones=4, inputLabel1="Chromecast", inputLabel2="Radio", inputLabel3="CD Player", inputLabel4="Bluetooth Audio", inputLabel5="HTPC", inputLabel6="Phono" ] + // Monoprice 31028 or OSD Audio PAM1270 monopriceaudio:monoprice70:myamp "Monoprice WHA" [ serialPort="COM5", pollingInterval=30, numZones=6, inputLabel1="Source 0 - Bus", inputLabel2="Source 1 - Line" ] @@ -136,7 +142,7 @@ monopriceaudio:xantech:myamp "Xantech WHA" [ serialPort="COM5", pollingInterval= monoprice.items: ```java -// substitute 'amplifier' for the appropriate thing id if using 31028, DAX88 or Xantech amplifier +// substitute 'amplifier' for the appropriate thing id if using 44519, 31028, DAX88 or Xantech amplifier Switch all_allpower "All Zones Power" { channel="monopriceaudio:amplifier:myamp:all#allpower" } Number all_source "Source Input [%s]" { channel="monopriceaudio:amplifier:myamp:all#allsource" } diff --git a/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/MonopriceAudioBindingConstants.java b/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/MonopriceAudioBindingConstants.java index 2f08c00de..acdbb484a 100644 --- a/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/MonopriceAudioBindingConstants.java +++ b/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/MonopriceAudioBindingConstants.java @@ -30,6 +30,7 @@ public class MonopriceAudioBindingConstants { // List of all Thing Type UIDs // to avoid breaking existing installations, the 10761/DAX66 will still be known as 'amplifier' public static final ThingTypeUID THING_TYPE_MP = new ThingTypeUID(BINDING_ID, "amplifier"); + public static final ThingTypeUID THING_TYPE_MP4 = new ThingTypeUID(BINDING_ID, "monoprice4"); public static final ThingTypeUID THING_TYPE_MP70 = new ThingTypeUID(BINDING_ID, "monoprice70"); public static final ThingTypeUID THING_TYPE_DAX88 = new ThingTypeUID(BINDING_ID, "dax88"); public static final ThingTypeUID THING_TYPE_XT = new ThingTypeUID(BINDING_ID, "xantech"); diff --git a/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/MonopriceAudioHandlerFactory.java b/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/MonopriceAudioHandlerFactory.java index b8e91bd8b..5cdad1175 100644 --- a/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/MonopriceAudioHandlerFactory.java +++ b/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/MonopriceAudioHandlerFactory.java @@ -43,8 +43,8 @@ import org.slf4j.LoggerFactory; @Component(configurationPid = "binding.monopriceaudio", service = ThingHandlerFactory.class) public class MonopriceAudioHandlerFactory extends BaseThingHandlerFactory { - private static final Set SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_MP, THING_TYPE_MP70, - THING_TYPE_DAX88, THING_TYPE_XT); + private static final Set SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_MP, THING_TYPE_MP4, + THING_TYPE_MP70, THING_TYPE_DAX88, THING_TYPE_XT); private final SerialPortManager serialPortManager; @@ -73,6 +73,11 @@ public class MonopriceAudioHandlerFactory extends BaseThingHandlerFactory { serialPortManager); } + if (THING_TYPE_MP4.equals(thingTypeUID)) { + return new MonopriceAudioHandler(thing, AmplifierModel.MONOPRICE4, stateDescriptionProvider, + serialPortManager); + } + if (THING_TYPE_MP70.equals(thingTypeUID)) { return new MonopriceAudioHandler(thing, AmplifierModel.MONOPRICE70, stateDescriptionProvider, serialPortManager); diff --git a/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/communication/AmplifierModel.java b/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/communication/AmplifierModel.java index 6fc2dc6c8..fa3151e46 100644 --- a/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/communication/AmplifierModel.java +++ b/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/communication/AmplifierModel.java @@ -47,6 +47,21 @@ public enum AmplifierModel { new StateOption("5", config.inputLabel5), new StateOption("6", config.inputLabel6)); } }, + // Monoprice 44519 4 zone variant + MONOPRICE4("<", "\r", "?", "", "#>", "PR", "CH", "VO", "MU", "TR", "BS", "BL", "DT", 38, -7, 7, 7, -10, 10, 10, 12, + 6, true, List.of("11", "12", "13", "14", "21", "22", "23", "24", "31", "32", "33", "34")) { + @Override + public MonopriceAudioZoneDTO getZoneData(String newZoneData) { + return getMonopriceZoneData(newZoneData); + } + + @Override + public List getSourceLabels(MonopriceAudioThingConfiguration config) { + return List.of(new StateOption("1", config.inputLabel1), new StateOption("2", config.inputLabel2), + new StateOption("3", config.inputLabel3), new StateOption("4", config.inputLabel4), + new StateOption("5", config.inputLabel5), new StateOption("6", config.inputLabel6)); + } + }, // Dayton Audio DAX88 DAX88("<", "\r", "?", "", ">", "PR", "CH", "VO", "MU", "TR", "BS", "BL", "DT", 38, -12, 12, 12, -10, 10, 10, 8, 8, true, List.of("01", "02", "03", "04", "05", "06", "07", "08")) { diff --git a/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/handler/MonopriceAudioHandler.java b/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/handler/MonopriceAudioHandler.java index ab270297d..b8e6782e7 100644 --- a/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/handler/MonopriceAudioHandler.java +++ b/bundles/org.openhab.binding.monopriceaudio/src/main/java/org/openhab/binding/monopriceaudio/internal/handler/MonopriceAudioHandler.java @@ -441,6 +441,7 @@ public class MonopriceAudioHandler extends BaseThingHandler implements Monoprice @Override public void onNewMessageEvent(MonopriceAudioMessageEvent evt) { + updateStatus(ThingStatus.ONLINE); String key = evt.getKey(); switch (key) { @@ -510,8 +511,6 @@ public class MonopriceAudioHandler extends BaseThingHandler implements Monoprice if (error != null) { closeConnection(); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, error); - } else { - updateStatus(ThingStatus.ONLINE); } } } diff --git a/bundles/org.openhab.binding.monopriceaudio/src/main/resources/OH-INF/i18n/monopriceaudio.properties b/bundles/org.openhab.binding.monopriceaudio/src/main/resources/OH-INF/i18n/monopriceaudio.properties index 5920f7336..263da5658 100644 --- a/bundles/org.openhab.binding.monopriceaudio/src/main/resources/OH-INF/i18n/monopriceaudio.properties +++ b/bundles/org.openhab.binding.monopriceaudio/src/main/resources/OH-INF/i18n/monopriceaudio.properties @@ -65,6 +65,34 @@ thing-type.monopriceaudio.dax88.group.zone7.label = Zone 7 thing-type.monopriceaudio.dax88.group.zone7.description = The Controls for Zone 7 thing-type.monopriceaudio.dax88.group.zone8.label = Zone 8 thing-type.monopriceaudio.dax88.group.zone8.description = The Controls for Zone 8 +thing-type.monopriceaudio.monoprice4.label = Monoprice 44519 4 Zone Amplifier +thing-type.monopriceaudio.monoprice4.description = A Multi-zone Whole House Amplifier System +thing-type.monopriceaudio.monoprice4.group.all.label = All Zones +thing-type.monopriceaudio.monoprice4.group.all.description = Control All Zones Simultaneously +thing-type.monopriceaudio.monoprice4.group.zone1.label = Zone 1 +thing-type.monopriceaudio.monoprice4.group.zone1.description = The Controls for Zone 1 +thing-type.monopriceaudio.monoprice4.group.zone10.label = Zone 10 +thing-type.monopriceaudio.monoprice4.group.zone10.description = The Controls for Zone 10 +thing-type.monopriceaudio.monoprice4.group.zone11.label = Zone 11 +thing-type.monopriceaudio.monoprice4.group.zone11.description = The Controls for Zone 11 +thing-type.monopriceaudio.monoprice4.group.zone12.label = Zone 12 +thing-type.monopriceaudio.monoprice4.group.zone12.description = The Controls for Zone 12 +thing-type.monopriceaudio.monoprice4.group.zone2.label = Zone 2 +thing-type.monopriceaudio.monoprice4.group.zone2.description = The Controls for Zone 2 +thing-type.monopriceaudio.monoprice4.group.zone3.label = Zone 3 +thing-type.monopriceaudio.monoprice4.group.zone3.description = The Controls for Zone 3 +thing-type.monopriceaudio.monoprice4.group.zone4.label = Zone 4 +thing-type.monopriceaudio.monoprice4.group.zone4.description = The Controls for Zone 4 +thing-type.monopriceaudio.monoprice4.group.zone5.label = Zone 5 +thing-type.monopriceaudio.monoprice4.group.zone5.description = The Controls for Zone 5 +thing-type.monopriceaudio.monoprice4.group.zone6.label = Zone 6 +thing-type.monopriceaudio.monoprice4.group.zone6.description = The Controls for Zone 6 +thing-type.monopriceaudio.monoprice4.group.zone7.label = Zone 7 +thing-type.monopriceaudio.monoprice4.group.zone7.description = The Controls for Zone 7 +thing-type.monopriceaudio.monoprice4.group.zone8.label = Zone 8 +thing-type.monopriceaudio.monoprice4.group.zone8.description = The Controls for Zone 8 +thing-type.monopriceaudio.monoprice4.group.zone9.label = Zone 9 +thing-type.monopriceaudio.monoprice4.group.zone9.description = The Controls for Zone 9 thing-type.monopriceaudio.monoprice70.label = Monoprice 31028 70V Amplifier thing-type.monopriceaudio.monoprice70.description = A Multi-zone Whole House Amplifier System thing-type.monopriceaudio.monoprice70.group.all.label = All Zones @@ -180,6 +208,34 @@ thing-type.config.monopriceaudio.dax88.port.label = Port thing-type.config.monopriceaudio.dax88.port.description = Communication Port for Serial over IP connection to the Dayton Amplifier thing-type.config.monopriceaudio.dax88.serialPort.label = Serial Port thing-type.config.monopriceaudio.dax88.serialPort.description = Serial Port to Use for Connecting to the Dayton Amplifier +thing-type.config.monopriceaudio.monoprice4.disableKeypadPolling.label = Disable Keypad Polling +thing-type.config.monopriceaudio.monoprice4.disableKeypadPolling.description = If physical keypads are not used, this option will disable polling the amplifier for zone updates +thing-type.config.monopriceaudio.monoprice4.host.label = Address +thing-type.config.monopriceaudio.monoprice4.host.description = Host Name or IP Address of the Monoprice Amplifier or Serial over IP device +thing-type.config.monopriceaudio.monoprice4.ignoreZones.label = Ignore Zones +thing-type.config.monopriceaudio.monoprice4.ignoreZones.description = (Optional) A Comma Seperated List of Zone Numbers That Will Ignore the 'All Zone' (Except All Off) Commands (ie: 1,6,10) +thing-type.config.monopriceaudio.monoprice4.initialAllVolume.label = Initial All Volume +thing-type.config.monopriceaudio.monoprice4.initialAllVolume.description = When 'All' Zones Are Activated, the Volume Will Reset to This Value (1-30; default 10) to Prevent Excessive Blaring of Sound ;) +thing-type.config.monopriceaudio.monoprice4.inputLabel1.label = Source 1 Input Label +thing-type.config.monopriceaudio.monoprice4.inputLabel1.description = Friendly Name for the Input Source to Be Displayed in the UI (ie: Chromecast, Radio, CD, etc.) +thing-type.config.monopriceaudio.monoprice4.inputLabel2.label = Source 2 Input Label +thing-type.config.monopriceaudio.monoprice4.inputLabel2.description = Friendly Name for the Input Source to Be Displayed in the UI (ie: Chromecast, Radio, CD, etc.) +thing-type.config.monopriceaudio.monoprice4.inputLabel3.label = Source 3 Input Label +thing-type.config.monopriceaudio.monoprice4.inputLabel3.description = Friendly Name for the Input Source to Be Displayed in the UI (ie: Chromecast, Radio, CD, etc.) +thing-type.config.monopriceaudio.monoprice4.inputLabel4.label = Source 4 Input Label +thing-type.config.monopriceaudio.monoprice4.inputLabel4.description = Friendly Name for the Input Source to Be Displayed in the UI (ie: Chromecast, Radio, CD, etc.) +thing-type.config.monopriceaudio.monoprice4.inputLabel5.label = Source 5 Input Label +thing-type.config.monopriceaudio.monoprice4.inputLabel5.description = Friendly Name for the Input Source to Be Displayed in the UI (ie: Chromecast, Radio, CD, etc.) +thing-type.config.monopriceaudio.monoprice4.inputLabel6.label = Source 6 Input Label +thing-type.config.monopriceaudio.monoprice4.inputLabel6.description = Friendly Name for the Input Source to Be Displayed in the UI (ie: Chromecast, Radio, CD, etc.) +thing-type.config.monopriceaudio.monoprice4.numZones.label = Number of Zones +thing-type.config.monopriceaudio.monoprice4.numZones.description = Number of Zones on the Amplifier to Utilize in the Binding (Up to 12 Zones With 3 Amplifiers Connected Together) +thing-type.config.monopriceaudio.monoprice4.pollingInterval.label = Polling Interval +thing-type.config.monopriceaudio.monoprice4.pollingInterval.description = Configures How Often to Poll the Amplifier to Check for Zone Updates (5-60; Default 15) +thing-type.config.monopriceaudio.monoprice4.port.label = Port +thing-type.config.monopriceaudio.monoprice4.port.description = Communication Port for Serial over IP connection to the Monoprice Amplifier (8080 for amps with built-in Serial over IP) +thing-type.config.monopriceaudio.monoprice4.serialPort.label = Serial Port +thing-type.config.monopriceaudio.monoprice4.serialPort.description = Serial Port to Use for Connecting to the Monoprice Amplifier thing-type.config.monopriceaudio.monoprice70.host.label = Address thing-type.config.monopriceaudio.monoprice70.host.description = Host Name or IP Address of the Machine Connected to the Monoprice Amplifier (Serial over IP) thing-type.config.monopriceaudio.monoprice70.ignoreZones.label = Ignore Zones diff --git a/bundles/org.openhab.binding.monopriceaudio/src/main/resources/OH-INF/thing/monoprice4.xml b/bundles/org.openhab.binding.monopriceaudio/src/main/resources/OH-INF/thing/monoprice4.xml new file mode 100644 index 000000000..65734b597 --- /dev/null +++ b/bundles/org.openhab.binding.monopriceaudio/src/main/resources/OH-INF/thing/monoprice4.xml @@ -0,0 +1,238 @@ + + + + + + + + A Multi-zone Whole House Amplifier System + + + + + + Control All Zones Simultaneously + + + + The Controls for Zone 1 + + + + The Controls for Zone 2 + + + + The Controls for Zone 3 + + + + The Controls for Zone 4 + + + + The Controls for Zone 5 + + + + The Controls for Zone 6 + + + + The Controls for Zone 7 + + + + The Controls for Zone 8 + + + + The Controls for Zone 9 + + + + The Controls for Zone 10 + + + + The Controls for Zone 11 + + + + The Controls for Zone 12 + + + + + + serial-port + false + + Serial Port to Use for Connecting to the Monoprice Amplifier + + + network-address + + Host Name or IP Address of the Monoprice Amplifier or Serial over IP device + + + + Communication Port for Serial over IP connection to the Monoprice Amplifier (8080 for amps with + built-in Serial over IP) + + + + Number of Zones on the Amplifier to Utilize in the Binding (Up to 12 Zones With 3 Amplifiers Connected + Together) + 4 + + + + Configures How Often to Poll the Amplifier to Check for Zone Updates (5-60; Default 15) + 15 + + + + (Optional) A Comma Seperated List of Zone Numbers That Will Ignore the 'All Zone' (Except All Off) + Commands (ie: 1,6,10) + + + + When 'All' Zones Are Activated, the Volume Will Reset to This Value (1-30; default 10) to Prevent + Excessive Blaring of Sound ;) + 10 + + + + Friendly Name for the Input Source to Be Displayed in the UI (ie: Chromecast, Radio, CD, etc.) + Source 1 + + + + Friendly Name for the Input Source to Be Displayed in the UI (ie: Chromecast, Radio, CD, etc.) + Source 2 + + + + Friendly Name for the Input Source to Be Displayed in the UI (ie: Chromecast, Radio, CD, etc.) + Source 3 + + + + Friendly Name for the Input Source to Be Displayed in the UI (ie: Chromecast, Radio, CD, etc.) + Source 4 + + + + Friendly Name for the Input Source to Be Displayed in the UI (ie: Chromecast, Radio, CD, etc.) + Source 5 + + + + Friendly Name for the Input Source to Be Displayed in the UI (ie: Chromecast, Radio, CD, etc.) + Source 6 + + + + If physical keypads are not used, this option will disable polling the amplifier for zone updates + false + + + + + + + Control All Zones Simultaneously + + + + + + + + + + + The Controls for the Zone + + + + + + + + + + + + + + + + Switch + + Turn All Zones On or Off + + + + Number + + Select the Source Input + + + + + Number + + Adjust the Treble + + + + + Number + + Adjust the Bass + + + + + Number + + Adjust the Balance + + + + + Switch + + Controls if the Zone Should Ignore an Incoming Audio Page + + + + Contact + + Indicates if the Page Mode is Active for This Zone + + + + + + + + + + Contact + + Indicates if a Physical Keypad is Attached to This Zone + + + + + + + + +