How check the power absorbed?

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
acaonweb
Posts: 78
Joined: Thursday 23 March 2017 14:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

How check the power absorbed?

Post 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
SweetPants

Re: How check the power absorbed?

Post 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
acaonweb
Posts: 78
Joined: Thursday 23 March 2017 14:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How check the power absorbed?

Post by acaonweb »

Ive already had a look there but I’m not able. I need suggestion ;-)
SweetPants

Re: How check the power absorbed?

Post by SweetPants »

Have you tried something already?
acaonweb
Posts: 78
Joined: Thursday 23 March 2017 14:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How check the power absorbed?

Post by acaonweb »

No, i’ve written scripts in dzevents but in this case I don’t know how start :-)
acaonweb
Posts: 78
Joined: Thursday 23 March 2017 14:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How check the power absorbed?

Post by acaonweb »

any ideas? There someone that trigger when a washer has finished?
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: How check the power absorbed?

Post 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
The most dangerous phrase in any language is:
"We always done this way"
acaonweb
Posts: 78
Joined: Thursday 23 March 2017 14:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How check the power absorbed?

Post by acaonweb »

great i'll study it because i don't know so much about functions
Thanx for now
acaonweb
Posts: 78
Joined: Thursday 23 March 2017 14:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How check the power absorbed?

Post by acaonweb »

this is a function... the main script is this?
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: How check the power absorbed?

Post 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:
The most dangerous phrase in any language is:
"We always done this way"
acaonweb
Posts: 78
Joined: Thursday 23 March 2017 14:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How check the power absorbed?

Post by acaonweb »

ok, first i have to study functions :D
acaonweb
Posts: 78
Joined: Thursday 23 March 2017 14:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How check the power absorbed?

Post 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?
jannl
Posts: 625
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: How check the power absorbed?

Post 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)
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: How check the power absorbed?

Post 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
The most dangerous phrase in any language is:
"We always done this way"
acaonweb
Posts: 78
Joined: Thursday 23 March 2017 14:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How check the power absorbed?

Post by acaonweb »

yesss, now is clear...
i'm just starting with dzevents 😉 thanx for now

ciao
Fabrizio
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest