Send message at text change Topic is solved

Post Reply
satanasinc
Posts: 30
Joined: Monday 19 October 2015 12:15
Target OS: Raspberry Pi
Domoticz version:
Contact:

Send message at text change

Post by satanasinc » Sunday 01 April 2018 18:39

Hi!

First of all exuse my baad english.

Im trying to send a email o telegram message when my vaccum start to clean and when it goes back to the dock station. The problem is my script dont send 1 email when the text change the state the script sends many.

commandArray = {}
if (otherdevices_svalues['M-O - Status'] == 'Cleaning')
then
commandArray['SendEmail']='M-O IS cleaning...#M-O Cleaning...#myvacuum@gmail.com'
end
if (otherdevices_svalues['M-O - Status'] == 'Back to home')
then
commandArray['SendEmail']='M-O Going back home...#M-O Returning home...#myvacuum@gmail.com'
end
return commandArray

I have tried this without luck. Now nothing is send.

commandArray = {}
if (devicechanged['M-O - Status'] == 'Cleaning') then
commandArray['SendEmail']='M-O Cleaning...#M-O Cleaning...#myvacuum@gmail.com'
elseif (devicechanged['M-O - Status'] == 'Back to home') then
commandArray['SendEmail']='M-O Returning home...#M-O Returning home...#myvacuum@gmail.com'
end
return commandArray

Anyone knows how to send a telegram message instead a email?

Thanx in advance for your help and regards

User avatar
jvdz
Posts: 1398
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: Send message at text change

Post by jvdz » Sunday 01 April 2018 18:55

You really should also test for devicechanged['""] in stead of just otherdevices_svalues.
Maybe this works? I have added an print() line to show the actual values in the domoticz log to help with debugging :

Code: Select all

commandArray = {}
if (devicechanged['M-O - Status'] ~= nil then
	print("Changed:" .. devicechanged['M-O - Status'] .. "   Status:" ..otherdevices_svalues['M-O - Status'])
	if (otherdevices_svalues['M-O - Status'] == 'Cleaning') 
	then
		commandArray['SendEmail']='M-O IS cleaning...#M-O Cleaning...#myvacuum@gmail.com'
	end
	if (otherdevices_svalues['M-O - Status'] == 'Back to home')
	then
		commandArray['SendEmail']='M-O Going back home...#M-O Returning home...#myvacuum@gmail.com'
	end
end
return commandArray
Jos

satanasinc
Posts: 30
Joined: Monday 19 October 2015 12:15
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Send message at text change

Post by satanasinc » Sunday 01 April 2018 19:08

jvdz wrote:
Sunday 01 April 2018 18:55
You really should also test for devicechanged['""] in stead of just otherdevices_svalues.
Maybe this works? I have added an print() line to show the actual values in the domoticz log to help with debugging :

Code: Select all

commandArray = {}
if (devicechanged['M-O - Status'] ~= nil then
	print("Changed:" .. devicechanged['M-O - Status'] .. "   Status:" ..otherdevices_svalues['M-O - Status'])
	if (otherdevices_svalues['M-O - Status'] == 'Cleaning') 
	then
		commandArray['SendEmail']='M-O IS cleaning...#M-O Cleaning...#myvacuum@gmail.com'
	end
	if (otherdevices_svalues['M-O - Status'] == 'Back to home')
	then
		commandArray['SendEmail']='M-O Going back home...#M-O Returning home...#myvacuum@gmail.com'
	end
end
return commandArray
Jos
Hello!
Thanks for your help, now it works perfect and I like it.
Now I will try to understand your modification.

Note:
A parenthesis was missing before the first then.

Thanks again.

regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest