Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[freeboxos] Add unitHint on few channel types #17259

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,8 @@ private void fetchConnectionStatus() throws FreeboxException {
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))) {
Expand All @@ -209,14 +207,12 @@ private void fetchConnectionStatus() throws FreeboxException {
}

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
</channel-type>

<channel-type id="lcd-orientation" advanced="true">
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down