]> git.basschouten.com Git - openhab-addons.git/commitdiff
[freeboxos] Use rpm as unit for fan sensors (#17198)
authorlolodomo <lg.hc@free.fr>
Thu, 8 Aug 2024 19:29:41 +0000 (21:29 +0200)
committerGitHub <noreply@github.com>
Thu, 8 Aug 2024 19:29:41 +0000 (21:29 +0200)
Also patch the label for hard disk sensor.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.freeboxos/src/main/java/org/openhab/binding/freeboxos/internal/handler/ServerHandler.java
bundles/org.openhab.binding.freeboxos/src/main/resources/OH-INF/thing/channel-types.xml

index d3601357d4b8de72cf775bd0076dd58060109dd6..d8fb8cd432caa51bd68e57eec1145731025527c0 100644 (file)
@@ -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()) {
index db8fe7bf0858b25b654ffcb1cfabd2d2a66214f0..70d9a68d982940bb2cd519408904727ec66a43e6 100644 (file)
        </channel-type>
 
        <channel-type id="fanspeed" advanced="true">
-               <item-type>Number:Frequency</item-type>
+               <item-type unitHint="rpm">Number:Frequency</item-type>
                <label>Fan Speed</label>
                <description>Actual measured rotation speed of the fan</description>
                <category>Fan</category>
-               <state readOnly="true" pattern="%d %unit%"/>
+               <state readOnly="true" pattern="%d rpm"/>
        </channel-type>
 
        <channel-type id="samba-file-status" advanced="true">