Thermostats fixed

This commit is contained in:
Claudio Maggioni (maggicl) 2020-05-02 11:12:11 +02:00
parent 3d74e02434
commit e0ab831be9
3 changed files with 17 additions and 12 deletions

View file

@ -28,11 +28,14 @@ public class ThermostatController {
newT.setId(t.getId()); newT.setId(t.getId());
newT.setName(t.getName()); newT.setName(t.getName());
newT.setRoomId(t.getRoomId()); newT.setRoomId(t.getRoomId());
newT.setMeasuredTemperature(t.getMeasuredTemperature());
newT.setUseExternalSensors(t.isUseExternalSensors()); newT.setUseExternalSensors(t.isUseExternalSensors());
newT.setOn(t.isTurnOn()); newT.setOn(false);
System.out.println(newT);
thermostatService.populateMeasuredTemperature(newT); thermostatService.populateMeasuredTemperature(newT);
newT = thermostatRepository.save(newT);
newT.setOn(t.isTurnOn());
newT = deviceService.saveAsOwner(newT, principal.getName()); newT = deviceService.saveAsOwner(newT, principal.getName());
return newT; return newT;
} }

View file

@ -22,8 +22,6 @@ public class ThermostatSaveRequest {
@NotNull private boolean useExternalSensors; @NotNull private boolean useExternalSensors;
@NotNull private BigDecimal measuredTemperature;
/** State of this thermostat */ /** State of this thermostat */
@NotNull private boolean turnOn; @NotNull private boolean turnOn;
@ -74,12 +72,4 @@ public class ThermostatSaveRequest {
public void setId(long id) { public void setId(long id) {
this.id = id; this.id = id;
} }
public BigDecimal getMeasuredTemperature() {
return measuredTemperature;
}
public void setMeasuredTemperature(BigDecimal measuredTemperature) {
this.measuredTemperature = measuredTemperature;
}
} }

View file

@ -87,6 +87,18 @@ public class Thermostat extends Switchable implements BooleanTriggerable {
this.mode = Mode.OFF; 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) { public void setMode(Mode state) {
this.mode = state; this.mode = state;
} }