Page 1 of 1

How check the power absorbed?

Posted: Saturday 30 December 2017 22:04
by acaonweb
I’d like to check if my washer has finished to wash.
My xiaomi plug give me back the power in Watt that I’m consuming
During the washing cycle the power can go to zero sometimes for few minutes and then rise up depending what the washer is doing.
When the washer finish the power goes to zero.
There is a way in dzevents to control something like

Code: Select all

If power is =0 in the last 10 minutes then switch of 
Thanx in advance

FABRIZIO

Re: How check the power absorbed?

Posted: Sunday 31 December 2017 9:20
by SweetPants
Yes, this should be possible, maybe not as easy as you suggest, but it's possible. See wiki https://www.domoticz.com/wiki/DzVents:_ ... _scripting for more information

Re: How check the power absorbed?

Posted: Sunday 31 December 2017 9:33
by acaonweb
Ive already had a look there but I’m not able. I need suggestion ;-)

Re: How check the power absorbed?

Posted: Sunday 31 December 2017 10:17
by SweetPants
Have you tried something already?

Re: How check the power absorbed?

Posted: Sunday 31 December 2017 20:10
by acaonweb
No, i’ve written scripts in dzevents but in this case I don’t know how start :-)

Re: How check the power absorbed?

Posted: Wednesday 03 January 2018 16:21
by acaonweb
any ideas? There someone that trigger when a washer has finished?

Re: How check the power absorbed?

Posted: Wednesday 03 January 2018 16:31
by emme
I've just realized a script for that....
it works in this way:

a Watt consumption treshold above which it start the monitoring process and under whitch it start counting a specific amount of minutes after whitch is consider the cycle ended.

you will need an integer user variable (mine is called cycleMonit) to initialize to 0

here is the script:

Code: Select all

local delay  = 20    -- minutes to wait to consider the duty cycle ended
local trig   = 80    -- WATT below treshold


return {
	on = {
		devices = {'WAT_Lavatrice'},
		timer   = {'every minute'}
	},

    logging = {
        level = domoticz.LOG_INFO,
        marker = "[MonitCycle: LAVATRICE]"
    },
	execute = function(dz, devWat, tgInfo)
	    local cycleMonit = dz.variables('cycleMonit')
	    if tgInfo.type == dz.EVENT_TYPE_TIMER then      -- cycle Monitor
	        dz.log('Monitoraggio attuale: '..cycleMonit.value..'/'..cycleMonit.lastUpdate.minutesAgo, dz.LOG_FORCE)
	        if cycleMonit.value == 2 and cycleMonit.lastUpdate.minutesAgo >= delay then
	            cycleMonit.set(0)
	            dz.notify('Fine ciclo Lavatrice', 'Credo che la lavatrice possa avere finito il proprio ciclo di lavoro')
	        end
        elseif tgInfo.type == dz.EVENT_TYPE_DEVICE then -- WATT updater
            if devWat.WhActual > trig and cycleMonit.value ~= 1 then
                cycleMonit.set(1)
            elseif devWat.WhActual < trig and cycleMonit.value == 1 then
                cycleMonit.set(2) 
            end 
	    end 
	end
}
based on the script... after 20 minutes of consumption under 80Watt, it consider the cycle ended

Re: How check the power absorbed?

Posted: Thursday 04 January 2018 10:58
by acaonweb
great i'll study it because i don't know so much about functions
Thanx for now

Re: How check the power absorbed?

Posted: Thursday 04 January 2018 11:05
by acaonweb
this is a function... the main script is this?

Re: How check the power absorbed?

Posted: Thursday 04 January 2018 11:06
by emme
acaonweb wrote: Thursday 04 January 2018 11:05 this is a function... the main script is this?
everything you need is there... I do not understand what you mean :oops: :oops:

Re: How check the power absorbed?

Posted: Thursday 04 January 2018 13:35
by acaonweb
ok, first i have to study functions :D

Re: How check the power absorbed?

Posted: Thursday 04 January 2018 13:45
by acaonweb
emme wrote: Thursday 04 January 2018 11:06
acaonweb wrote: Thursday 04 January 2018 11:05 this is a function... the main script is this?
everything you need is there... I do not understand what you mean :oops: :oops:
yes... i have just a dubt,
1) in device u trigger WAT_lavatrice i think is the seat plug you have in the function doesn't appears something like

Code: Select all

execute = function(domoticz, device)
but

Code: Select all

execute = function(dz, devWat, tgInfo)
i can't understand that.. what are devWat and tginfo?

Re: How check the power absorbed?

Posted: Thursday 04 January 2018 13:59
by jannl
Basically the same as I do with my PC. When the power is below 30watts for about 15 minutes, I switch off the zwave (in this case) switch. (Without dzvents btw)

Re: How check the power absorbed?

Posted: Thursday 04 January 2018 14:10
by emme
acaonweb wrote:
1) in device u trigger WAT_lavatrice i think is the seat plug you have in the function doesn't appears something like

Code: Select all

execute = function(domoticz, device)
but

Code: Select all

execute = function(dz, devWat, tgInfo)
i can't understand that.. what are devWat and tginfo?
ok... You have to understand the dzVents framework structure then... ;)

the trigger of the script is based on 2 separates events:

Code: Select all

	on = {
		devices = {'WAT_Lavatrice'},
		timer   = {'every minute'}
	},
a DEVICE info based on the update coming from the device WAT_Lavatrice (which is in my case the power consumption on the plug attached to the washingmachine)
a TIMER eventi that triggers every minute.
Why? because the device trigger must do some stuff (compare values and act by consequences) while the timer function have to count (if necessary) the minutes passed

Code: Select all

execute = function(dz, devWat, tgInfo)
dz, devWat,tgInfo are simple names... they could be even named domoticz, device, triggerinfo or foo, bar, zoo.... you just have to respect them in the code ;)

dz (or domoticz) = the entire Domoticz table containing all the nodes, variables and other useful stuff
devWat( or device) = contain ONLY the information about the device/variable that trigger the event, in case of timer info the table in null
tgInfo = the trigger information. this is a special table that contains information about why the scripts have been triggered

hope this will helps you to better understand it ;)
ciao
M

Re: How check the power absorbed?

Posted: Friday 05 January 2018 14:07
by acaonweb
yesss, now is clear...
i'm just starting with dzevents 😉 thanx for now

ciao
Fabrizio