Skip to content

Commit

Permalink
[coronastats] Use QuantityType instead of plain DecimalType (#7477)
Browse files Browse the repository at this point in the history
Signed-off-by: Kai Kreuzer <kai@openhab.org>
  • Loading branch information
kaikreuzer authored Apr 25, 2020
1 parent bf56172 commit 642613f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
import java.util.HashMap;
import java.util.Map;

import javax.measure.quantity.Dimensionless;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.library.types.DecimalType;
import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.types.State;
import org.eclipse.smarthome.core.types.UnDefType;

import tec.uom.se.AbstractUnit;

/**
* The {@link CoronaStatsCountry} class holds the internal data representation of each Country
*
Expand Down Expand Up @@ -55,7 +59,7 @@ protected State parseToState(int count) {
if (count == -1) {
return UnDefType.NULL;
} else {
return new DecimalType(count);
return new QuantityType<Dimensionless>(count, AbstractUnit.ONE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,49 @@
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

<channel-type id="cases">
<item-type>Number</item-type>
<item-type>Number:Dimensionless</item-type>
<label>Total Cases</label>
<state readOnly="true"/>
</channel-type>

<channel-type id="today_cases">
<item-type>Number</item-type>
<item-type>Number:Dimensionless</item-type>
<label>New Cases</label>
<state readOnly="true"/>
</channel-type>

<channel-type id="deaths">
<item-type>Number</item-type>
<item-type>Number:Dimensionless</item-type>
<label>Total Deaths</label>
<state readOnly="true"/>
</channel-type>

<channel-type id="today_deaths">
<item-type>Number</item-type>
<item-type>Number:Dimensionless</item-type>
<label>New Deaths</label>
<state readOnly="true"/>
</channel-type>

<channel-type id="recovered">
<item-type>Number</item-type>
<item-type>Number:Dimensionless</item-type>
<label>Recovered</label>
<state readOnly="true"/>
</channel-type>

<channel-type id="active">
<item-type>Number</item-type>
<item-type>Number:Dimensionless</item-type>
<label>Active</label>
<state readOnly="true"/>
</channel-type>

<channel-type id="critical">
<item-type>Number</item-type>
<item-type>Number:Dimensionless</item-type>
<label>Critical</label>
<state readOnly="true"/>
</channel-type>

<channel-type id="tests">
<item-type>Number</item-type>
<item-type>Number:Dimensionless</item-type>
<label>Tests</label>
<state readOnly="true"/>
</channel-type>
Expand Down

0 comments on commit 642613f

Please sign in to comment.