Skip to content

Commit

Permalink
[yamahamusiccast] Fix DecimalType commands for volumeDB channel (open…
Browse files Browse the repository at this point in the history
…hab#15124)

* [yamahamusiccast] Fix volumeDB channel doesn't accept DecimalType and QuantityType commands

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
  • Loading branch information
florian-h05 committed Jun 25, 2023
1 parent d62c006 commit 6dff1ff
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,16 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}
break;
case CHANNEL_VOLUMEDB:
setVolumeDb(((QuantityType<?>) command).floatValue(), zone, this.host);
float volumeDb;
if (command instanceof QuantityType<?> qt) {
volumeDb = qt.toUnit(Units.DECIBEL).floatValue();
} else if (command instanceof DecimalType dt) {
volumeDb = dt.floatValue();
} else {
logger.debug("Command has wrong type, QuantityType or DecimalType required!");
return;
}
setVolumeDb(volumeDb, zone, this.host);
localSyncVolume = Boolean.parseBoolean(getThing().getConfiguration().get("syncVolume").toString());
if (localSyncVolume == Boolean.TRUE) {
tmpString = getDistributionInfo(this.host);
Expand All @@ -238,7 +247,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
if ("server".equals(localRole)) {
for (JsonElement ip : distributioninfo.getClientList()) {
JsonObject clientObject = ip.getAsJsonObject();
setVolumeDbLinkedDevice(((DecimalType) command).floatValue(), zone,
setVolumeDbLinkedDevice(volumeDb, zone,
clientObject.get("ip_address").getAsString());
}
}
Expand Down

0 comments on commit 6dff1ff

Please sign in to comment.