Question about rule

Hello all,

i am following this guide https://docs.openhab.org/tutorials/beginner/rules.html
Now i dont have a wall-plug so i am trying to send a email when my phone connects and disconnects.

My mail.cfg is:

hostname=smtp-mail.outlook.com
port=587
username=myemailadres@hotmail.com
password=mypass123
from=myemailadres@hotmail.com
tls=true

My rules are:

Rule "Welkom Home"
when
  item Presence_Mobile_Brand changed from OFF to ON
then
  sendMail("myemailadres@hotmail.com", "Test subject", "Test message")
end

rule "Goodbye"
when
  item Presence_Mobile_Brand changed from ON to OFF
then
  sendMail("myemailadrres@hotmail.com'", "Test Goodbye subject", "Test Goodbye me$
end

But when my phone connects or disconnets i don’t receive a email.
What is wrong in my configuration?

Greet

But when my phone connects or disconnets i don’t receive a email.
What is wrong in my configuration?

Greet

when
	Item (not item)

also, fix the

(remove the ’ at the end of the email address)

Add logging

Example:

Rule "Welkom Home"
when
  Item Presence_Mobile_Brand changed from OFF to ON
then
  logInfo("Welkom Home", "I am home!")
  sendMail("myemailadres@hotmail.com", "Test subject", "Test message")
end

And do you see, in your logs, that Presence_Mobile_Brand is actually chaging from OFF to ON ?

Thanks for the repl’s

when
item

when
	Item (not item)
also, fix the

 diado:
sendMail("myemailadrres@hotmail.com’"

(remove the ’ at the end of the email address)

I wil fix those.

Add logging

Example:

Rule "Welkom Home"
when
  Item Presence_Mobile_Brand changed from OFF to ON
then
  logInfo("Welkom Home", "I am home!")
  sendMail("myemailadres@hotmail.com", "Test subject", "Test message")
end
And do you see, in your logs, that Presence_Mobile_Brand is actually chaging from OFF to ON ?

Thanks for the great logging tip. Wil the log be stored in the/var/log/openhab2 ?
Yes i do see a change in the log from ON to OFF.

Made the changes, but no luck. Still don’t receive a email.
Also tryed my rule with the channel id instead of the Item-name.

Greet

„rule“ is written in small letters :wink:

1 Like

„rule“ is written in small letters :wink:

Thanks, now it is working.
Everyone really thanks for the great help, already love the comunity.
A’ll go end play around some more with my RaspberryPi en Opehanb2.

Greet Diado