fixed the bin card on the bins page to not use temp only cables for the average humidity calc

This commit is contained in:
csawatzky 2025-09-02 11:37:09 -06:00
parent d1e9066324
commit 5636b70fa7
2 changed files with 15 additions and 12 deletions

View file

@ -103,8 +103,10 @@ export default function BinCard(props: Props) {
let filteredNodes = c.filteredNodes(true) let filteredNodes = c.filteredNodes(true)
allTemps.push(...filteredNodes.temps); allTemps.push(...filteredNodes.temps);
allHums.push(...filteredNodes.humids); if(avg(c.humidities) !== 0){ //if the average of the humidities is 0 that means that all the readings are 0 and it is a temp only cable
allMoistures.push(...filteredNodes.moistures); allHums.push(...filteredNodes.humids);
allMoistures.push(...filteredNodes.moistures);
}
//set the hottest and coldest nodes //set the hottest and coldest nodes
if (coldestNode === undefined || Math.min(...filteredNodes.temps) < coldestNode.temp) { if (coldestNode === undefined || Math.min(...filteredNodes.temps) < coldestNode.temp) {

View file

@ -414,14 +414,15 @@ export default function BinVisualizer(props: Props) {
//if the lowest temp for this cable is less than the temp in the low node conditions or the low node conditions are not set //if the lowest temp for this cable is less than the temp in the low node conditions or the low node conditions are not set
//use this cables lowest node and trend data in the condition //use this cables lowest node and trend data in the condition
if (!lowNodeConditions || Math.min(...temps) < lowNodeConditions.tempC) { if (!lowNodeConditions || Math.min(...filteredNodes.temps) < lowNodeConditions.tempC) {
//determine which node is the coldest so that the data displayed is for the same node //determine which node is the coldest so that the data displayed is for the same node
let lowTempIndex = let lowTempIndex =
temps.indexOf(Math.min(...temps)) === -1 ? 0 : temps.indexOf(Math.min(...temps)); filteredNodes.temps.indexOf(Math.min(...filteredNodes.temps)) === -1 ? 0 : filteredNodes.temps.indexOf(Math.min(...filteredNodes.temps));
console.log(lowTempIndex)
lowNodeConditions = { lowNodeConditions = {
tempC: temps[lowTempIndex], tempC: filteredNodes.temps[lowTempIndex],
humidity: humids[lowTempIndex], humidity: filteredNodes.humids[lowTempIndex],
emc: emcs[lowTempIndex], emc: filteredNodes.moistures[lowTempIndex],
tempCTrend: cableTrendData.coldNodeTrend?.tempTrend ?? 0, tempCTrend: cableTrendData.coldNodeTrend?.tempTrend ?? 0,
humidityTrend: cableTrendData.coldNodeTrend?.humidityTrend ?? 0, humidityTrend: cableTrendData.coldNodeTrend?.humidityTrend ?? 0,
emcTrend: cableTrendData.coldNodeTrend?.emcTrend ?? 0 emcTrend: cableTrendData.coldNodeTrend?.emcTrend ?? 0
@ -429,13 +430,13 @@ export default function BinVisualizer(props: Props) {
} }
//do the same for the high node //do the same for the high node
if (!highNodeConditions || cable.maxTemp() > highNodeConditions.tempC) { if (!highNodeConditions || Math.max(...filteredNodes.temps) > highNodeConditions.tempC) {
let highTempIndex = let highTempIndex =
temps.indexOf(Math.max(...temps)) === -1 ? 0 : temps.indexOf(Math.max(...temps)); filteredNodes.temps.indexOf(Math.max(...filteredNodes.temps)) === -1 ? 0 : filteredNodes.temps.indexOf(Math.max(...filteredNodes.temps));
highNodeConditions = { highNodeConditions = {
tempC: temps[highTempIndex], tempC: filteredNodes.temps[highTempIndex],
humidity: humids[highTempIndex], humidity: filteredNodes.humids[highTempIndex],
emc: emcs[highTempIndex], emc: filteredNodes.humids[highTempIndex],
tempCTrend: cableTrendData.hotNodeTrend?.tempTrend ?? 0, tempCTrend: cableTrendData.hotNodeTrend?.tempTrend ?? 0,
humidityTrend: cableTrendData.hotNodeTrend?.humidityTrend ?? 0, humidityTrend: cableTrendData.hotNodeTrend?.humidityTrend ?? 0,
emcTrend: cableTrendData.hotNodeTrend?.emcTrend ?? 0 emcTrend: cableTrendData.hotNodeTrend?.emcTrend ?? 0