[opensprinkler] fix nextDuration UoM transformation (#8753)

Fixes #8541

Signed-off-by: Holger Eisold <kugelsicha@gmail.com>
This commit is contained in:
HoLLe 2020-10-15 18:03:53 +02:00 committed by GitHub
parent 33575e26f7
commit 3e82b5d6de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -21,7 +21,6 @@ import javax.measure.quantity.Time;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
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.thing.Channel;
@ -91,10 +90,11 @@ public class OpenSprinklerStationHandler extends OpenSprinklerBaseHandler {
return;
}
QuantityType<?> quantity = (QuantityType<?>) command;
this.nextDurationTime = quantity.toBigDecimal();
this.nextDurationTime = quantity.toUnit(Units.SECOND).toBigDecimal();
updateState(channelUID, quantity);
}
@SuppressWarnings("null")
private void handleStationStateCommand(OpenSprinklerApi api, Command command) {
if (!(command instanceof OnOffType)) {
logger.error("Received invalid command type for OpenSprinkler station ({}).", command);
@ -204,7 +204,7 @@ public class OpenSprinklerStationHandler extends OpenSprinklerBaseHandler {
case NEXT_DURATION:
BigDecimal duration = nextDurationValue();
if (duration != null) {
updateState(channel, new DecimalType(duration));
updateState(channel, new QuantityType<>(duration, Units.SECOND));
}
break;
case STATION_QUEUED:

View File

@ -120,6 +120,6 @@
<item-type>Number:Time</item-type>
<label>Next Open Duration</label>
<description>The duration the station will be opened the next time it is switched on.</description>
<state readOnly="false" pattern="%.0f s"/>
<state readOnly="false" pattern="%.0f min"/>
</channel-type>
</thing:thing-descriptions>