Skip to content

Commit

Permalink
Improve volume event handling (#17387)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
  • Loading branch information
mlobstein authored Sep 8, 2024
1 parent d161354 commit 2fb5740
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 135 deletions.
266 changes: 138 additions & 128 deletions bundles/org.openhab.binding.kaleidescape/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public class KaleidescapeBindingConstants {
public static final String MUSIC_RANDOM_OFF = "MUSIC_RANDOM_OFF";

public static final String SEND_TO_SYSLOG = "SEND_TO_SYSLOG:INFORMATION:";
public static final String SEND_EVENT_VOLUME_CAPABILITIES_3 = "SEND_EVENT:VOLUME_CAPABILITIES=3";
public static final String SEND_EVENT_VOLUME_CAPABILITIES_15 = "SEND_EVENT:VOLUME_CAPABILITIES=15";
public static final String SEND_EVENT_VOLUME_LEVEL_EQ = "SEND_EVENT:VOLUME_LEVEL=";
public static final String SEND_EVENT_MUTE = "SEND_EVENT:MUTE_";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class KaleidescapeThingConfiguration {
public @Nullable Integer updatePeriod;
public boolean volumeEnabled;
public Integer initialVolume = 0;
public boolean volumeBasicEnabled;
public boolean loadHighlightedDetails;
public boolean loadAlbumDetails;
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public class KaleidescapeHandler extends BaseThingHandler implements Kaleidescap
protected int metaRuntimeMultiple = 1;
protected int volume = 0;
protected boolean volumeEnabled = false;
protected boolean volumeBasicEnabled = false;
protected boolean isMuted = false;
protected boolean isLoadHighlightedDetails = false;
protected boolean isLoadAlbumDetails = false;
Expand Down Expand Up @@ -162,6 +163,8 @@ public void initialize() {
this.volume = config.initialVolume;
this.updateState(VOLUME, new PercentType(this.volume));
this.updateState(MUTE, OnOffType.OFF);
} else if (config.volumeBasicEnabled) {
this.volumeBasicEnabled = true;
}

if (serialPort != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,10 @@ public void handleMessage(String message, KaleidescapeHandler handler) {
handler.connector.sendCommand(SEND_EVENT_VOLUME_LEVEL_EQ + handler.volume);
handler.connector.sendCommand(SEND_EVENT_MUTE + (handler.isMuted ? MUTE_ON : MUTE_OFF));
}
} else if (handler.volumeBasicEnabled) {
synchronized (handler.sequenceLock) {
handler.connector.sendCommand(SEND_EVENT_VOLUME_CAPABILITIES_3);
}
}
break;
case "VOLUME_UP":
Expand Down Expand Up @@ -514,10 +518,8 @@ public void handleMessage(String message, KaleidescapeHandler handler) {
}
}
break;
// the default is to just publish all other USER_DEFINED_EVENTs
default:
handler.updateChannel(KaleidescapeBindingConstants.USER_DEFINED_EVENT, new StringType(message));
}
handler.updateChannel(KaleidescapeBindingConstants.USER_DEFINED_EVENT, new StringType(message));
} catch (KaleidescapeException e) {
logger.debug("USER_DEFINED_EVENT - exception on message: {}", message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
<default>0</default>
</parameter>
<parameter name="volumeEnabled" type="boolean" required="false">
<label>Volume Control Enabled</label>
<description>Enable the Volume and Mute controls in the Kaleidescape iPad &amp; Phone apps and track their status in
<label>Advanced Volume Control Enabled</label>
<description>Enable the Volume and Mute controls in the Kaleidescape iPad &amp; phone apps and track their status in
the binding. Disabled by default to prevent conflicts with other control systems that may already be controlling
volume on this zone.</description>
<default>false</default>
Expand All @@ -43,6 +43,12 @@
<description>When the binding starts up, set the Inital Volume level to this value (Default 25).</description>
<default>25</default>
</parameter>
<parameter name="volumeBasicEnabled" type="boolean" required="false">
<label>Basic Volume Control Enabled</label>
<description>Enable Basic Volume up-down and Mute toggle controls in the Kaleidescape iPad &amp; phone apps. Cannot
be used at the same time as volumeEnabled set to true.</description>
<default>false</default>
</parameter>
<parameter name="loadHighlightedDetails" type="boolean" required="false">
<label>Load Highlighted Details</label>
<description>When enabled the binding will automatically load the metadata channels when the selected item in the UI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ thing-type.config.kaleidescape.kaleidescapedevice.serialPort.label = Serial Port
thing-type.config.kaleidescape.kaleidescapedevice.serialPort.description = (Optional) Serial Port to use for connecting directly to an individual Kaleidescape component.
thing-type.config.kaleidescape.kaleidescapedevice.updatePeriod.label = Update Period
thing-type.config.kaleidescape.kaleidescapedevice.updatePeriod.description = Tells the component how often time status updates should be sent; Values greater than 1 are not yet implmented by the protocol. Setting to 1 may impact openHAB system performance due to constant updates while content playing.
thing-type.config.kaleidescape.kaleidescapedevice.volumeEnabled.label = Volume Control Enabled
thing-type.config.kaleidescape.kaleidescapedevice.volumeEnabled.description = Enable the Volume and Mute controls in the Kaleidescape iPad & Phone apps and track their status in the binding. Disabled by default to prevent conflicts with other control systems that may already be controlling volume on this zone.
thing-type.config.kaleidescape.kaleidescapedevice.volumeBasicEnabled.label = Basic Volume Control Enabled
thing-type.config.kaleidescape.kaleidescapedevice.volumeBasicEnabled.description = Enable Basic Volume up-down and Mute toggle controls in the Kaleidescape iPad & phone apps. Cannot be used at the same time as volumeEnabled set to true.
thing-type.config.kaleidescape.kaleidescapedevice.volumeEnabled.label = Advanced Volume Control Enabled
thing-type.config.kaleidescape.kaleidescapedevice.volumeEnabled.description = Enable the Volume and Mute controls in the Kaleidescape iPad & phone apps and track their status in the binding. Disabled by default to prevent conflicts with other control systems that may already be controlling volume on this zone.

# channel group types

Expand Down

0 comments on commit 2fb5740

Please sign in to comment.