From: Florian Hotze Date: Sun, 25 Jun 2023 10:14:58 +0000 (+0200) Subject: [yamahamusiccast] Fix DecimalType commands for volumeDB channel (#15124) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=6dff1ffa632aedcd23a4c9ab2b7d633c8ae42826;p=openhab-addons.git [yamahamusiccast] Fix DecimalType commands for volumeDB channel (#15124) * [yamahamusiccast] Fix volumeDB channel doesn't accept DecimalType and QuantityType commands Signed-off-by: Florian Hotze --- diff --git a/bundles/org.openhab.binding.yamahamusiccast/src/main/java/org/openhab/binding/yamahamusiccast/internal/YamahaMusiccastHandler.java b/bundles/org.openhab.binding.yamahamusiccast/src/main/java/org/openhab/binding/yamahamusiccast/internal/YamahaMusiccastHandler.java index d0ddb81dab..a42eba855b 100644 --- a/bundles/org.openhab.binding.yamahamusiccast/src/main/java/org/openhab/binding/yamahamusiccast/internal/YamahaMusiccastHandler.java +++ b/bundles/org.openhab.binding.yamahamusiccast/src/main/java/org/openhab/binding/yamahamusiccast/internal/YamahaMusiccastHandler.java @@ -228,7 +228,16 @@ public class YamahaMusiccastHandler extends BaseThingHandler { } 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); @@ -238,7 +247,7 @@ public class YamahaMusiccastHandler extends BaseThingHandler { 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()); } }