From 9b0db7903a50aca1887294aa805e4ff09439e0f0 Mon Sep 17 00:00:00 2001
From: Cyril Beslay Home
Date: Tue, 30 Jul 2024 23:46:54 +0200
Subject: [PATCH] feat(temperature): Add last value changed info
---
.../components/boxs/room-temperature/RoomTemperature.jsx | 7 ++++++-
.../temperature-sensor.getTemperatureInRoom.js | 8 +++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/front/src/components/boxs/room-temperature/RoomTemperature.jsx b/front/src/components/boxs/room-temperature/RoomTemperature.jsx
index 1f8ee1c82d..6daf947106 100644
--- a/front/src/components/boxs/room-temperature/RoomTemperature.jsx
+++ b/front/src/components/boxs/room-temperature/RoomTemperature.jsx
@@ -52,7 +52,10 @@ const RoomTemperatureBox = ({ children, ...props }) => (
)}
- {props.roomName}
+
+ {props.roomName}
+
+
@@ -87,6 +90,7 @@ class RoomTemperatureBoxComponent extends Component {
const boxData = get(props, `${DASHBOARD_BOX_DATA_KEY}TemperatureInRoom.${props.x}_${props.y}`);
const boxStatus = get(props, `${DASHBOARD_BOX_STATUS_KEY}TemperatureInRoom.${props.x}_${props.y}`);
const temperature = get(boxData, 'room.temperature.temperature');
+ const lastValueChanged = get(boxData, 'room.temperature.lastValueChanged');
const unit = get(boxData, 'room.temperature.unit');
const roomName = get(boxData, 'room.name');
@@ -115,6 +119,7 @@ class RoomTemperatureBoxComponent extends Component {
{
let temperature;
@@ -73,6 +75,9 @@ async function getTemperatureInRoom(roomId, options) {
temperature = deviceFeature.last_value;
}
total += temperature;
+ if (deviceFeature.last_value_changed > lastValueChanged) {
+ lastValueChanged = deviceFeature.last_value_changed;
+ }
});
// we calculate the average value
@@ -82,6 +87,7 @@ async function getTemperatureInRoom(roomId, options) {
return {
temperature: averageTemperature,
unit: optionsWithDefault.unit,
+ lastValueChanged,
};
}