Skip to content

Commit

Permalink
Add UoM for more channels
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Schofield <[email protected]> (github: andrew-schofield)
  • Loading branch information
andrew-schofield committed Aug 12, 2018
1 parent 0524323 commit 98363f0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,17 @@
</channel-type>

<channel-type id="batteryVoltage-channel" advanced="true">
<item-type>Number</item-type>
<item-type>Number:ElectricPotential</item-type>
<label>Battery Voltage</label>
<description>Current Battery Voltage for the device</description>
<state readOnly="true" pattern="%.1f V" />
<state readOnly="true" pattern="%.1f %unit%" />
</channel-type>

<channel-type id="demandPercent-channel">
<item-type>Number</item-type>
<item-type>Number:Dimensionless</item-type>
<label>Current Heat Demand</label>
<description>Current heat demand in %</description>
<state readOnly="true" pattern="%d %%"></state>
<state readOnly="true" pattern="%d %unit%"></state>
</channel-type>

<channel-type id="heatRequest-channel">
Expand Down Expand Up @@ -330,10 +330,10 @@
</channel-type>

<channel-type id="heatChannelDemand-channel">
<item-type>Number</item-type>
<item-type>Number:Dimensionless</item-type>
<label>Channel 1 Heat Demand</label>
<description>Current heat demand in %</description>
<state readOnly="true" pattern="%d %%"></state>
<state readOnly="true" pattern="%d %unit%"></state>
</channel-type>

<channel-type id="demandState-channel">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.library.types.DecimalType;
import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.library.types.StringType;
import org.eclipse.smarthome.core.library.unit.SmartHomeUnits;
import org.eclipse.smarthome.core.thing.ChannelUID;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingStatus;
Expand Down Expand Up @@ -173,7 +175,7 @@ private State getSignalStrength() {
@SuppressWarnings("null")
private State getHeatChannel1Demand() {
if (heatingChannels != null && heatingChannels.size() >= 1) {
return new DecimalType(heatingChannels.get(0).getPercentageDemand());
return new QuantityType<>(heatingChannels.get(0).getPercentageDemand(), SmartHomeUnits.PERCENT);
}

return UnDefType.UNDEF;
Expand All @@ -182,7 +184,7 @@ private State getHeatChannel1Demand() {
@SuppressWarnings("null")
private State getHeatChannel2Demand() {
if (heatingChannels != null && heatingChannels.size() >= 2) {
return new DecimalType(heatingChannels.get(1).getPercentageDemand());
return new QuantityType<>(heatingChannels.get(1).getPercentageDemand(), SmartHomeUnits.PERCENT);
}

return UnDefType.UNDEF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.library.types.StringType;
import org.eclipse.smarthome.core.library.unit.SIUnits;
import org.eclipse.smarthome.core.library.unit.SmartHomeUnits;
import org.eclipse.smarthome.core.thing.ChannelUID;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingStatus;
Expand Down Expand Up @@ -171,7 +172,7 @@ private State getTemperature() {

private State getDemand() {
if (room != null) {
return new DecimalType(room.getPercentageDemand());
return new QuantityType<>(room.getPercentageDemand(), SmartHomeUnits.PERCENT);
}

return UnDefType.UNDEF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.library.types.StringType;
import org.eclipse.smarthome.core.library.unit.SIUnits;
import org.eclipse.smarthome.core.library.unit.SmartHomeUnits;
import org.eclipse.smarthome.core.thing.ChannelUID;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingStatus;
Expand Down Expand Up @@ -189,7 +190,7 @@ private State getBatteryVoltage() {
if (roomStat != null && bridgeHandler != null) {
Device device = bridgeHandler.getExtendedDeviceProperties(roomStat.getId());
if (device != null) {
return new DecimalType((float) device.getBatteryVoltage() / 10);
return new QuantityType<>((float) device.getBatteryVoltage() / 10, SmartHomeUnits.VOLT);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.library.types.StringType;
import org.eclipse.smarthome.core.library.unit.SIUnits;
import org.eclipse.smarthome.core.library.unit.SmartHomeUnits;
import org.eclipse.smarthome.core.thing.ChannelUID;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingStatus;
Expand Down Expand Up @@ -123,7 +124,7 @@ private State getSetPoint() {

private State getDemand() {
if (smartValve != null) {
return new DecimalType(smartValve.getPercentageDemand());
return new QuantityType<>(smartValve.getPercentageDemand(), SmartHomeUnits.PERCENT);
}
return UnDefType.UNDEF;
}
Expand Down Expand Up @@ -189,7 +190,7 @@ private State getBatteryVoltage() {
if (smartValve != null && bridgeHandler != null) {
Device device = bridgeHandler.getExtendedDeviceProperties(smartValve.getId());
if (device != null) {
return new DecimalType((float) device.getBatteryVoltage() / 10);
return new QuantityType<>((float) device.getBatteryVoltage() / 10, SmartHomeUnits.VOLT);
}
}

Expand Down

0 comments on commit 98363f0

Please sign in to comment.