small fix to thermostat controller

This commit is contained in:
Jacob Salvi 2020-04-25 14:38:47 +02:00
parent fc25177a69
commit 886f43bf62
2 changed files with 8 additions and 8 deletions

View file

@ -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;
}

View file

@ -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<BooleanTrigger<? extends Device>> triggers = new HashSet<>();
// @OneToMany(mappedBy = "scene", orphanRemoval = true)
// @GsonExclude
// private Set<BooleanTrigger<? extends Device>> triggers = new HashSet<>()
/** Creates a thermostat with a temperature sensor and its initial OFF state */
public Thermostat() {