Skip to content

Commit

Permalink
[charts] Add support for QuantityTypes to DefaultChartProvider (openh…
Browse files Browse the repository at this point in the history
…ab#1789)

Fixes openhab#1781

Signed-off-by: Kai Kreuzer <kai@openhab.org>
  • Loading branch information
kaikreuzer committed Nov 2, 2020
1 parent 5a9c5e7 commit 35b0a12
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.persistence.FilterCriteria;
import org.openhab.core.persistence.FilterCriteria.Ordering;
import org.openhab.core.persistence.HistoricItem;
Expand Down Expand Up @@ -262,6 +263,8 @@ public BufferedImage createChart(String serviceId, String theme, Date startTime,
double convertData(State state) {
if (state instanceof DecimalType) {
return ((DecimalType) state).doubleValue();
} else if (state instanceof QuantityType) {
return ((QuantityType<?>) state).doubleValue();
} else if (state instanceof OnOffType) {
return (state == OnOffType.OFF) ? 0 : 1;
} else if (state instanceof OpenClosedType) {
Expand Down

0 comments on commit 35b0a12

Please sign in to comment.