mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[freeboxos] Add unitHint on few channel types (#17259)
* [freeboxos] Add unitHint on few channel types Also remove an unused channel type "bandwidth". Also avoid unneeded unit conversion when updating channel state. Signed-off-by: Laurent Garnier <lg.hc@free.fr> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
d528605bcf
commit
330bcb54be
@ -192,10 +192,8 @@ public class ServerHandler extends ApiConsumerHandler implements FreeDeviceIntf
|
||||
updateRateBandwidth(status.rateUp(), status.bandwidthUp(), "up");
|
||||
updateRateBandwidth(status.rateDown(), status.bandwidthDown(), "down");
|
||||
|
||||
updateChannelQuantity(GROUP_CONNECTION_STATUS, BYTES_UP, new QuantityType<>(status.bytesUp(), OCTET),
|
||||
GIBIOCTET);
|
||||
updateChannelQuantity(GROUP_CONNECTION_STATUS, BYTES_DOWN, new QuantityType<>(status.bytesDown(), OCTET),
|
||||
GIBIOCTET);
|
||||
updateChannelQuantity(GROUP_CONNECTION_STATUS, BYTES_UP, status.bytesUp(), OCTET);
|
||||
updateChannelQuantity(GROUP_CONNECTION_STATUS, BYTES_DOWN, status.bytesDown(), OCTET);
|
||||
}
|
||||
if (anyChannelLinked(GROUP_FTTH,
|
||||
Set.of(SFP_PRESENT, SFP_ALIM, SFP_POWER, SFP_SIGNAL, SFP_LINK, SFP_PWR_TX, SFP_PWR_RX))) {
|
||||
@ -218,14 +216,12 @@ public class ServerHandler extends ApiConsumerHandler implements FreeDeviceIntf
|
||||
}
|
||||
|
||||
private void updateRateBandwidth(long rate, long bandwidth, String orientation) {
|
||||
QuantityType<?> rateUp = new QuantityType<>(rate * 8, Units.BIT_PER_SECOND);
|
||||
QuantityType<?> rateUp = new QuantityType<>(rate * 8, BIT_PER_SECOND);
|
||||
QuantityType<?> bandwidthUp = new QuantityType<>(bandwidth, BIT_PER_SECOND);
|
||||
updateChannelQuantity(GROUP_CONNECTION_STATUS, RATE + "-" + orientation, rateUp, KILOBIT_PER_SECOND);
|
||||
updateChannelQuantity(GROUP_CONNECTION_STATUS, BW + "-" + orientation, bandwidthUp, KILOBIT_PER_SECOND);
|
||||
updateChannelQuantity(GROUP_CONNECTION_STATUS, RATE + "-" + orientation, rateUp);
|
||||
updateChannelQuantity(GROUP_CONNECTION_STATUS, BW + "-" + orientation, bandwidthUp);
|
||||
updateChannelQuantity(GROUP_CONNECTION_STATUS, PCT_BW + "-" + orientation,
|
||||
!bandwidthUp.equals(QuantityType.ZERO) ? rateUp.multiply(HUNDRED).divide(bandwidthUp)
|
||||
: QuantityType.ZERO,
|
||||
Units.PERCENT);
|
||||
!bandwidthUp.equals(QuantityType.ZERO) ? rateUp.divide(bandwidthUp) : QuantityType.ZERO, PERCENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -214,8 +214,6 @@ channel-type.freeboxos.alarm-volume.label = Alarm Volume
|
||||
channel-type.freeboxos.alternate-ring.label = Alternating Ring
|
||||
channel-type.freeboxos.bandwidth-usage.label = Bandwidth Usage
|
||||
channel-type.freeboxos.bandwidth-usage.description = Current bandwidth usage
|
||||
channel-type.freeboxos.bandwidth.label = Bandwidth
|
||||
channel-type.freeboxos.bandwidth.description = Available bandwidth
|
||||
channel-type.freeboxos.basic-shutter.label = Shutter
|
||||
channel-type.freeboxos.basic-shutter.description = Shutter command
|
||||
channel-type.freeboxos.box-event.label = Server Event
|
||||
|
@ -5,11 +5,11 @@
|
||||
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
|
||||
|
||||
<channel-type id="lcd-brightness" advanced="true">
|
||||
<item-type>Number:Dimensionless</item-type>
|
||||
<item-type unitHint="%">Number:Dimensionless</item-type>
|
||||
<label>Screen Brightness</label>
|
||||
<description>Brightness level of the screen in percent</description>
|
||||
<category>Light</category>
|
||||
<state pattern="%d %unit%" min="0" max="100"/>
|
||||
<state pattern="%d %%" min="0" max="100"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="lcd-orientation" advanced="true">
|
||||
@ -104,40 +104,33 @@
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="bandwidth-usage">
|
||||
<item-type>Number:Dimensionless</item-type>
|
||||
<item-type unitHint="%">Number:Dimensionless</item-type>
|
||||
<label>Bandwidth Usage</label>
|
||||
<description>Current bandwidth usage</description>
|
||||
<state readOnly="true" pattern="%.2f %unit%"/>
|
||||
<state readOnly="true" pattern="%.0f %%"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="transfer-rate">
|
||||
<item-type>Number:DataTransferRate</item-type>
|
||||
<item-type unitHint="Mbit/s">Number:DataTransferRate</item-type>
|
||||
<label>Transfer Rate</label>
|
||||
<description>Current transfer rate</description>
|
||||
<state readOnly="true" pattern="%.2f %unit%"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="transfer-rate-bps" advanced="true">
|
||||
<item-type>Number:DataTransferRate</item-type>
|
||||
<item-type unitHint="bit/s">Number:DataTransferRate</item-type>
|
||||
<label>Transfer Rate</label>
|
||||
<description>Current transfer rate</description>
|
||||
<state readOnly="true" pattern="%.2f bit/s"/>
|
||||
<state readOnly="true" pattern="%.0f bit/s"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="transfer-bytes" advanced="true">
|
||||
<item-type>Number:DataAmount</item-type>
|
||||
<item-type unitHint="GB">Number:DataAmount</item-type>
|
||||
<label>Transfered Bytes</label>
|
||||
<description>Total data transfered since last connection</description>
|
||||
<state readOnly="true" pattern="%.2f %unit%"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="bandwidth" advanced="true">
|
||||
<item-type>Number:DataTransferRate</item-type>
|
||||
<label>Bandwidth</label>
|
||||
<description>Available bandwidth</description>
|
||||
<state readOnly="true" pattern="%.2f %unit%"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="uptime" advanced="true">
|
||||
<item-type>Number:Time</item-type>
|
||||
<label>Uptime</label>
|
||||
@ -451,7 +444,7 @@
|
||||
<item-type unitHint="%">Number:Dimensionless</item-type>
|
||||
<label>Alarm Volume</label>
|
||||
<category>oh:freeboxos:sirene</category>
|
||||
<state min="0" max="100" step="1" pattern="%d %unit%"/>
|
||||
<state min="0" max="100" step="1" pattern="%d %%"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="alarm-pin">
|
||||
|
Loading…
Reference in New Issue
Block a user