From c5996608a414642e01f6a185deaf4716a348cdb5 Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Wed, 25 Mar 2020 22:34:15 +0100 Subject: [PATCH] fixed dimmable light --- .../sa4/sanmarinoes/smarthut/models/DimmableLight.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableLight.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableLight.java index 7a59f7b..6b537c6 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableLight.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableLight.java @@ -39,6 +39,10 @@ public class DimmableLight extends Switchable { @Max(100) private Integer intensity = 0; + @NotNull + @Column(nullable = false) + private Integer oldIntensity = 100; + public Integer getIntensity() { return intensity; } @@ -55,8 +59,10 @@ public class DimmableLight extends Switchable { this.intensity = 0; } else if (intensity > 100) { this.intensity = 100; + this.oldIntensity = 100; } else { this.intensity = intensity; + this.oldIntensity = intensity; } } @@ -67,13 +73,13 @@ public class DimmableLight extends Switchable { @Override public void setOn(boolean on) { - intensity = on ? 100 : 0; + intensity = on ? oldIntensity : 0; } public void setDimmerId(Long dimmerId) { this.dimmerId = dimmerId; super.setSwitchId(null); - }; + } @Override public void setSwitchId(Long switchId) {