In the below script if the washing machines power usage exceeds 4 watts an event will run once, if it falls below 4 watts another event will run once.
Code: Select all
commandArray = {}
-- Change Watt Device value to number and remove the word Watt
wattdevice = otherdevices_svalues['Washing Machine / Dryer Watts']
function stripchars(str, chrs)
local s = str:gsub("["..chrs.."]", '')
return s end
wattvalue = stripchars( wattdevice, " Watt" )
if (uservariables["WashingMachineState"] == 'notinuse' and tonumber(wattvalue) >= 4 ) then
commandArray['Variable:WashingMachineState'] = 'inuse'
os.execute ('sh /domoticz/speak.sh "speaker2 I am ready to wash your clothes."')
end
if (uservariables["WashingMachineState"] == 'inuse' and tonumber(wattvalue) <= 4 ) then
commandArray['Variable:WashingMachineState'] = 'notinuse'
os.execute ('sh /domoticz/speak.sh "speaker2 The washing is finished."')
end
return commandArray