Skip to content

Commit

Permalink
[draytonwiser] Updated hot water and room boost to return time in min…
Browse files Browse the repository at this point in the history
…utes

Signed-off-by: Andrew Schofield <the.uncle.fungus@gmail.com>
  • Loading branch information
andrew-schofield committed Jul 14, 2020
1 parent acdc665 commit a368b5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@

import java.util.List;

import javax.measure.quantity.Time;

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.library.unit.SmartHomeUnits;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.types.Command;
import org.eclipse.smarthome.core.types.State;
Expand Down Expand Up @@ -125,14 +129,13 @@ private State getBoostedState() {
private State getBoostRemainingState() {
if (getData().hotWater.size() >= 1) {
final HotWaterDTO firstChannel = getData().hotWater.get(0);
final Integer overrideTimeout = firstChannel.getOverrideTimeoutUnixTime();

if (firstChannel.getOverrideTimeoutUnixTime() != null
&& !"NONE".equalsIgnoreCase(firstChannel.getOverrideType())) {
return new DecimalType(
((firstChannel.getOverrideTimeoutUnixTime() - System.currentTimeMillis() / 1000L)) / 60);
if (overrideTimeout != null && !"NONE".equalsIgnoreCase(firstChannel.getOverrideType())) {
return new QuantityType<Time>(overrideTimeout - (System.currentTimeMillis() / 1000L), SmartHomeUnits.SECOND).toUnit(SmartHomeUnits.MINUTE);
}
}
return DecimalType.ZERO;
return new QuantityType<Time>(0, SmartHomeUnits.MINUTE);
}

static class HotWaterData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ private State getBoostedState() {
private State getBoostRemainingState() {
final Integer overrideTimeout = getData().getOverrideTimeoutUnixTime();
if (overrideTimeout != null && !"NONE".equalsIgnoreCase(getData().getOverrideType())) {
return new QuantityType<Time>(overrideTimeout - (System.currentTimeMillis() / 1000L), SmartHomeUnits.SECOND);
return new QuantityType<Time>(overrideTimeout - (System.currentTimeMillis() / 1000L), SmartHomeUnits.SECOND).toUnit(SmartHomeUnits.MINUTE);
}
return new QuantityType<Time>(0, SmartHomeUnits.SECOND);
return new QuantityType<Time>(0, SmartHomeUnits.MINUTE);
}

private void setBoostDuration(final int durationMinutes) throws DraytonWiserApiException {
Expand Down

0 comments on commit a368b5d

Please sign in to comment.