I read the thread about sensing wether a washing machine had finished by measuring the energy use. Since I don't have an energy meter in my Domoticz setup, but I do have a Z-Wave flood sensor on the washing machine that also has tamper (= vibration) detection sensor on board, I am looking into another option. I want to use it to detect whether the machine is spinning and, when it has finished, to send a signal that the machine should be emptied. No more stale laundry that stayed in the drum for too long! This seems useful to me, because my washing machine is in the attic and although it does a play a 'pocket calculator version' of 'Die Forelle' by Schubert when finished, I don't always hear that when the TV is on or when I am out.
So how to detect if the machine is spin drying? Here is a part of the vibration sensor log:
Code: Select all
2019-03-25 16:07:50 On
2019-03-25 16:07:47 Off
2019-03-25 16:07:43 On
2019-03-25 16:07:41 Off
2019-03-25 16:07:38 On
2019-03-25 16:07:35 Off
2019-03-25 16:07:11 On
2019-03-25 16:07:07 Off
2019-03-25 16:06:53 On
2019-03-25 16:06:49 Off
2019-03-25 16:06:45 On
2019-03-25 16:06:44 Off
2019-03-25 16:06:38 On
2019-03-25 16:06:37 Off
As you can see the 'centrifuge' pattern is easily recognizable by about 8 to 10 state changes per minute. The question now is how to implement this in dzvents. A timed routine that checks every second seems the easiest (just a matter of counting), but will put an unnecessary load on the system even if there are no device updates. It must therefore be a device trigger, but then the question is how I can check how many updates occur in a certain period (preferably a minute or 5 to prevent false positive if vibrations occur during filling the machine, or washing, or pumping water, etcetera).
I think I need something like this, in pseudo code:
Code: Select all
If (number_of_devicechanges_within_5_minutes >= 40) then
print('Washing machine is spinning') -- only for testing
Centrifuge = true
End
If (device.lastupdate.minutes > 5) && (Centrifuge == true) then
Notify ('The washing machine is ready')
Centrifuge = false
End
Of course the challenge is how to measure 'number_of_devicechanges_within_5_minutes'. I have some programming experience, but am a newbie in dzvents, which I find a strange language compared to C or Javascript or even assembler. So how do I use it to measure how many events (device notifications, E) have occurred in a certain time period (T)? Can this be implemented in dzvents? Can I even get a Unix date in dzvents?
Pierre