Marlock & SmartDomik
Just got my hands on a low‑noise motion sensor that can detect a single heartbeat—could be perfect for keeping the house quiet while you run your automation routines.
Sounds like a neat little trick – you could keep the lights dim and the fans off while still catching when someone’s really sleeping. Just make sure the firmware can ignore the tiny heartbeat buzz and not trigger a full automation cycle every second. If it does, we’ll have to build a buffer or a noise‑filter routine before it starts messing with the thermostat.
Sure thing, just slap a low‑pass filter on the sensor output and debounce it. That’ll keep the system quiet when it’s just a thud. If you want me to sneak in the code, just say the word.
Thanks, go ahead and drop the code—let's see if we can integrate that filter smoothly. I'll set up a test node so we can monitor the heartbeat signal without waking the whole system.
```javascript
// Node‑RED JavaScript function node
// Input: heartbeatSignal (number, 0–1, raw sensor output)
// Output: filteredSignal (0 or 1)
// Simple low‑pass filter (RC smoothing)
const alpha = 0.1; // smoothing factor (0 < alpha < 1)
let prev = 0; // previous filtered value
// Debounce: only emit when signal changes and is stable
const debounceTime = 200; // ms
let lastChange = Date.now();
let lastState = 0;
return function(heartbeatSignal) {
// Low‑pass filtering
const filtered = alpha * heartbeatSignal + (1 - alpha) * prev;
prev = filtered;
// Treat >0.5 as a heartbeat
const currentState = filtered > 0.5 ? 1 : 0;
if (currentState !== lastState) {
// Check debounce
if (Date.now() - lastChange > debounceTime) {
lastChange = Date.now();
lastState = currentState;
return { filteredSignal: currentState };
}
}
// No change, return null to keep Node‑RED quiet
return null;
};
```
Looks solid, just keep an eye on the alpha value – 0.1 is pretty slow, so if the sensor hiccups you’ll get a lag. If you want a sharper response you could bump it to 0.2 or so, but then you risk a bit of jitter. Also, make sure the debounce logic is in sync with the rest of your flow so you don’t accidentally miss a real heartbeat. Let me know if you need help wiring it into the HVAC controller.
Got it, I'll tweak alpha to 0.2 for a snappier feel and tighten the debounce to 150 ms so we catch real beats without the jitter. Just drop the function into the HVAC node and hook its output to the fan trigger. If you hit any hiccups, let me know.