Is the washing machine done?

User avatar
felix63
Posts: 161
Joined: Monday 07 December 2015 10:30
Target OS: Raspberry Pi
Domoticz version: 3.8275
Location: Gouda
Contact:

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 script runs every five minutes to check or when the power consumption of one of the monitored devices changes. The time can be changed at will.

You can turn on logging to get an idea of what the script does.

The script requires for each device to be monitored:
- a power measuring socket with a device measuring the actual power consumption named 'SC-XXXX verbruik' . The table USAGE_DEVICES contains the names of the devices to monitor for each.
- a virtual switch created with the name of the device to monitor, named XXXX
- a measurement of the level of power that is used by the machine in standby mode. Contained in USAGE_MaxWatt.
- an estimate of the number of minutes the power consumption should be lower than the standby level to assume standby to be active. Contained in USAGE_SwitchTimeOutMinutes.
- a decision wether or not to have the script send a notification when the machine is ready (off or on standby). This could also be done by attaching the notification to the virtual switch. Contained in USAGE_Notify.

The example below supports two devices, the 'Wasdroger' and the 'Wasmachine'.

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
 				local average = domoticz.data[usage].avg()
                domoticz.data[usage].add(actual)
 				domoticz.log("actual = " .. actual)
				domoticz.log("average = " .. tostring(average))
				if actual == 0 then
					domoticz.log(machine .. " gebruikt geen energie, dus is uit")
					domoticz.devices(machine).switchOff().checkFirst()
				elseif actual < USAGE_MaxWatt[machine] then
					domoticz.log(machine .. " gebruikt weinig energie, is de machine klaar?")
					local timeout = USAGE_SwitchTimeOutMinutes[machine]
					domoticz.log(machine .. " gebruikte gemiddeld: " .. tostring(domoticz.data[usage].avg))
					if (average <= USAGE_MaxWatt[machine]) then
						domoticz.log(machine .. " lijkt standby te staan, we nemen aan klaar.")
						domoticz.devices(machine).switchOff().checkFirst()
					    domoticz.data[usage].reset()
					else
						domoticz.log(machine .. " maar nog te kort om klaar te zijn.")
						domoticz.devices(machine).switchOn().checkFirst()
					end
				else 
					domoticz.log(machine .. " gebruikt energie, dus is (nog) bezig.")
					domoticz.devices(machine).switchOn().checkFirst()
				end
 			end
 		elseif (USAGE_DEVICES[device.name] ~= nil) then
 			-- we have a usage sensor here
 			domoticz.log("usage trigger")
 			local switch = domoticz.devices(USAGE_DEVICES[device.name])
 			local timeout = USAGE_SwitchTimeOutMinutes[USAGE_DEVICES[device.name]]
 			local watt = USAGE_MaxWatt[USAGE_DEVICES[device.name]]
 			domoticz.data[device.name].add(device.WhActual)
 			local history = domoticz.data[device.name]
 			domoticz.log("device = " .. device.name)
 			if (switch.active) then
				domoticz.log("Switch is active, check average use and last update")
				domoticz.log("usage last update: " .. tostring(switch.lastUpdate.minutesAgo))
  			    domoticz.log("usage = " .. tostring(device.WhActual))
				domoticz.log("average = " .. tostring(history.avg()))
				if (history.avg() <= watt and device.WhActual <= watt and switch.lastUpdate.minutesAgo >= timeout) then
    			 	switch.switchOff().checkFirst()
					domoticz.log("Turn switch off")
					domoticz.data[device.name].reset()
     			end
             else
				domoticz.log("Switch not on")
                 if (device.WhActual > watt) then
					domoticz.log("but power use is over treshold, turn switch on")
 	                switch.switchOn().checkFirst()
 	            end
 		    end
 		end
 	end
 }
 
Image
Attachments
devices.png
devices.png (159.7 KiB) Viewed 1519 times
Last edited by felix63 on Wednesday 27 June 2018 12:47, edited 4 times in total.

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

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!!
Frank

LennartIsHigh
Posts: 12
Joined: Thursday 02 November 2017 17:50
Target OS: Raspberry Pi
Domoticz version: 4.9700
Location: Rotterdam
Contact:

Re: Is the washing machine done?

Post by LennartIsHigh » Wednesday 27 June 2018 8:52

Hi Felix,

Since I just started using Domoticz I'm not yet deep into coding. Can you clarify what switches, virtual devices and or sensors you have used in your example. I do have a wall plug installed that measures the Watts used by the washing machine. What's next? Do I have to create a virtual switch "Wasmachine On/Off" that will be switched by your script to see if it's running or not.

Thanks you for your example!

User avatar
felix63
Posts: 161
Joined: Monday 07 December 2015 10:30
Target OS: Raspberry Pi
Domoticz version: 3.8275
Location: Gouda
Contact:

Re: Is the washing machine done?

Post by felix63 » Wednesday 27 June 2018 12:42

Hi,

I have updated the script for I found it still had some glaring bugs! I also included some more comprehensive instructions on how it works. I hope this will help you!

LennartIsHigh
Posts: 12
Joined: Thursday 02 November 2017 17:50
Target OS: Raspberry Pi
Domoticz version: 4.9700
Location: Rotterdam
Contact:

Re: Is the washing machine done?

Post by LennartIsHigh » Wednesday 27 June 2018 12:50

Thanks again Felix! I'll try it and will let you know next week.

Pjedr
Posts: 110
Joined: Friday 27 December 2013 4:13
Target OS: Linux
Domoticz version: Beta
Location: Friesland
Contact:

Re: Is the washing machine done?

Post by Pjedr » Thursday 28 June 2018 14:38

Ik doe dit al jaren met als groep4 (sGroep4Watt) langer dan een bepaalde tijd (timedifference) onder een bepaalde waarde (sElektrBoiler1Cap)) zit, is mijn water opgewarmd en kan de leidingwaterboiler (otherdevices['LeidingWaterBoiler 15 Liter']) uit, en zet ik een virtuele schakelaar (commandArray['LeidingWaterBoiler 15 Liter Opgewarmd']='On') aan:

Code: Select all

sElektrBoiler1Cap=uservariables['Elektrische Boiler 15 Liter Laadvermogen']
sGroep4Watt,sGroep4Wh= otherdevices_svalues['Gr4 ElektrBoiler']:match("([^;]+);([^;]+)")
sGroep4Watt=tonumber(sGroep4Watt) sGroep4Wh=tonumber(sGroep4Wh)
if sGroep4Watt == nil then sGroep4Watt=0 end if sGroep4Wh == nil then sGroep4Wh=0 end
print('Verbruik Groep4 = '..sGroep4Watt..' Watt '.. sGroep4Wh/1000 ..' KwH, Elektrische Boiler')
difference=timedifference(otherdevices_lastupdate['LeidingWaterBoiler 15 Liter'])
print('LeidingWaterBoiler 15 Liter is '.. difference/60 ..' minuten geleden geschakeld, verbruik groep2 is '..round(sGroep2Watt, -2)..' Watt'
if (otherdevices['LeidingWaterBoiler 15 Liter']=='On' and otherdevices['LeidingWaterBoiler 15 Liter Opgewarmd']=='Off' and difference > 330 and sGroep3Watt < sElektrBoiler1Cap) then sMsg='Leidingwaterboiler 15 Liter is opgewarmd.' print(sMsg)
 commandArray['LeidingWaterBoiler 15 Liter Opgewarmd']='On' commandArray['LeidingWaterBoiler 15 Liter']='Off' end

LennartIsHigh
Posts: 12
Joined: Thursday 02 November 2017 17:50
Target OS: Raspberry Pi
Domoticz version: 4.9700
Location: Rotterdam
Contact:

Re: Is the washing machine done?

Post by LennartIsHigh » Friday 06 July 2018 10:50

Hello again,

Your script works like a charm. At first I had some trouble because of a slow rate of Watt-values coming in from my NeoCoolcam Plug, but then I switched the whole idea to measure the dishwasher (ground floor vs second floor) and all of a sudden it works as expected. What kind of Watt-metering-equipment do you guys use? Since I’m testing this for my new to build house where I really like to build an automated home.

Kind regards

Ps. Thanks again for your explanation, Felix

User avatar
felix63
Posts: 161
Joined: Monday 07 December 2015 10:30
Target OS: Raspberry Pi
Domoticz version: 3.8275
Location: Gouda
Contact:

Re: Is the washing machine done?

Post by felix63 » Saturday 07 July 2018 2:11

The script is running on GreenWave PowerNodes. I do have some Neo CoolCam Power plugs lying around. I will try running the script on a device connected to one of them to see what happens. Will let you know.

HarR
Posts: 19
Joined: Saturday 30 December 2017 15:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Is the washing machine done?

Post by HarR » Saturday 07 July 2018 8:53

People be careful using these power plugs on appliances like washers and dryers. They more aimed at switching lights, and not designed for high currents. Even more so the cheap Chinese ones.....
Washers and dryers are rated over 2000 Watts


Sent from my iPhone using Tapatalk

LennartIsHigh
Posts: 12
Joined: Thursday 02 November 2017 17:50
Target OS: Raspberry Pi
Domoticz version: 4.9700
Location: Rotterdam
Contact:

Re: Is the washing machine done?

Post by LennartIsHigh » Saturday 07 July 2018 20:18

Thanks for the heads-up HarR! In this situation I am trying to figure out how this all works out and in my new home, next summer, I’ll install other devices that can carry the load. I’ve found some plugs that can carry up to 3500Watt spikes.

Do you mean these ones or do you refer to a other type of Watt-measuring? Is there another way to measure the Watts used?

On the other hand, this script of Felix works great, I just need to adjust it to my needs. Thank you both for your information.

User avatar
felix63
Posts: 161
Joined: Monday 07 December 2015 10:30
Target OS: Raspberry Pi
Domoticz version: 3.8275
Location: Gouda
Contact:

Re: Is the washing machine done?

Post by felix63 » Saturday 07 July 2018 23:31

Hi HarR,

I checked the specifications of the green point devices.
Technical DetailsOperating Temperature 0°C to +25°CStorage Temperature -20°C to +60°CMaximum Humidity 5% to 90% N/CIP-Class (Moisture Tolerance) IP20Maximum Load Current 10AMaximum Load Power 2400W (@240V)Load Monitoring Precision ±0.1WOvercurrent Protection 10A internal fuseSupply Power 250V~ AC, 50HzSurge Protection YesStandby Power Consumption 0.4WAppliance Receptacle DIN49440 (Schuko)Wall Plug CEE 7/7 (Schuko)Z-Wave Radio Frequency 868.4MHz (EU)Maximum Inter-Node Range 30mNet Weight 140gTotal Weight 170gDimensions 120x60x70mmm (131x76x67mm)Operating the deviceInstant/Accumulated Power MeasurePowerNode can report instant or accumulated power of each port. PowerNode measures power consumption of load on each port and the value of instant power will be updated every 1.5 seconds. Accumulated power increases by time and the value will reset to 0 after METER_RESET command.Over Current Protection (OCP) (Association Group 4)PowerNode will turn the relay off for safety when the port is over-current. And PowerNode will send out unsolicited alarm report if OCP is trigged and also an association relationship exists. Once this event happens, all commands about relay on/off (basic set, binary switch set, all switch on, all switch off) and PadLock functionality will be ignored. User can set it to normal by pressing power button.
My conclusion is that the current use is quiet safe. The Greenwave PowerNode has overcurrent protection (which by the way has never kicked in). The maximum load is 2400W which is apparently acceptable for both devices. The stats show a maximum use of 2109W for the washer and 750W for the dryer. So I'll leave everything as it is. But it is a good reminder to be careful when handling electrical equipement and to be aware of possible risk. So check and be respectful of known limitations.

Cheers!

p.s.
Also checked the NEO's. The manual indicates a max. load of 13A which is sufficient for connecting a washer. Again also these devices offer a (configurable) overload protection.

terrorsource
Posts: 53
Joined: Wednesday 10 May 2017 17:57
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Is the washing machine done?

Post by terrorsource » Monday 09 July 2018 10:43

Are the SC-devices "Real" deviced and the not-SC devices dummy's in your screenshot?

I'm now using a Blocky which monitors the usage and toggles a dummy switch when the current power usage is higher/lower then a value.
When lower then sends a Prowl message.

I want to move to DzVents because Blocky cannot be saved as a file for as i know.
PowerPlug Switch : Wasmachine
PowerPlug power usage: Wasmachine_Unknown4
Dummy: WasmachineDummy

User avatar
felix63
Posts: 161
Joined: Monday 07 December 2015 10:30
Target OS: Raspberry Pi
Domoticz version: 3.8275
Location: Gouda
Contact:

Re: Is the washing machine done?

Post by felix63 » Monday 09 July 2018 11:14

The SC devices are real.

User avatar
emme
Posts: 847
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Is the washing machine done?

Post by emme » Monday 09 July 2018 11:59

I have the same but with a different (and perhaps a much more complicate) approach

I do use an array with the consumption device names in it (which is used to trigger the script also) and other 2 arrays with the minimum consumption (watt) and the timing.

the script runs by device and evaluate its consumption.... if over the setting that it switch the monitor on then, when it goes below it starts counting
Monitor is a timer option script that evaluate the lastupdate for the variable, if greater than the settings it can be considered finish and send a notification to my wife's Telegram account with a random personalized sentence (I have a house with personality :P :P)
in the meantime, if the consumption vary and goes over the setting, the monitor gets disable.

It works fine for washing machine, dryer and dishwasher

here it is:

Code: Select all

-- Script di controvvo e avviso fine ciclo grandi elettrodomestici


local devNames = { 'kWh_Lavatrice' , 'kWh_Asciugatrice', 'kWh_Lavastoviglie'}               -- Devices
local varNames = { 'cycleMonitLavatrice', 'cycleMonitAsciugatrice', 'cycleMonitLavastoviglie' }    -- Variables name (set 0 Monitor disable, 1 Monitor Engaged, 2 Start counting minutes)
local defDelay = { 15, 30, 40 }                                             -- delay (in minutes) for cycle end
local devTrig  = { 50, 50, 30 }                                             -- consumption (W) under which start the monitor

-- ==== NON CAMBIARE NULLA DA QUI' IN POI ====

package.path = package.path .. ';' .. '/home/pi/domoticz/scripts/lua/?.lua'
local telegram = require('Telegram')
local quote    = require('quote')

function getKey(varName)
    for k, v in pairs(devNames) do
        if v == varName then
            return k
        end
    end
end

return {
	on = {
		devices =  devNames ,
		timer   = {'every minute'}
	},
--[[
    logging = {
        level = domoticz.LOG_INFO,
        marker = "[MONITORCARICHI]"
    },
]]
	execute = function(dz, devWat)
	    if devWat.isDevice then -- tgInfo.EVENT_TYPE_DEVICE then
	        local idx = getKey(devWat.name)
	        --dz.log(devWat.name..' Stato: '..devWat.WhActual..' '..idx, dz.LOG_FORCE)
	        if devWat.WhActual > devTrig[idx] and dz.variables(varNames[idx]).value ~= 1 then
                dz.variables(varNames[idx]).set(1)
                dz.log('Inizio il monitoraggio per la '..devNames[idx]:sub(5))
                
            elseif devWat.WhActual < devTrig[idx] and dz.variables(varNames[idx]).value == 1 then
                dz.variables(varNames[idx]).set(2)
                dz.log('Inizio il conteggio per la '..devNames[idx]:sub(5))
	        end 
	        
        elseif devWat.isTimer then  -- tgInfo.type == dz.EVENT_TYPE_TIMER then      -- cycle Monitor
            for idx, v in pairs(devNames) do 
                --dz.log(devNames[idx]..' Stato: '..dz.devices(devNames[idx]).WhActual..' '..type(dz.devices(devNames[idx]).WhActual), dz.LOG_FORCE)
                if dz.variables(varNames[idx]).value == 2 and dz.variables(varNames[idx]).lastUpdate.minutesAgo >= defDelay[idx] then
                    dz.variables(varNames[idx]).set(0)
                    telegram.sendText(telegram.getId('myName'), quote.getCycleMonit():gsub('§MONIT§', v:sub(5)))
    	        end
            end
        end
	end
}
ciao
M
The most dangerous phrase in any language is:
"We always done this way"

terrorsource
Posts: 53
Joined: Wednesday 10 May 2017 17:57
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Is the washing machine done?

Post by terrorsource » Thursday 12 July 2018 10:39

felix63 wrote:
Monday 09 July 2018 11:14
The SC devices are real.
And the "Wasdroger" device? Is that a real device too or a dummy?
Bit hard to see the difference between "SC-Wasdroger" and "Wasdroger" for me.

User avatar
felix63
Posts: 161
Joined: Monday 07 December 2015 10:30
Target OS: Raspberry Pi
Domoticz version: 3.8275
Location: Gouda
Contact:

Re: Is the washing machine done?

Post by felix63 » Thursday 12 July 2018 11:21

The SC-Wasdroger verbruik shows the current power usage. The SC-Wasdroger is the socket the dryer is physically plugged in to. The Wasdroger device is a logical device showing the assumed state of the dryer (on/off) based on power consumption on the socket. Does this help?

terrorsource
Posts: 53
Joined: Wednesday 10 May 2017 17:57
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Is the washing machine done?

Post by terrorsource » Thursday 12 July 2018 12:56

felix63 wrote:
Thursday 12 July 2018 11:21
The SC-Wasdroger verbruik shows the current power usage. The SC-Wasdroger is the socket the dryer is physically plugged in to. The Wasdroger device is a logical device showing the assumed state of the dryer (on/off) based on power consumption on the socket. Does this help?
I guess.

My case:
PowerPlug Switch : Droger = your SC-Wasdroger
PowerPlug power usage: Droger_Unknown4 = your SC-Wasdroger verbruik
Dummy: DrogerDummy = your Wasdroger

LennartIsHigh
Posts: 12
Joined: Thursday 02 November 2017 17:50
Target OS: Raspberry Pi
Domoticz version: 4.9700
Location: Rotterdam
Contact:

Re: Is the washing machine done?

Post by LennartIsHigh » Thursday 19 July 2018 16:13

Hello again,

Since I dug a little deeper in this idea and also because of the warning HarR gave us, I've come up with a new plan. To stay within the topic of the washing machine being done, has anyone tried to connect a Sonoff POW to Domoticz? I haven't done it yet but I'm ordering a Sonoff POW R2 as we speak. My plan is to flash it with Tasmota and than add it to Domoticz. By than I have a Sonoff that can measure my power usage (up to 3500W) and have it report to Domoticz through Wifi. Maybe this is more a Sonoff Tasmota thing but I wanted to tell you about this idea.

Any thoughts?

User avatar
CyberE
Posts: 7
Joined: Monday 25 June 2018 17:46
Target OS: Raspberry Pi
Domoticz version: 4.9700
Location: NL
Contact:

Re: Is the washing machine done?

Post by CyberE » Sunday 05 August 2018 8:42

Let me start by saying thanks for the script. I've been using this script for a couple of days now and it works like a charm.

The only thing I noticed was that it is a bit heavy on performance. My Pi went from a 1,5% cpu load, to roughly 12%.

I think I will also step away from the Coolcam Wallplugs for this setup, as they only should be used up to 2500 Watts, and my dryer is pulling 2800 Watts.

User avatar
felix63
Posts: 161
Joined: Monday 07 December 2015 10:30
Target OS: Raspberry Pi
Domoticz version: 3.8275
Location: Gouda
Contact:

Re: Is the washing machine done?

Post by felix63 » Sunday 05 August 2018 10:20

Thanks. I Will look into the energy consumption next week. Let you know if the same thing happens with me.

Regarding hardware I agree, be safe. Most switches have overload protection though.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests