For my motion sensor i use this script. Every minute the script is executed (script_time_nomotion.lua), a check is done if the motionsensor has activated. If not, the counter is upped with +1. When the counter reaches 30, a virtual switch is turned off.
For the washingmachine i would do something like this:
Code: Select all
--script_time_washingmachine.lua
--Change the values below to reflect to your own setup
local switch_washingmachine = 'virt_wasmachine' --Name of virtual switch that will show the state of the washingmachine (on/off)
local energy_consumption = 'Actual_wasmachine' --Name of Z-Wave plug that contains actual consumption of washingmachine (in Watts)
local washer_uservar = 'washingmachine_counter' --Name of the uservariable that will contain the counter that is needed
local idle_minutes = '10' --The amount of minutes the consumption has to stay below the 'consumption_lower' value
local consumption_upper = 4.0 --If usage is higher than this value (Watts), the washingmachine has started
local consumption_lower = 3.0 --If usage is lower than this value (Watts), the washingmachine is idle for a moment/done washing
commandArray = {}
--Virtual switch is off, but consumption is higher than configured level, so washing has started
if (tonumber(otherdevices_svalues[energy_consumption])) > consumption_upper and otherdevices[switch_washingmachine] == 'Off' then
commandArray[switch_washingmachine]='On'
print('Washingmachine is now ON')
commandArray['Variable:' .. washer_uservar]=tostring(idle_minutes)
else --Washing machine is not using a lot of energy, subtract the counter
if (tonumber(otherdevices_svalues[energy_consumption])) <= consumption_lower and otherdevices[switch_washingmachine] == 'On' then
commandArray['Variable:' .. washer_uservar]=tostring(math.max(uservariables[washer_uservar] - 1, 0))
end
end
--Washingmachine is done
if (otherdevices[switch_washingmachine] == 'On' and uservariables[washer_uservar] == 0) then
print('Washingmachine is DONE')
commandArray['SendNotification']='Washingmachine#Washingmachine is done, please go empty it!#0' --Use Domoticz to send a notification, replace line for your own command if needed.
commandArray[switch_washingmachine]='Off'
end
return commandArray
Code: Select all
commandArray['Variable:' .. washer_uservar]=tostring(math.max(tonumber(uservariables[washer_uservar]) - 1, 0))
Something for later
