mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[opensprinkler] fix nextDuration UoM transformation (#8727)
Fixes #8541 Signed-off-by: Holger Eisold <kugelsicha@gmail.com>
This commit is contained in:
parent
b9beaad5cd
commit
5e2c5345eb
@ -25,7 +25,6 @@ import org.openhab.binding.opensprinkler.internal.api.OpenSprinklerApi;
|
||||
import org.openhab.binding.opensprinkler.internal.api.exception.CommunicationApiException;
|
||||
import org.openhab.binding.opensprinkler.internal.api.exception.GeneralApiException;
|
||||
import org.openhab.binding.opensprinkler.internal.config.OpenSprinklerStationConfig;
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
import org.openhab.core.library.types.OnOffType;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.thing.Channel;
|
||||
@ -85,13 +84,14 @@ public class OpenSprinklerStationHandler extends OpenSprinklerBaseHandler {
|
||||
updateChannels();
|
||||
}
|
||||
|
||||
@SuppressWarnings("null")
|
||||
private void handleNextDurationCommand(ChannelUID channelUID, Command command) {
|
||||
if (!(command instanceof QuantityType<?>)) {
|
||||
logger.info("Ignoring implausible non-QuantityType command for NEXT_DURATION");
|
||||
return;
|
||||
}
|
||||
QuantityType<?> quantity = (QuantityType<?>) command;
|
||||
this.nextDurationTime = quantity.toBigDecimal();
|
||||
this.nextDurationTime = quantity.toUnit(Units.SECOND).toBigDecimal();
|
||||
updateState(channelUID, quantity);
|
||||
}
|
||||
|
||||
@ -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