script_time_washingmachine.lua
Code: Select all
-- The name of the virtual washing machine switch
local switch_washingmachine = 'virt_wasmachine'
commandArray = {}
--If actual consumption of measured by Z-Wave plug is higher than or equal to 4W, washingmachine is on
if (otherdevices_svalues['Actual_wasmachine'] >= '4' and otherdevices[switch_washingmachine] == 'Off') then
commandArray[switch_washingmachine]='On'
print('Wasmachine staat AAN')
commandArray['Variable:washingmachine_dummyCounter']='10'
else
if (otherdevices_svalues['Actual_wasmachine'] < '3' and otherdevices[switch_washingmachine] == 'On') then
commandArray['Variable:washingmachine_dummyCounter']=tostring(math.max(uservariables['washingmachine_dummyCounter'] - 1, 0))
end
end
if (otherdevices[switch_washingmachine] == 'On' and uservariables['washingmachine_dummyCounter'] == 0) then
print('Wasmachine is KLAAR')
commandArray['SendNotification']='Wasmachine#Wasmachine is klaar!#0'
commandArray[switch_washingmachine]='Off'
end
return commandArray
What you need:
- A virtual switch ('virt_wasmachine')
- A user variable ('wasmachine_dummyCounter')
How it works:
It checks if the power usage is higher than or equal to 4W, if yes: washing machine is on. It will set the virtual switch to on and set the counter (user variable) to a defined value.
It will then check if the virtual switch is on and get the counter value and updates the counter with the value MINUS 1 (this is a sort of timer, because the script will be initiated every minute).
If the counter reaches zero and the virtual switch = on then send a pushmessage and turn switch off
First test with a lightbulb worked fine, after about 5 minutes after turning off the light i received a message.
The value (>10W) and the time (5 minutes) are values i have to measure in real life, and adjust the script to. I don't know how much Watt my washing machine uses when it is waiting (between spinning, heating and pumping). I also don't know how much time it will 'wait' while doing this. But i can just measure it
I also don't know if the 'if/elseif/else' structure is correct. I first left out the last 'else', but then i got errors.