Page 1 of 5

Is the washing machine done?

Posted: Monday 11 June 2018 22:55
by felix63
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'.

** Edited 5/10/2020 with version 2.0 after some valuable inputs **

Code: Select all


 -- Is the washing macgine done? Version 2.0
 -- create a lookup table that matches a usage
 -- device to the accompanying switch
 local USAGE_DEVICES = {
 	['SC-Wasdroger gebruik'] = 'Wasdroger',	-- You need to have a inline wall plug that measures energy,
 	['SC-Wasmachine gebruik'] = 'Wasmachine',  -- here you make the link between the energy device and the wall plug.
 }

 local USAGE_TimeOut = {
 	['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.
 }

 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 gebruik',
            'SC-Wasmachine gebruik',
 		},
 	},
 	data = { 									-- use exact device names to match USAGE_DEVICES
        ['CountDevices'] = {initial=0},
        ['SC-Wasdroger gebruik'] = { history = true, maxMinutes = 10 },
        ['SC-Wasmachine gebruik'] = { history = true, maxMinutes = 10 },
 	},

 	execute = function(domoticz, device)

        function status(machine)
			local usage = "SC-" .. machine.. " gebruik"                     -- name of physical power measuring device
            local standby = USAGE_MaxWatt[machine]                          -- threshold for standby 
            local timeout = USAGE_TimeOut[machine]                          -- amount of time the power consumption needs to be constant
            local switch = domoticz.devices(machine)                        -- the actual virtual switch that shows the status of the device
            local power_actual = domoticz.devices(usage).WhActual           -- the actual power consumption of the device
            local power_average = domoticz.data[usage].avg()                -- the average power consumption in the last 10 minutes
            local minutes = domoticz.devices(usage).lastUpdate.minutesAgo   -- the # minutes the power consumption is unchanjged
            domoticz.log("device   : " .. machine .. ', power: ' .. usage)
            domoticz.log('gebruik  : ' .. power_actual .. ', treshold: ' .. standby)
            domoticz.log('gemiddeld: ' .. power_average)
            domoticz.log('sinds    : ' .. minutes .. ', standby: ' .. timeout)
            domoticz.data[usage].add(power_actual)
            if (switch.active) then
                if power_actual > standby then                  -- Device is already on
                    return('Already on')
                end
         	    if (power_actual == 0) or (power_actual <= standby and 
         	        (power_average <= standby) or minutes > standby)  then
                    switch.switchOff()                          -- Device is off or on standby
                    domoticz.data[usage].reset()                -- Reset history
                    return('Off')
         		end
     		    return('Idle')
 			end
            if power_actual > standby then                      -- Device is active
                switch.switchOn()                               -- Turn the virtual switch on
                if domoticz.data['CountDevices'] == 0 then
                    domoticz.data['CountDevices'] =  1          -- Keep track off active devices
                end
                return('Switching On')                      
            end
            if power_average > 0 then                           -- Switch is off but average needs to be reset
    	        domoticz.data[usage].reset()                    -- Reset history
            end                
            return('Off')                                       -- Device is off
        end
        
        if (device.isTimer) then                                -- Then its a regular check
			domoticz.log("Monitoring " .. tostring(domoticz.data['CountDevices']) .. "  apparaten.")
		 	if (domoticz.data['CountDevices'] > 0) then         -- When one or more devices are on
				domoticz.log("Monitoring " .. tostring(domoticz.data['CountDevices']) .. "  apparaten.")
				domoticz.data['CountDevices'] = 0               -- Reset count
     			for i, machine in pairs(USAGE_DEVICES) do       -- Loop thru all the devices
     			    checked = status(machine)                   -- Check the status of each device
                    domoticz.log('status: '..checked)           -- Check the status of each device
                    if checked ~= 'Off' then
                        domoticz.data['CountDevices'] = domoticz.data['CountDevices'] + 1   -- Keep track off active devices
                    end
     			end
			end
     	elseif (USAGE_DEVICES[device.name] ~= nil) then         -- Then one device has a changed power consumption
            domoticz.log('status: '..status(USAGE_DEVICES[device.name]))    -- Check the status of this one device
        end
 	end
 }
 
Schermafbeelding 2020-12-06 om 15.29.58.png
Schermafbeelding 2020-12-06 om 15.29.58.png (249.47 KiB) Viewed 3602 times

Re: Is the washing machine done?

Posted: Tuesday 12 June 2018 8:57
by freijn
My next item on the list. Will give it a try , many thanks for sharing!!
Frank

Re: Is the washing machine done?

Posted: Wednesday 27 June 2018 8:52
by LennartIsHigh
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!

Re: Is the washing machine done?

Posted: Wednesday 27 June 2018 12:42
by felix63
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!

Re: Is the washing machine done?

Posted: Wednesday 27 June 2018 12:50
by LennartIsHigh
Thanks again Felix! I'll try it and will let you know next week.

Re: Is the washing machine done?

Posted: Thursday 28 June 2018 14:38
by Pjedr
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

Re: Is the washing machine done?

Posted: Friday 06 July 2018 10:50
by LennartIsHigh
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

Re: Is the washing machine done?

Posted: Saturday 07 July 2018 2:11
by felix63
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.

Re: Is the washing machine done?

Posted: Saturday 07 July 2018 8:53
by HarR
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

Re: Is the washing machine done?

Posted: Saturday 07 July 2018 20:18
by LennartIsHigh
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.

Re: Is the washing machine done?

Posted: Saturday 07 July 2018 23:31
by felix63
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.

Re: Is the washing machine done?

Posted: Monday 09 July 2018 10:43
by terrorsource
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

Re: Is the washing machine done?

Posted: Monday 09 July 2018 11:14
by felix63
The SC devices are real.

Re: Is the washing machine done?

Posted: Monday 09 July 2018 11:59
by emme
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

Re: Is the washing machine done?

Posted: Thursday 12 July 2018 10:39
by terrorsource
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.

Re: Is the washing machine done?

Posted: Thursday 12 July 2018 11:21
by felix63
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?

Re: Is the washing machine done?

Posted: Thursday 12 July 2018 12:56
by terrorsource
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

Re: Is the washing machine done?

Posted: Thursday 19 July 2018 16:13
by LennartIsHigh
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?

Re: Is the washing machine done?

Posted: Sunday 05 August 2018 8:42
by CyberE
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.

Re: Is the washing machine done?

Posted: Sunday 05 August 2018 10:20
by felix63
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.