Skip to content

Commit 49550be

Browse files
committed
Enhance pump status determination for modbus and relay-based pumps
1 parent fec7e1f commit 49550be

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

scripts/pumps.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,24 @@
100100
el.css({ display: '' });
101101
if (data.pumpOnDelay === true)
102102
el.find('div.picIndicator').attr('data-status', 'delay');
103-
else
104-
el.find('div.picIndicator').attr('data-status', data.command === 10 || data.relay > 0 ? 'on' : 'off');
103+
else {
104+
// Determine pump on/off status based on pump type
105+
var isOn = false;
106+
if (type.name === 'regalmodbus' || type.name === 'regalmodbus2') {
107+
// For modbus pumps, use actual speed/flow indicators
108+
// Pump is considered "on" if it's actually running at a speed > 0
109+
isOn = (typeof data.rpm !== 'undefined' && data.rpm > 0) ||
110+
(typeof data.speed !== 'undefined' && data.speed > 0);
111+
if (data.id === 1) { // Debug for pump 1 only to avoid spam
112+
console.debug(`[Pump ${data.id}] Modbus pump state - rpm: ${data.rpm}, speed: ${data.speed}, isOn: ${isOn}`);
113+
}
114+
}
115+
else {
116+
// For relay-based pumps, use command or relay status
117+
isOn = data.command === 10 || data.relay > 0;
118+
}
119+
el.find('div.picIndicator').attr('data-status', isOn ? 'on' : 'off');
120+
}
105121
}
106122
el.attr('data-pumptype', data.type.val);
107123
el.attr('data-id', data.id);

0 commit comments

Comments
 (0)