Email Notification

I’m using network binding to monitor online status of some network devices. I would like to receive an email if one of the device states switches from OFF to ON.

items/network.items
Switch ping_my_nas “NAS” {channel=“network:pingdevice:my_nas:online”}
Switch ping_ps4 “Sony Playstation 4” {channel=“network:pingdevice:ps4:online”}

rules/nas.rules
rule “NAS Online”
when
Item ping_my_nas changed from OFF to ON
then
sendMail(“myEmail@email.com”, “NAS is online”, “NAS is online”)
logInfo(“notifications”, “Sending notification for my_nas via mail.”)
end

events.log
2019-12-24 00:07:13.003 [vent.ItemStateChangedEvent] - network_pingdevice_my_nas_online changed from OFF to ON

But I don’t receive any email. Addon Mail Action is working fine and rules used to work before but suddenly stopped working.

Thank you for your help.

Manuel

1 Like

You’ll want to look in openhab.log to see if -
Your rules file loads
Your sendmail spits an error message
Your logInfo reports

You’ll probably also want to look at -

This Item is not that Item -

Before what?
What did you do?
Which version of openHAB are you running?
The latest version use a mail binding instead of an action.

If you had read the Release notes for 2.5 before upgrading you would know that the Mail action is deprecated in favor of a new Mail binding.

1 Like

Hello all
Thank you very much for your help. I’m still using openhab 2.4.0-1 with Mail Action addon.

2019-12-24 16:00:14.896 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'nas.rules'
2019-12-24 16:00:16.311 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'nas.rules'

My nas.rules file can be loaded without any errors in /var/log/openhab.log.

This Item is not that Item

But the name in my Item files network.items is

etc/openhab2$ cat items/network.items 
Switch ping_my_nas "NAS"                         {channel="network:pingdevice:my_nas:online"}
Switch ping_ps4    "Sony Playstation 4"      {channel="network:pingdevice:ps4:online"}

I didn’t change anything in my network.items and nas.rules and ps.rules file and it stopped working.

You’ll want to look in openhab.log to see if -
Your rules file loads
Your sendmail spits an error message
Your logInfo reports

  • Rule is loaded
  • No sendmail error message
  • No LogInfo report at all

Greetings and merry christmas.

Manuel

I believe you.
But that Item is not this Item

If ping_my_nas Item never changes in your events.log then of course your rule will never run.
network_pingdevice_my_nas_online is some different Item.
Perhaps you’ve got Simple Mode configured, people often end up in a knot ith semi-duplicated Items.