Is the washing machine done?

Post Reply
User avatar
Posts: 121
Joined: Monday 07 December 2015 10:30
Target OS: Raspberry Pi
Domoticz version: 3.8275
Location: Gouda

Is the washing machine done?

Post by felix63 » Monday 11 June 2018 22:55

A DzVents script inspired by other scripts - no claim to ownership but adapted for dzvents to check to see if various appliance are running and give a warning when they have finished again. Stuff like washing machines, tumble dryers and the likes. Typically these devices don't switch off completely but go into a standby mode. The basic assumption is that the device is connected to a power measuring socket ('SC-XXXX verbruik') and a virtual switch ('XXXX'). For each device you can set a time-out period giving the period the power usages has to remain below a variable threshold value in order to be considered finished. You can also let the script handle giving a notification when a device is finished.

Code: Select all

 -- create a lookup table that matches a usage
 -- device to the accompanying switch
 local USAGE_DEVICES = {
	['SC-Wasdroger verbruik'] = 'Wasdroger',		-- You need to have a inline wall plug that measures energy,
	['SC-Wasmachine verbruik'] = 'Wasmachine',	-- here you make the link between the energy device and the wall plug.

 local USAGE_SwitchTimeOutMinutes = {
 	['Wasdroger'] = 6,		-- Here you define how long no power is used per device.
 	['Wasmachine'] = 6,		-- The period is in minutes. Adjust to your needs. Between every add a ",".

 local USAGE_MaxWatt = {
 	['Wasdroger'] = 3,		-- Here you define the maximum amount of power a device uses when it is in standby.
 	['Wasmachine'] = 3,		-- Some devices uses a little amount of power. Test it and a slightly higher usage.

 local USAGE_Notify = {
 	['Wasdroger'] = 'Yes',		-- In some cases you want to be notified when a device is turned on and off.
 	['Wasmachine'] = 'Yes',	-- Adjust to your needs. Between every line you need to add a ",".

 return {
 	logging = {
-- 		level = domoticz.LOG_INFO,		-- Uncomment to override the dzVents global logging setting
 		marker = 'POW'

 	on = {
		timer = { 'every 5 minutes' },
 		devices = {		-- Make sure that the devices are the same as above
 			'SC-Wasdroger verbruik',
 			'SC-Wasmachine verbruik',
 	data = {		-- use exact device names to match USAGE_DEVICES
 		['SC-Wasdroger verbruik'] = { history = true, maxMinutes = 10 },
 		['SC-Wasmachine verbruik'] = { history = true, maxMinutes = 10 }

 	execute = function(domoticz, device)
         if (device.isTimer) then
 			-- we need to check for expiration of grace period
 			domoticz.log("timer trigger")
 			for i, machine in pairs(USAGE_DEVICES) do
				local usage = "SC-" .. machine.. " verbruik"
 				domoticz.log("device = " .. machine)
 				local actual = domoticz.devices(usage).WhActual
 				domoticz.log("actual = " .. actual)
				if actual == 0 then
					domoticz.log(machine .. " gebruikt geen energie, dus is uit")
				elseif actual < USAGE_MaxWatt[machine] then
					domoticz.log(machine .. " gebruikt weinig energie, is de machine klaar?")
					local history =[usage]
					local timeout = USAGE_SwitchTimeOutMinutes[machine]
					domoticz.log(machine .. " gebruikte gemiddeld: " .. tostring(history.avg))
					if (domoticz.devices(usage).lastUpdate.minutesAgo >= timeout) then
						domoticz.log(machine .. " lijkt standby te staan, we nemen aan klaar.")
						domoticz.log(machine .. " maar nog te kort om klaar te zijn.")
					domoticz.log(machine .. " gebruikt energie, dus is (nog) bezig.")
 		elseif (USAGE_DEVICES[] ~= nil) then
 			-- we have a usage sensor here
 			domoticz.log("usage trigger")
 			local switch = domoticz.devices(USAGE_DEVICES[])
 			local history =[]
 			local timeout = USAGE_SwitchTimeOutMinutes[USAGE_DEVICES[]]
 			local watt = USAGE_MaxWatt[USAGE_DEVICES[]]
 			domoticz.log("device = " ..
 			if ( then
				domoticz.log("Switch is active, check average use and last update")
				domoticz.log("usage last update: " .. tostring(switch.lastUpdate.minutesAgo))
				domoticz.log("average = " .. tostring(history.avg()))
				if (history.avg() <= watt and switch.lastUpdate.minutesAgo >= timeout) then
					domoticz.log("Turn switch off")
				domoticz.log("Switch not on")
				if (device.WhActual > watt) then
					domoticz.log("but power use is over treshold, turn switch on")
Last edited by felix63 on Wednesday 13 June 2018 22:41, edited 1 time in total.

Posts: 299
Joined: Friday 23 December 2016 17:40
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands Purmerend

Re: Is the washing machine done?

Post by freijn » Tuesday 12 June 2018 8:57

My next item on the list. Will give it a try , many thanks for sharing!!

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests