From: lolodomo Date: Thu, 8 Aug 2024 19:29:41 +0000 (+0200) Subject: [freeboxos] Use rpm as unit for fan sensors (#17198) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=6445e64300e269dc7ce14a6f439909737cd4f5ee;p=openhab-addons.git [freeboxos] Use rpm as unit for fan sensors (#17198) Also patch the label for hard disk sensor. Signed-off-by: Laurent Garnier --- diff --git a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ServerHandler.java b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ServerHandler.java index d3601357d4..d8fb8cd432 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ServerHandler.java +++ b/bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ServerHandler.java @@ -39,7 +39,6 @@ import org.openhab.binding.freeboxos.internal.api.rest.SystemManager; import org.openhab.binding.freeboxos.internal.api.rest.SystemManager.Config; import org.openhab.binding.freeboxos.internal.api.rest.UPnPAVManager; import org.openhab.binding.freeboxos.internal.api.rest.WifiManager; -import org.openhab.core.library.CoreItemFactory; import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.unit.SIUnits; import org.openhab.core.library.unit.Units; @@ -87,17 +86,22 @@ public class ServerHandler extends ApiConsumerHandler implements FreeDeviceIntf config.sensors().forEach(sensor -> { ChannelUID sensorId = new ChannelUID(thing.getUID(), GROUP_SENSORS, sensor.id()); if (getThing().getChannel(sensorId) == null) { - channels.add(ChannelBuilder.create(sensorId).withLabel(sensor.name()) - .withAcceptedItemType("Number:Temperature") - .withType(new ChannelTypeUID(BINDING_ID + ":temperature")).build()); + String label = sensor.name(); + // For revolution, API returns only "Disque dur" so we patch it to have naming consistency with other + // temperature sensors + if ("Disque dur".equals(label)) { + label = "Température " + label; + } + channels.add(ChannelBuilder.create(sensorId).withLabel(label).withAcceptedItemType("Number:Temperature") + .withType(new ChannelTypeUID(BINDING_ID, "temperature")).build()); } }); config.fans().forEach(sensor -> { ChannelUID sensorId = new ChannelUID(thing.getUID(), GROUP_FANS, sensor.id()); if (getThing().getChannel(sensorId) == null) { channels.add(ChannelBuilder.create(sensorId).withLabel(sensor.name()) - .withAcceptedItemType(CoreItemFactory.NUMBER) - .withType(new ChannelTypeUID(BINDING_ID + ":fanspeed")).build()); + .withAcceptedItemType("Number:Frequency").withType(new ChannelTypeUID(BINDING_ID, "fanspeed")) + .build()); } }); if (nbInit != channels.size()) { diff --git a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml index db8fe7bf08..70d9a68d98 100644 --- a/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml +++ b/bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml @@ -75,11 +75,11 @@ - Number:Frequency + Number:Frequency Actual measured rotation speed of the fan Fan - +