Pushnotification when dishwasher/washing machine is ready?

Moderator: leecollings

ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Create a Event or Lua to get push notification when dish

Post by ThinkPad »

I took some time to rewrite it to a more 'logical' version:

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
(Credits for the basic 'structure' of the script go to nickyb2, who is always great in helping me out)

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.
I am not active on this forum anymore.
ropske
Posts: 483
Joined: Tuesday 12 August 2014 5:37
Target OS: Raspberry Pi / ODroid
Domoticz version: V3_8394
Location: Rumbeke,Belgium
Contact:

Re: Create a Event or Lua to get push notification when dish

Post by ropske »

if your script is working fine for your application, i'm glad your you ;-)
mine is working ok for my application ;-)

if you need any help, please ask.
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by ThinkPad »

Today the washing machine is on, and i already received 8 pushnotifications... but the washing machine is still runing....
So my script is not good yet...

Will try and see if i can adjust it
I am not active on this forum anymore.
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by tlpeter »

I think it now has some data which you can look back on how much it used.
I guess the lowest usage will be when it is doing very little like letting out water.
You could measure the time if the usage is too low to use.
Then build a script which uses usage and time.
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by ThinkPad »

Downside is that the graphs in Domoticz accumulate data by every 5 minutes... So my graph jumps from 10:40 to 10:45. This makes it harder to determine what the washing machine was doing.

But it seems that when it is 'idle' (not pumping, heating water, or tumbling) it uses 3W. This always takes under a minute
I am not active on this forum anymore.
matthijs
Posts: 17
Joined: Friday 29 May 2015 12:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Create a Event or Lua to get push notification when dish

Post by matthijs »

ThinkPad wrote:I took some time to rewrite it to a more 'logical' version:

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
(Credits for the basic 'structure' of the script go to nickyb2, who is always great in helping me out)

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.
I tried this script with my washing machine, but I got also a lot of notifications. After checking the lua documentation (I'm not a real scripter) I discovered the function tonumber(). This converts a string to a number. I think the script was not converting the string correctly to a number (something lua tries to do automatically). Now it's working like a charm. My washing machine has a maximum value of 2 watt when it's on but not in a program and when a program is running the lowest value is 3 watt which is easy to program. I added the code with tonumber() added.

Code: Select all

local switch_washingmachine = 'virt_wasmachine'
commandArray = {}

--If actual consumption of measured by Z-Wave plug is higher than 2W, washingmachine is on
if (tonumber(otherdevices_svalues['Wasmachine'])) > 2.0 and otherdevices[switch_washingmachine] == 'Off' then
   commandArray[switch_washingmachine]='On'
   print('Wasmachine staat AAN')   
   else 
   if (tonumber(otherdevices_svalues['Wasmachine'])) <= 2.0 and otherdevices[switch_washingmachine] == 'On' then
      print('Wasmachine is KLAAR')
	  commandArray['SendNotification']='Wasmachine#Wasmachine is klaar!#0'
	  commandArray[switch_washingmachine]='Off'
  end
end  

return commandArray
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by ThinkPad »

Thanks, will try it again soon.

Script has a high WAF (Wife Acceptance Factor) so would be nice if i could get it working reliable.

But i'm not sure, because it seems you don't use the counter part. I think i need that, because the washing machine has the same low usage when it is waiting between rotating the other way round as when it is done with everything.
I am not active on this forum anymore.
matthijs
Posts: 17
Joined: Friday 29 May 2015 12:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by matthijs »

I suppose you can just use your script and add the tonumber() function and use the timer. I noticed that that right values where there, but the equation was not always done right. If lua can't read the value as a number it is nill. That is always lower than 2 or 3 watt so the script thinks the washing machine is ready. It's strange because lua normally transforms this automatically but in this case it doesn't.
User avatar
Plaagje
Posts: 42
Joined: Thursday 30 April 2015 10:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Netherlands
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by Plaagje »

Thanks for the script,

i changed it a bit,,, check it out:

Code: Select all

commandArray = {}

sWasmachine = otherdevices_svalues['Wasmachine']:match("([^;]+)")
sWasmachine = tonumber(sWasmachine);
print("Wasmachine: Wasmachine load is: " .. sWasmachine .. " ");

--If actual consumption of measured by Z-Wave plug is higher than 2W, washingmachine is on
if sWasmachine > 2.0 and otherdevices['switch_washingmachine'] == 'Off' then
	commandArray['switch_washingmachine']='On'
	print('Wasmachine staat AAN')   
   
   elseif sWasmachine <= 2.0 and otherdevices['switch_washingmachine'] == 'On' then
		print('Wasmachine is KLAAR')
		commandArray['SendNotification']='Wasmachine#Wasmachine is klaar!#0'
		commandArray['switch_washingmachine']='Off'
end

return commandArray
name is script_device_Wasmachine.lua

I have a Fibaro wall switch (the small one with the led ring), and it gives me 3 devices, 1 switch and 2 energy devices,,, i named the energy device that showed the power usage Wasmachine and i created the virtual switch as mentioned above.
Last edited by Plaagje on Monday 01 June 2015 21:41, edited 1 time in total.
User avatar
Plaagje
Posts: 42
Joined: Thursday 30 April 2015 10:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Location: Netherlands
Contact:

Re: Create a Event or Lua to get push notification when dish

Post by Plaagje »

matthijs wrote: commandArray[switch_washingmachine]=
should be:

commandArray['switch_washingmachine']=

dont forget the quotes ;-)
matthijs
Posts: 17
Joined: Friday 29 May 2015 12:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by matthijs »

Plaagje wrote:dont forget the quotes
Thank you for cleaning up the script. My coding skills aren't that good but I try and learn. I made switch_washingmachine local, because my real switch is called virt_wasmachine ( I used the script Thinkpad provided and edited it after I got the same problem with the push notifications). I thought you don't need the quotes when you make it local, but your script is much cleaner.
ivom74
Posts: 52
Joined: Wednesday 03 September 2014 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by ivom74 »

Which energy reading device you used ?
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by ThinkPad »

I am not active on this forum anymore.
NiklasO
Posts: 67
Joined: Friday 16 August 2013 18:34
Target OS: -
Domoticz version:
Location: Stockholm, Sweden
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by NiklasO »

This is my solution using Blockly. Works every time and no dual notifications.
blockly.png
blockly.png (58.37 KiB) Viewed 6929 times
I use a virtual device to see if the machine is running a program or not, great for visible confirmation:
Namnlös.png
Namnlös.png (19.52 KiB) Viewed 6929 times
Over 2,2W: washing machine running a program.
1,8W or less: washing machine not running a program or off/stand-by.

You mileage may vary. ;)
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by ThinkPad »

My washingmachine uses the same when it is waiting before reversing spinning direction as when it is totally done. So a solution like your Blockly isn't going to work for me :(
I am not active on this forum anymore.
djoeney
Posts: 15
Joined: Sunday 17 May 2015 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by djoeney »

ThinkPad wrote:My washingmachine uses the same when it is waiting before reversing spinning direction as when it is totally done. So a solution like your Blockly isn't going to work for me :(
Thinkpad can you confirm the script is running stable? with the version you applied above?
Compute RPi 2 : Domoticz latest beta, Synology : Domoticz tested beta on failover system.
Peripherals RFXCOM - RFXtrx433, Z-Wave.Me ZME_UZB1 USB Stick,P1 cable on smartmeter, Logitech Harmony Hub, 3 IP camera's
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by ThinkPad »

I am not using it, couldn't get this working because of the reason you quoted in your post.
I am not active on this forum anymore.
djoeney
Posts: 15
Joined: Sunday 17 May 2015 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by djoeney »

To bad, is has a high WAF. Like you mentioned. I'm hoping to get this stable with my wash machine.
Compute RPi 2 : Domoticz latest beta, Synology : Domoticz tested beta on failover system.
Peripherals RFXCOM - RFXtrx433, Z-Wave.Me ZME_UZB1 USB Stick,P1 cable on smartmeter, Logitech Harmony Hub, 3 IP camera's
D'rMorris
Posts: 138
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by D'rMorris »

You can still use the script, you just would need to add a timeout to it.
I assume the washing machine needs perhaps 10 seconds or so to go into reverse spinning mode, so if you add another clause to the script, you can circumvent that issue.
For example, create a uservariable called "dishwasher_timeout" and fill in the timeout that the dishwasher needs to reverse.
Then, in your code check whether this timeout has passed with a function, like this:

Code: Select all

print('<b style="color:Blue">>   Monitoring Dishwasher</b>')

------------- Begin time functions -------------

function timedifference_dishwasher (s)
  year = string.sub(s, 1, 4)
  month = string.sub(s, 6, 7)
  day = string.sub(s, 9, 10)
  hour = string.sub(s, 12, 13)
  minutes = string.sub(s, 15, 16)
  seconds = string.sub(s, 18, 19)
  t1 = os.time()
  t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
  difference_dishwasher = os.difftime (t1, t2)
  return difference_dishwasher
end

------------- End time functions -------------


------------- Begin local variables -------------

-- Debug variables:
debug                   = uservariables["debug_general"]
dishwasher_timeout      = uservariables["dishwasher_timeout"]
difference_dishwasher   = timedifference_dishwasher(otherdevices_lastupdate['dishwasher_on_off_switch'])

------------- End local variables -------------


------------- Begin debug statements -------------

if debug=="Y" 
  then
  print('<b style="color:Red">>> Debug is set to: ' .. debug .. '</b>')
  print('<b style="color:Red">>> Dishwasher timeout is set to: ' .. dishwasher_timeout .. '</b>')
end

------------- End debug statements -------------


------------- Begin code -------------

if (otherdevices['PowerUsageDishwasher'] >= '2' and 
    difference_dishwasher > dishwasher_timeout)
    then
        action
    else
        print('<b style="color:Red">>> Dishwasher still running. Dishwasher last seen: ' .. difference_dishwasher .. ' seconds ago</b>')
    end

------------- End code -------------
djoeney
Posts: 15
Joined: Sunday 17 May 2015 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by djoeney »

Thanks Can't wait for my order to get delivered. Will post the outcome when done!
Compute RPi 2 : Domoticz latest beta, Synology : Domoticz tested beta on failover system.
Peripherals RFXCOM - RFXtrx433, Z-Wave.Me ZME_UZB1 USB Stick,P1 cable on smartmeter, Logitech Harmony Hub, 3 IP camera's
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest