fix thermostat
This commit is contained in:
parent
7c1d010805
commit
c9f53f0c97
3 changed files with 10 additions and 3 deletions
|
@ -36,7 +36,13 @@ public class ThermostatController {
|
|||
newT = thermostatRepository.save(newT);
|
||||
|
||||
newT.setOn(t.isTurnOn());
|
||||
<<<<<<< Updated upstream
|
||||
return deviceService.saveAsOwner(newT, principal.getName());
|
||||
=======
|
||||
newT = deviceService.saveAsOwner(newT, principal.getName());
|
||||
System.out.println(newT);
|
||||
return newT;
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
|
|
|
@ -25,6 +25,6 @@ public interface ThermostatRepository extends DeviceRepository<Thermostat> {
|
|||
* @return an optional big decimal, empty if none found
|
||||
*/
|
||||
@Query(
|
||||
"SELECT AVG(s.value) FROM Sensor s JOIN s.room r WHERE s.sensor = 'TEMPERATURE' AND r.id = ?1")
|
||||
Optional<BigDecimal> getAverageTemperature(Long thermostatRoomId);
|
||||
"SELECT AVG(s.value) FROM Sensor s JOIN s.room r WHERE s.sensor = ?2 AND r.id = ?1")
|
||||
Optional<BigDecimal> getAverageTemperature(Long thermostatRoomId, Sensor.SensorType sensorType);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,8 @@ public class ThermostatService {
|
|||
Optional<BigDecimal> average;
|
||||
|
||||
if (thermostat.isUseExternalSensors()) {
|
||||
average = thermostatRepository.getAverageTemperature(thermostat.getRoomId());
|
||||
average = thermostatRepository.getAverageTemperature(thermostat.getRoomId(), Sensor.SensorType.TEMPERATURE);
|
||||
|
||||
} else {
|
||||
return thermostat.getInternalSensorTemperature();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue