Re: Pushnotification when dishwasher/washing machine is ready?
Posted: Wednesday 31 May 2017 15:20
anyone?
Open source Home Automation System
https://forum.domoticz.com/
Hard to say anything just based on this info. I suggest adding more debug lines ( = print more stuff to log) on the script to see where it goes wrong. With just a quick look I noticed something that might play a role:maomanna wrote:anyone?
Code: Select all
local energy_consumption = 'verbruik wasmachine' --Name of Z-Wave plug that contains actual consumption of washingmachine (in
-- sWatt, sTotalkWh = otherdevices_svalues['Clothes Washer Power Usage']:match("([^;]+);([^;]+)")
-- washer_usage = tonumber(sWatt)
washer_usage = tonumber(otherdevices_svalues[energy_consumption])
You're free to do it however you like.gordonb3 wrote:Considering the various operating modes of the targeted devices that I own, I doubt that measuring power consumption and issuing an alarm/notification after X seconds of ample usage is very reliable. And of course this requires acquiring hardware that can measure the power usage of such devices and this will need to be quality hardware as the targeted devices will typically have a peak power rating (far) above 2000 Watts. Which doesn't seem like a very good investment as I can already deduce the power usage of these devices from my P1 reports. I'd guess it would be far cheaper and exact to get yourself a light monitoring device to detect whether the control light on the dishwasher/washing machine is on. Or to stay with the subject: signal when it turns off.
this is my device:Nautilus wrote:Hard to say anything just based on this info. I suggest adding more debug lines ( = print more stuff to log) on the script to see where it goes wrong. With just a quick look I noticed something that might play a role:maomanna wrote:anyone?Is your device "verbruik wasmachine" such it only reports Watts? If it reports energy (W & kWh) then you need the split which you have now commented out (and use correct device name there.Code: Select all
local energy_consumption = 'verbruik wasmachine' --Name of Z-Wave plug that contains actual consumption of washingmachine (in -- sWatt, sTotalkWh = otherdevices_svalues['Clothes Washer Power Usage']:match("([^;]+);([^;]+)") -- washer_usage = tonumber(sWatt) washer_usage = tonumber(otherdevices_svalues[energy_consumption])
Code: Select all
--script_time_washingmachine.lua
--Change the values below to reflect to your own setup
local washer_status_uservar = 'washingmachine_status'
local energy_consumption = 'wasmachine' --Name of Z-Wave plug that contains actual consumption of washingmachine (in Watts)
local washer_counter_uservar = 'washingmachine_counter' --Name of the uservariable that will contain the counter that is needed
local idle_minutes = 5 --The amount of minutes the consumption has to stay below the 'consumption_lower' value
local consumption_upper = 20 --If usage is higher than this value (Watts), the washingmachine has started
local consumption_lower = 4.3 --If usage is lower than this value (Watts), the washingmachine is idle for a moment/done washing
-- sWatt, sTotalkWh = otherdevices_svalues['wasmachine']:match("([^;]+);([^;]+)")
-- washer_usage = tonumber(sWatt)
washer_usage = tonumber(otherdevices_svalues[energy_consumption])
commandArray = {}
--Virtual switch is off, but consumption is higher than configured level, so washing has started
if (washer_usage > consumption_upper) and uservariables[washer_status_uservar] == 0 then
commandArray['Variable:' .. washer_status_uservar]='1'
print('Current power usage (' ..washer_usage.. 'W) is above upper boundary (' ..consumption_upper.. 'W), so washing has started!')
commandArray['SendNotification']='Wasmachine is gestart!'
commandArray['Variable:' .. washer_counter_uservar]=tostring(idle_minutes)
end
--Washing machine is not using a lot of energy, check the counter
if (washer_usage < consumption_lower) and uservariables[washer_status_uservar] == 1 then
commandArray['Variable:' .. washer_counter_uservar]=tostring(math.max(tonumber(uservariables[washer_counter_uservar]) - 1, 0))
print('Current power usage (' ..washer_usage.. 'W) is below lower boundary (' ..consumption_lower.. 'W), washer is idle or almost ready')
print('Subtracting counter, old value: ' ..uservariables[washer_counter_uservar].. ' minutes')
elseif ((uservariables[washer_counter_uservar] ~= idle_minutes) and uservariables[washer_status_uservar] == 1) then
commandArray['Variable:' .. washer_counter_uservar]=tostring(idle_minutes)
print('Resetting Washing Machine Timer')
end
--Washingmachine is done
if ((uservariables[washer_status_uservar] == 1) and uservariables[washer_counter_uservar] == 0) then
print('Washingmachine is DONE')
print('Current power usage washingmachine ' ..washer_usage.. 'W')
print('Washingmachine is done, please go empty it!')
commandArray['SendNotification']='Cycle Ended: Washing Machine#The load in the washing machine has finsihed, please move it to the dryer!#0'
commandArray['Variable:' .. washer_status_uservar]='0'
end
return commandArray
Code: Select all
2017-05-31 22:46:00.230 LUA: Resetting Washing Machine Timer
2017-05-31 22:46:00.230 EventSystem: Script event triggered: Wasmachine
2017-05-31 22:47:00.247 LUA: Resetting Washing Machine Timer
2017-05-31 22:47:00.247 EventSystem: Script event triggered: Wasmachine
2017-05-31 22:48:00.264 LUA: Resetting Washing Machine Timer
2017-05-31 22:48:00.265 EventSystem: Script event triggered: Wasmachine
2017-05-31 22:49:00.280 LUA: Resetting Washing Machine Timer
2017-05-31 22:49:00.280 EventSystem: Script event triggered: Wasmachine
Code: Select all
-- sWatt, sTotalkWh = otherdevices_svalues['wasmachine']:match("([^;]+);([^;]+)")
-- washer_usage = tonumber(sWatt)
washer_usage = tonumber(otherdevices_svalues[energy_consumption])
Code: Select all
sWatt, sTotalkWh = otherdevices_svalues['wasmachine']:match("([^;]+);([^;]+)")
washer_usage = tonumber(sWatt)
Code: Select all
sWatt, sTotalkWh = otherdevices_svalues['wasmachine']:match("([^;]+);([^;]+)")
washer_usage = tonumber(sWatt)
print('Current washer usage is '..washer_usage..'W')
i get this error:Nautilus wrote:So based on your screenshot the device shows both W and kWh so you need to change these lines:toCode: Select all
-- sWatt, sTotalkWh = otherdevices_svalues['wasmachine']:match("([^;]+);([^;]+)") -- washer_usage = tonumber(sWatt) washer_usage = tonumber(otherdevices_svalues[energy_consumption])
That is, uncomment first two and remove third. If it does not work, please try to add more debug lines as suggested. Start with something as simple as:Code: Select all
sWatt, sTotalkWh = otherdevices_svalues['wasmachine']:match("([^;]+);([^;]+)") washer_usage = tonumber(sWatt)
Code: Select all
sWatt, sTotalkWh = otherdevices_svalues['wasmachine']:match("([^;]+);([^;]+)") washer_usage = tonumber(sWatt) print('Current washer usage is '..washer_usage..'W')
Code: Select all
2017-06-14 20:39:00.208 Error: EventSystem: in Wasmachine: [string "--script_time_washingmachine.lua ..."]:13: attempt to concatenate global 'washer_usage' (a nil value)
Code: Select all
print(otherdevices_svalues['wasmachine'])
Nautilus wrote:Means the variable is nil, i.e. it does not get any value. What do you get if you putin the beginning of the script?Code: Select all
print(otherdevices_svalues['wasmachine'])
Code: Select all
--script_time_washingmachine.lua
--Change the values below to reflect to your own setup
local washer_status_uservar = 'washingmachine_status'
local energy_consumption = 'wasmachine' --Name of Z-Wave plug that contains actual consumption of washingmachine (in Watts)
local washer_counter_uservar = 'washingmachine_counter' --Name of the uservariable that will contain the counter that is needed
local idle_minutes = 5 --The amount of minutes the consumption has to stay below the 'consumption_lower' value
local consumption_upper = 20 --If usage is higher than this value (Watts), the washingmachine has started
local consumption_lower = 4.3 --If usage is lower than this value (Watts), the washingmachine is idle for a moment/done washing
sWatt, sTotalkWh = otherdevices_svalues['wasmachine']:match("([^;]+);([^;]+)")
washer_usage = tonumber(sWatt)
print('Current washer usage is '..washer_usage..'W')
print(otherdevices_svalues['wasmachine'])
commandArray = {}
--Virtual switch is off, but consumption is higher than configured level, so washing has started
if (washer_usage > consumption_upper) and uservariables[washer_status_uservar] == 0 then
commandArray['Variable:' .. washer_status_uservar]='1'
print('Current power usage (' ..washer_usage.. 'W) is above upper boundary (' ..consumption_upper.. 'W), so washing has started!')
commandArray['SendNotification']='Wasmachine is gestart!'
commandArray['Variable:' .. washer_counter_uservar]=tostring(idle_minutes)
end
--Washing machine is not using a lot of energy, check the counter
if (washer_usage < consumption_lower) and uservariables[washer_status_uservar] == 1 then
commandArray['Variable:' .. washer_counter_uservar]=tostring(math.max(tonumber(uservariables[washer_counter_uservar]) - 1, 0))
print('Current power usage (' ..washer_usage.. 'W) is below lower boundary (' ..consumption_lower.. 'W), washer is idle or almost ready')
print('Subtracting counter, old value: ' ..uservariables[washer_counter_uservar].. ' minutes')
elseif ((uservariables[washer_counter_uservar] ~= idle_minutes) and uservariables[washer_status_uservar] == 1) then
commandArray['Variable:' .. washer_counter_uservar]=tostring(idle_minutes)
print('Resetting Washing Machine Timer')
end
--Washingmachine is done
if ((uservariables[washer_status_uservar] == 1) and uservariables[washer_counter_uservar] == 0) then
print('Washingmachine is DONE')
print('Current power usage washingmachine ' ..washer_usage.. 'W')
print('Washingmachine is done, please go empty it!')
commandArray['SendNotification']='Cycle Ended: Washing Machine#The load in the washing machine has finsihed, please move it to the dryer!#0'
commandArray['Variable:' .. washer_status_uservar]='0'
end
return commandArray
2017-06-15 11:53:00.198 Error: EventSystem: in Wasmachine: [string "--script_time_washingmachine.lua ..."]:15: attempt to concatenate global 'washer_usage' (a nil value)
it look liked i had 2 devices names "wasmachine" 1 the switch and 1 the power usage.Nautilus wrote:As mentioned, please put it in the beginning of the script, it does not continue after the error anymore and you have it now after the error line (13).
Code: Select all
2017-06-15 14:31:00.459 LUA: 0.000;14571.000
2017-06-15 14:31:00.459 LUA: Current washer usage is 0W
2017-06-15 14:31:00.459 LUA: 50
Code: Select all
--script_time_washingmachine.lua
--Change the values below to reflect to your own setup
local washer_status_uservar = 'washingmachine_status'
local energy_consumption = 'WattWasmachine' --Name of Z-Wave plug that contains actual consumption of washingmachine (in Watts)
local washer_counter_uservar = 'washingmachine_counter' --Name of the uservariable that will contain the counter that is needed
local idle_minutes = 5 --The amount of minutes the consumption has to stay below the 'consumption_lower' value
local consumption_upper = 20 --If usage is higher than this value (Watts), the washingmachine has started
local consumption_lower = 4.3 --If usage is lower than this value (Watts), the washingmachine is idle for a moment/done washing
sWatt, sTotalkWh = otherdevices_svalues['WattWasmachine']:match("([^;]+);([^;]+)")
washer_usage = tonumber(sWatt)
print('Current washer usage is '..washer_usage..'W')
print(otherdevices_svalues['WattWasmachine'])
commandArray = {}
--Virtual switch is off, but consumption is higher than configured level, so washing has started
if (washer_usage > consumption_upper) and uservariables[washer_status_uservar] == 0 then
commandArray['Variable:' .. washer_status_uservar]='1'
print('Current power usage (' ..washer_usage.. 'W) is above upper boundary (' ..consumption_upper.. 'W), so washing has started!')
commandArray['SendNotification']='Wasmachine is gestart!'
commandArray['Variable:' .. washer_counter_uservar]=tostring(idle_minutes)
end
--Washing machine is not using a lot of energy, check the counter
if (washer_usage < consumption_lower) and uservariables[washer_status_uservar] == 1 then
commandArray['Variable:' .. washer_counter_uservar]=tostring(math.max(tonumber(uservariables[washer_counter_uservar]) - 1, 0))
print('Current power usage (' ..washer_usage.. 'W) is below lower boundary (' ..consumption_lower.. 'W), washer is idle or almost ready')
print('Subtracting counter, old value: ' ..uservariables[washer_counter_uservar].. ' minutes')
elseif ((uservariables[washer_counter_uservar] ~= idle_minutes) and uservariables[washer_status_uservar] == 1) then
commandArray['Variable:' .. washer_counter_uservar]=tostring(idle_minutes)
print('Resetting Washing Machine Timer')
end
--Washingmachine is done
if ((uservariables[washer_status_uservar] == 1) and uservariables[washer_counter_uservar] == 0) then
print('Washingmachine is DONE')
print('Current power usage washingmachine ' ..washer_usage.. 'W')
print('Washingmachine is done, please go empty it!')
commandArray['SendNotification']='Cycle Ended: Washing Machine#The load in the washing machine has finsihed, please move it to the dryer!#0'
commandArray['Variable:' .. washer_status_uservar]='0'
end
return commandArray
Code: Select all
2017-09-17 12:19:00.302 Error: EventSystem: in Wasmachine melding: [string "--script_time_washingmachine.lua..."]:15: attempt to concatenate global 'washer_usage' (a nil value)
Code: Select all
sWatt, sTotalkWh = otherdevices_svalues['WattWasmachine']:match("([^;]+);([^;]+)")
Code: Select all
--sWatt, sTotalkWh = otherdevices_svalues['WattWasmachine']:match("([^;]+);([^;]+)")
--washer_usage = tonumber(sWatt)
washer_usage = tonumber(otherdevices_svalues['WattWasmachine'])
Thanks for sharring.Goldwing1973 wrote: ↑Sunday 17 September 2017 21:49 I've had the same idea a little while ago, and this is how i solved it.
I'm using a Fibaro Wall Plug to measure its power consumption, when it uses 300watt or more a variable sets to on and writes it to the log.
Next it's waiting until the power consumption becomes 1.3 watt (ready, but the display on the washing machine still lid, 15 minutes later the display will turn off and power consumption will be 1 watt)
Then send a message, and turn on the most left light above the dining table.
Works like a charm and has a huge WAF (Wife Acceptance Factor)
Domoticz Wasmachine.png
This did the trickjvdz wrote: ↑Sunday 17 September 2017 13:05 Looks like the device WattWasmachine doesn't contain the right values. What is the exact content shown in the devices tab for it?
EDIT: This statement expect the svalue to contain "Current usage;Total kWh usage":Likely your device only has the current usage?Code: Select all
sWatt, sTotalkWh = otherdevices_svalues['WattWasmachine']:match("([^;]+);([^;]+)")
If so just modify the script to:JosCode: Select all
--sWatt, sTotalkWh = otherdevices_svalues['WattWasmachine']:match("([^;]+);([^;]+)") --washer_usage = tonumber(sWatt) washer_usage = tonumber(otherdevices_svalues['WattWasmachine'])