From e0ab831be90a143dd6ee25ff2780eec6045abf52 Mon Sep 17 00:00:00 2001 From: "Claudio Maggioni (maggicl)" Date: Sat, 2 May 2020 11:12:11 +0200 Subject: [PATCH] Thermostats fixed --- .../smarthut/controller/ThermostatController.java | 7 +++++-- .../smarthut/dto/ThermostatSaveRequest.java | 10 ---------- .../sa4/sanmarinoes/smarthut/models/Thermostat.java | 12 ++++++++++++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/ThermostatController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/ThermostatController.java index 7a6fc59..12cd09b 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/ThermostatController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/ThermostatController.java @@ -28,11 +28,14 @@ public class ThermostatController { newT.setId(t.getId()); newT.setName(t.getName()); newT.setRoomId(t.getRoomId()); - newT.setMeasuredTemperature(t.getMeasuredTemperature()); newT.setUseExternalSensors(t.isUseExternalSensors()); - newT.setOn(t.isTurnOn()); + newT.setOn(false); + System.out.println(newT); thermostatService.populateMeasuredTemperature(newT); + newT = thermostatRepository.save(newT); + + newT.setOn(t.isTurnOn()); newT = deviceService.saveAsOwner(newT, principal.getName()); return newT; } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ThermostatSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ThermostatSaveRequest.java index 3986996..5ac3402 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ThermostatSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/ThermostatSaveRequest.java @@ -22,8 +22,6 @@ public class ThermostatSaveRequest { @NotNull private boolean useExternalSensors; - @NotNull private BigDecimal measuredTemperature; - /** State of this thermostat */ @NotNull private boolean turnOn; @@ -74,12 +72,4 @@ public class ThermostatSaveRequest { public void setId(long id) { this.id = id; } - - public BigDecimal getMeasuredTemperature() { - return measuredTemperature; - } - - public void setMeasuredTemperature(BigDecimal measuredTemperature) { - this.measuredTemperature = measuredTemperature; - } } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Thermostat.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Thermostat.java index e8f0e86..c02c4e4 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Thermostat.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Thermostat.java @@ -87,6 +87,18 @@ public class Thermostat extends Switchable implements BooleanTriggerable { this.mode = Mode.OFF; } + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Thermostat{"); + sb.append("targetTemperature=").append(targetTemperature); + sb.append(", internalSensorTemperature=").append(internalSensorTemperature); + sb.append(", mode=").append(mode); + sb.append(", measuredTemperature=").append(measuredTemperature); + sb.append(", useExternalSensors=").append(useExternalSensors); + sb.append('}'); + return sb.toString(); + } + public void setMode(Mode state) { this.mode = state; }