Pushnotification when dishwasher/washing machine is ready?

Moderator: leecollings

User avatar
nayr
Posts: 354
Joined: Tuesday 11 November 2014 18:42
Target OS: Linux
Domoticz version: github
Location: Denver, CO - USA
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by nayr »

happy to report that my Washing Machine, Clothes Dryer and Dish Washer are all using this script with great success..

The Dish Washer has a 30min timeout and a consumption_lower of 0.1w, this way it dont ask me to open it and I get blasted in the face with steam.. it goes right to 0w when its done, no idling around at the end.

Dryer since it is gas is very steady and dont idle about at all waiting for stuff to drain, used the same values I did for the washing machine and it's been fine.

I put these appliances in the $HiddenDevices room, the on/off switch are useless in a day to day need.. but I do want them available for scripts, I have a flood sensor in the basement shoved down an emergency drain, if something leaks or my sewer pipe clogs (it happens) it will trigger the washers to shutdown, so they dont contribute to the flooding... I am thinking of making a virtual override switch to enable during spring lightning storms, disconnect all non-critical equipment for say 12h.. just for extra safety, but then perhaps im trying to hard to find a use for the on/off switch huh?

Wife Approval Factor is very high, if only because I am more likely to getup and change a load out now that I know its in there and ready.
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Kjakan
Posts: 14
Joined: Wednesday 11 March 2015 14:03
Target OS: Linux
Domoticz version: 2024.2
Location: Norway
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by Kjakan »

Thanks for the scripts. Working great for my washing machine after some script modifications.
My clothes dryer have some issues and sometimes it's stopping before the dry program is finished. So I wanted to know how long the dryer been running before it stopped.

Created a simple function that gives me e.g. 1 hour and 5 minutes in notifications. This might be useful for others.

Code: Select all

function formatSeconds(seconds)
	local hours = math.floor(seconds / 3600)
	local seconds = seconds % 3600
	local minutes = math.floor(seconds / 60)
	local andTxt = ' and '
	if hours == 1 then hoursTxt = ' hour' else hoursTxt = ' hours' end
	if minutes == 1 then minutesTxt = ' minute' else minutesTxt = ' minutes' end
	if hours == 0 then hoursTxt = '' hours = '' andTxt = '' end
	if minutes == 0 then minutesTxt = '' minutes = '' andTxt = '' end
	return hours .. hoursTxt .. andTxt .. minutes .. minutesTxt  
end

function timedifference(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 = os.difftime (t1, t2)
	return difference
end

print(formatSeconds(7304)) --Result: 2 hours and 1 minute

--Send notification example
commandArray['SendNotification']='Dryer#Dryer has stopped after ' .. formatSeconds(timedifference(uservariables_lastupdate['YOUR_USERVARIABLE'])) .. '#0'
User avatar
MaffeMuis
Posts: 17
Joined: Saturday 09 August 2014 20:57
Target OS: NAS (Synology & others)
Domoticz version: 3.9483
Location: Netherlands - Limburg - Echt
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by MaffeMuis »

Thank you for this script! Works great for my washing machine!
Ik ben en blijf een brabander!
|Node-Red|Mqtt|ESPboards|tasmota|NAS|
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 »

Kjakan wrote:Thanks for the scripts. Working great for my washing machine after some script modifications.
My clothes dryer have some issues and sometimes it's stopping before the dry program is finished. So I wanted to know how long the dryer been running before it stopped.

Created a simple function that gives me e.g. 1 hour and 5 minutes in notifications. This might be useful for others.

Code: Select all

function formatSeconds(seconds)
	local hours = math.floor(seconds / 3600)
	local seconds = seconds % 3600
	local minutes = math.floor(seconds / 60)
	local andTxt = ' and '
	if hours == 1 then hoursTxt = ' hour' else hoursTxt = ' hours' end
	if minutes == 1 then minutesTxt = ' minute' else minutesTxt = ' minutes' end
	if hours == 0 then hoursTxt = '' hours = '' andTxt = '' end
	if minutes == 0 then minutesTxt = '' minutes = '' andTxt = '' end
	return hours .. hoursTxt .. andTxt .. minutes .. minutesTxt  
end

function timedifference(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 = os.difftime (t1, t2)
	return difference
end

print(formatSeconds(7304)) --Result: 2 hours and 1 minute

--Send notification example
commandArray['SendNotification']='Dryer#Dryer has stopped after ' .. formatSeconds(timedifference(uservariables_lastupdate['YOUR_USERVARIABLE'])) .. '#0'

this is a great addition to my script! thanx!
LovelessNl
Posts: 2
Joined: Thursday 10 March 2016 14:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by LovelessNl »

This is probably a silly question, but how do you configure where the messages in the script (such as 'Washing Machine#The load in the washing machine has finsihed, please move it to the dryer' go? I
LovelessNl
Posts: 2
Joined: Thursday 10 March 2016 14:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by LovelessNl »

Ah never mind, thats obviously just the default config from Domoticz...
Evelen
Posts: 234
Joined: Thursday 09 July 2015 12:03
Target OS: Linux
Domoticz version: 2.4538
Location: Norway
Contact:

Re: Pushnotification when dishwasher/washing machine is read

Post by Evelen »

nayr wrote:modified your script a bit @ThinkPad to fix a lil bug,

copied the counter setup line from the first if statment, and added it to the second as an elseif condition:

Code: Select all

if (washer_usage < consumption_lower) and uservariables[washer_status_uservar] == 1 then --Washing machine is not using a lot of energy, subtract the counter
  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 with 1, new 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)
end
my full script: http://pastebin.com/w9aWiu3B

this way the counter resets if its not idle for consecutive mins.. Watching a load wash now and I noticed wattage dropped real low but the counter did not reset after it went back up before timeout. My Washer gives a reminder tone @ 5mins and the notification came in within seconds of that going off.
sure the idle time is in minutes?, my log indicates it is much faster (seconds?):

Code: Select all

2016-10-03 22:33:16.981 LUA: Subtracting counter, old value: 6 minutes
2016-10-03 22:33:16.981 EventSystem: Script event triggered: Vaskemaskin LUA
2016-10-03 22:33:26.625 LUA: Current power usage (0W) is below lower boundary (10W), washer is idle or almost ready
2016-10-03 22:33:26.625 LUA: Subtracting counter, old value: 5 minutes
2016-10-03 22:33:26.626 EventSystem: Script event triggered: Vaskemaskin LUA
2016-10-03 22:33:27.801 LUA: Current power usage (0W) is below lower boundary (10W), washer is idle or almost ready
2016-10-03 22:33:27.801 LUA: Subtracting counter, old value: 4 minutes
2016-10-03 22:33:27.801 EventSystem: Script event triggered: Vaskemaskin LUA
2016-10-03 22:33:30.062 LUA: Current power usage (0W) is below lower boundary (10W), washer is idle or almost ready
2016-10-03 22:33:30.062 LUA: Subtracting counter, old value: 3 minutes
2016-10-03 22:33:30.062 EventSystem: Script event triggered: Vaskemaskin LUA
2016-10-03 22:33:30.066 LUA: Current power usage (0W) is below lower boundary (10W), washer is idle or almost ready
2016-10-03 22:33:30.066 LUA: Subtracting counter, old value: 2 minutes
2016-10-03 22:33:30.066 EventSystem: Script event triggered: Vaskemaskin LUA
2016-10-03 22:33:30.068 LUA: Current power usage (0W) is below lower boundary (10W), washer is idle or almost ready
2016-10-03 22:33:30.068 LUA: Subtracting counter, old value: 1 minutes
2016-10-03 22:33:30.068 EventSystem: Script event triggered: Vaskemaskin LUA
2016-10-03 22:33:37.806 LUA: Current power usage (0W) is below lower boundary (10W), washer is idle or almost ready
2016-10-03 22:33:37.806 LUA: Subtracting counter, old value: 0 minutes
Evelen
Posts: 234
Joined: Thursday 09 July 2015 12:03
Target OS: Linux
Domoticz version: 2.4538
Location: Norway
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by Evelen »

did a test.
looks like tha value "1000" equals 1h (or 60m)

Code: Select all

local idle_minutes            = 1000
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by Nautilus »

Evelen wrote:did a test.
looks like tha value "1000" equals 1h (or 60m)

Code: Select all

local idle_minutes            = 1000
Hi, as long as you make sure the script is defined as "time" script it really runs once a minute. If it is defined as "device" script it triggers for every device change which I guess could explain the above ( = about 1000 device changes in an hour). But yeah, once it is defined as time script, it'll work as intended and run only once a minute...:)
Evelen
Posts: 234
Joined: Thursday 09 July 2015 12:03
Target OS: Linux
Domoticz version: 2.4538
Location: Norway
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by Evelen »

thanks ;) worked.
amblyo
Posts: 2
Joined: Saturday 21 January 2017 11:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by amblyo »

I have problem that the script runs to often and not every minute.

How do i define a script as a "time script"?
Nautilus wrote:
Evelen wrote:did a test.
looks like tha value "1000" equals 1h (or 60m)

Code: Select all

local idle_minutes            = 1000
Hi, as long as you make sure the script is defined as "time" script it really runs once a minute. If it is defined as "device" script it triggers for every device change which I guess could explain the above ( = about 1000 device changes in an hour). But yeah, once it is defined as time script, it'll work as intended and run only once a minute...:)
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by ben53252642 »

This is the script I'm using for my washing machine (based on power usage in watts):

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) >= 10 ) then
commandArray['Variable:WashingMachineState'] = 'inuse'
end

if (uservariables["WashingMachineState"] == 'inuse' and tonumber(wattvalue) <= 1 ) then
commandArray['Variable:WashingMachineState'] = 'notinuse'
os.execute ('/var/www/tts/speak.sh "Kitchen" "The washing machine has finished."')
commandArray['SendNotification']='Notification#The washing machine has finished.'
end

return commandArray
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by Nautilus »

amblyo wrote: How do i define a script as a "time script"?
If you have the script as text file in the lua directory, the naming needs to be script_time_XXX.lua. If you have it in the database (= are using the web interface for managing events) under the "Event name" section (top right) there's a dropdown selector with default value "All" that you need to change to "Time" and save the script.
amblyo
Posts: 2
Joined: Saturday 21 January 2017 11:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by amblyo »

Thanks!

I missed that obvious dropdown in the webinterface.

Hope that it solves my problem.
maomanna
Posts: 94
Joined: Monday 30 November 2015 16:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by maomanna »

i dont get it,

tried several scripts.

in the log i see (like every second)
2017-04-12 22:57:47.654 Error: EventSystem: in script_time_wasmachine: [string "--script_time_washingmachine.lua ..."]:18: attempt to compare number with nil
it is this script:

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      = 'verbruik 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['Clothes Washer Power Usage']: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['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
How can i fix this?
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by Nautilus »

If you have created the script via the event management in the web UI make sure the type is set as "Time" and not "All" or "Device". If you have stored it in the file system make sure the name starts with script_time_

Then Domoticz knows it's a time script and runs it only once a minute.
Hesmink
Posts: 168
Joined: Monday 22 June 2015 10:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by Hesmink »

Thanks all for perfecting this script!

Just received my TP-Link HS110, and it got just notified of my first finished washing routine!
The notification comes around 10 minutes after actually finishing, my washing machine still does 'stuff' costing energy.
It also has anti-crease security that once in a while spins the drum. Maybe disabling this helps.
SiggeStardust
Posts: 2
Joined: Tuesday 03 January 2017 10:34
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: Sweden
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by SiggeStardust »

Just a wild idea and also perhaps ofThread .
Main thread is how to determine when a machine is done and then give a notification.
I want to focus on the later part since the detection phase is working . but instead of having a push notification like Pushover that i use, i would like to have a TTS message in my Sonos telling me that the "Laundry is done" Anyone having thoughts about how to do this ?
Besides Domoticz i also use HASS and their is a Sonos TTS interface that i thought might be usefull.
What would we do with all our time if we didnt have HomeAutomation
:lol:
maomanna
Posts: 94
Joined: Monday 30 November 2015 16:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by maomanna »

SiggeStardust wrote: What would we do with all our time if we didnt have HomeAutomation
:lol:
ask your wife:-)
maomanna
Posts: 94
Joined: Monday 30 November 2015 16:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pushnotification when dishwasher/washing machine is ready?

Post by maomanna »

Nautilus wrote:If you have created the script via the event management in the web UI make sure the type is set as "Time" and not "All" or "Device". If you have stored it in the file system make sure the name starts with script_time_

Then Domoticz knows it's a time script and runs it only once a minute.
it is created as time in the web ui.
When i reset the timer manually, it eventually will send my a notification when it returned to "5".
But when i start using the washingmachine, it does not reset.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest