mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[opensprinkler] fix nextDuration UoM transformation (#8753)
Fixes #8541 Signed-off-by: Holger Eisold <kugelsicha@gmail.com>
This commit is contained in:
parent
33575e26f7
commit
3e82b5d6de
@ -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:
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user