Send message at text change Topic is solved

Moderator: leecollings

Post Reply
satanasinc
Posts: 41
Joined: Monday 19 October 2015 12:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Spain
Contact:

Send message at text change

Post by satanasinc »

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...#[email protected]'
end
if (otherdevices_svalues['M-O - Status'] == 'Back to home')
then
commandArray['SendEmail']='M-O Going back home...#M-O Returning home...#[email protected]'
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...#[email protected]'
elseif (devicechanged['M-O - Status'] == 'Back to home') then
commandArray['SendEmail']='M-O Returning home...#M-O Returning home...#[email protected]'
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: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Send message at text change

Post by jvdz »

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...#[email protected]'
	end
	if (otherdevices_svalues['M-O - Status'] == 'Back to home')
	then
		commandArray['SendEmail']='M-O Going back home...#M-O Returning home...#[email protected]'
	end
end
return commandArray
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
satanasinc
Posts: 41
Joined: Monday 19 October 2015 12:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Spain
Contact:

Re: Send message at text change

Post by satanasinc »

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...#[email protected]'
	end
	if (otherdevices_svalues['M-O - Status'] == 'Back to home')
	then
		commandArray['SendEmail']='M-O Going back home...#M-O Returning home...#[email protected]'
	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