[freeboxos] Use rpm as unit for fan sensors (#17198)

Also patch the label for hard disk sensor.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
lolodomo 2024-08-08 21:29:41 +02:00 committed by Ciprian Pascu
parent 4e9d6d6890
commit 87611a59da
2 changed files with 12 additions and 8 deletions

View 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()) {

View File

@ -75,11 +75,11 @@
</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">