small fix to thermostat controller
This commit is contained in:
parent
fc25177a69
commit
886f43bf62
2 changed files with 8 additions and 8 deletions
|
@ -25,6 +25,7 @@ public class ThermostatController {
|
||||||
|
|
||||||
private Thermostat save(Thermostat newT, ThermostatSaveRequest t, final Principal principal) {
|
private Thermostat save(Thermostat newT, ThermostatSaveRequest t, final Principal principal) {
|
||||||
newT.setTargetTemperature(t.getTargetTemperature());
|
newT.setTargetTemperature(t.getTargetTemperature());
|
||||||
|
thermostatService.populateMeasuredTemperature(newT);
|
||||||
newT.setId(t.getId());
|
newT.setId(t.getId());
|
||||||
newT.setName(t.getName());
|
newT.setName(t.getName());
|
||||||
newT.setRoomId(t.getRoomId());
|
newT.setRoomId(t.getRoomId());
|
||||||
|
@ -32,7 +33,6 @@ public class ThermostatController {
|
||||||
newT.setOn(t.isTurnOn());
|
newT.setOn(t.isTurnOn());
|
||||||
|
|
||||||
newT = deviceService.saveAsOwner(newT, principal.getName());
|
newT = deviceService.saveAsOwner(newT, principal.getName());
|
||||||
thermostatService.populateMeasuredTemperature(newT);
|
|
||||||
return newT;
|
return newT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ -38,6 +34,10 @@ public class Thermostat extends Switchable implements BooleanTriggerable {
|
||||||
|
|
||||||
BigDecimal measured = this.getMeasuredTemperature();
|
BigDecimal measured = this.getMeasuredTemperature();
|
||||||
BigDecimal target = this.getTargetTemperature();
|
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);
|
BigDecimal delta = target.subtract(measured);
|
||||||
|
|
||||||
if (delta.abs().doubleValue() < 0.25) {
|
if (delta.abs().doubleValue() < 0.25) {
|
||||||
|
@ -85,9 +85,9 @@ public class Thermostat extends Switchable implements BooleanTriggerable {
|
||||||
|
|
||||||
@Column private boolean useExternalSensors = false;
|
@Column private boolean useExternalSensors = false;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "scene", orphanRemoval = true)
|
// @OneToMany(mappedBy = "scene", orphanRemoval = true)
|
||||||
@GsonExclude
|
// @GsonExclude
|
||||||
private Set<BooleanTrigger<? extends Device>> triggers = new HashSet<>();
|
// private Set<BooleanTrigger<? extends Device>> triggers = new HashSet<>()
|
||||||
|
|
||||||
/** Creates a thermostat with a temperature sensor and its initial OFF state */
|
/** Creates a thermostat with a temperature sensor and its initial OFF state */
|
||||||
public Thermostat() {
|
public Thermostat() {
|
||||||
|
|
Loading…
Reference in a new issue