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 670df76..4cffe89 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 @@ -25,6 +25,7 @@ public class ThermostatController { private Thermostat save(Thermostat newT, ThermostatSaveRequest t, final Principal principal) { newT.setTargetTemperature(t.getTargetTemperature()); + thermostatService.populateMeasuredTemperature(newT); newT.setId(t.getId()); newT.setName(t.getName()); newT.setRoomId(t.getRoomId()); @@ -32,7 +33,6 @@ public class ThermostatController { newT.setOn(t.isTurnOn()); newT = deviceService.saveAsOwner(newT, principal.getName()); - thermostatService.populateMeasuredTemperature(newT); return newT; } 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 2dd3772..bb4bef1 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 @@ -1,13 +1,9 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models; -import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude; import com.google.gson.annotations.SerializedName; import java.math.BigDecimal; -import java.util.HashSet; -import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.OneToMany; import javax.persistence.Transient; import javax.validation.constraints.NotNull; @@ -38,6 +34,10 @@ public class Thermostat extends Switchable implements BooleanTriggerable { BigDecimal measured = this.getMeasuredTemperature(); BigDecimal target = this.getTargetTemperature(); + System.out.println("measured is"); + // System.out.println(measured.getClass().getName()); + System.out.println("target is"); + System.out.println(target.getClass().getName()); BigDecimal delta = target.subtract(measured); if (delta.abs().doubleValue() < 0.25) { @@ -85,9 +85,9 @@ public class Thermostat extends Switchable implements BooleanTriggerable { @Column private boolean useExternalSensors = false; - @OneToMany(mappedBy = "scene", orphanRemoval = true) - @GsonExclude - private Set> triggers = new HashSet<>(); + // @OneToMany(mappedBy = "scene", orphanRemoval = true) + // @GsonExclude + // private Set> triggers = new HashSet<>() /** Creates a thermostat with a temperature sensor and its initial OFF state */ public Thermostat() {