[charts] Add support for QuantityTypes to DefaultChartProvider (#1789)

Fixes #1781

Signed-off-by: Kai Kreuzer <kai@openhab.org>
pull/1792/head
Kai Kreuzer 2020-11-02 10:45:31 +01:00 committed by GitHub
parent 5a9c5e7d87
commit 35b0a1275e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -39,6 +39,7 @@ import org.openhab.core.items.ItemNotFoundException;
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;
@ -262,6 +263,8 @@ public class DefaultChartProvider implements ChartProvider {
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) {