I noticed strange behaviour from "is my xxx finished" scripts, being receiving notifications that the dishwasher is done while I didn't start the machine. I know my house is not yet that smart to go and decide that on its own

Some quick investigation showed that this was caused by strange peaks in the current readings (800 watts while not in use), one single spike.
This caused the virtual switch I use for later triggering to be switched on, and a minute later off again. In turn the script sent a notification.
(non)options:
- Finding a way to avoid these spikes --> I deem this near impossible
- The same way as detecting the 'In use status'. On the first value above 'idle' usage start a counter (of 10 minutes in my case) and for every run of the script deduct 1 until 0. This is not how I prefer, because the 'in use' status would be delayed with 10 minutes and then 10 minutes again at the end.
- Applying the hysteresis like in the heating scripts. The method I chose, but from the start posed another issue.
I decided on taking 3 readings and use their average. But with a spike of 800 watts, and 2 zeros, the average is still 266 watts, way above the treshold.
Now from the dZvents documentation, I knew how to find the highest value but not how to excluded it.
This is what I came up with so far, it does the trick, but am I overlooking some function?
Code: Select all
local WaReadings = domoticz.data.WaReadings
local clean_avg = (WaReadings.sum(1,3) - WaReadings.max(1,3)) / 2
And from there on use the average value for triggering
Just started applying it, so not real reliable data, but all seems fine. This assumes that the spikes do not last for more than 61 seconds.
Your insights and input would be really appreciated.