In this tutorial we will show how to send SMS message when sensors detect water leak. 

We already show how to build water leak sensor. We can see sensor status in EasyIoT WEB user interface, but we usually want to be notified as soon as possible when water leak occurs. We assume, that we have installed SMS interface. We can also easily adopt automation program to use EmailHelper.

It's recommended to read tutorials about automation before you start:

EasyIoT server automation - part I

EasyIoT server automation - part II

EasyIoT server automation - part III

First add automation program and name it water leak notification.

water leak notification program

In next step add SMS notification in Setup function. We will use EventHelper and SmsHelper. In event helper we will detect water leak alarm and with SmsHelper we will send SMS alarm notification.Program is like this. Change module addresses to suit your sensor configuration. 

/*
  This code is running one time when program is enabled
*/
public void Setup()
{		
    EventHelper.ModuleChangedHandler((o, m, p) =>
    {    
  	  // bathroom alarm
      if (m.Domain == Domains.MYSENSORS && m.Address == "N8S0" && p.Property == "Sensor.Leak" && p.Value == "1")
      	SmsHelper.SendSms("+38xxxxxxxxx","Water leak in bathroom");
      
      // living room
      if (m.Domain == Domains.MYSENSORS && m.Address == "N3S0" && p.Property == "Sensor.Leak" && p.Value == "1")
        SmsHelper.SendSms("+38xxxxxxxxx","Water leak in living room");
        
      return true;
    });
}

/*
  This code is running periodicaly when program is enabled. 
  Cron job detirmine running period.
*/
public void Run()
{
}  

We can also add switch to disable SMS notification. First add Virtual module DO switch and name it SMS notification enable.

Remember module address and modify existing program to check switch status.

/*
  This code is running one time when program is enabled
*/
public void Setup()
{		
    EventHelper.ModuleChangedHandler((o, m, p) =>
    { 
// read switch status
ModuleParameter par = ModuleHelper.GetProperty(Domains.VIRTUAL, "N19S0", "Sensor.DigitalValue");

if (par.Value == "1")
{ // bathroom alarm if (m.Domain == Domains.MYSENSORS && m.Address == "N8S0" && p.Property == "Sensor.Leak" && p.Value == "1") SmsHelper.SendSms("+38xxxxxxxxx","Water leak in bathroom"); // living room if (m.Domain == Domains.MYSENSORS && m.Address == "N3S0" && p.Property == "Sensor.Leak" && p.Value == "1") SmsHelper.SendSms("+38xxxxxxxxx","Water leak in living room"); } return true; }); } /* This code is running periodicaly when program is enabled. Cron job detirmine running period. */ public void Run() { }

Comments   

#5 profile 2018-11-01 12:35
Need cheap hosting? Try webhosting1st, just $10 for an year.

+1 #4 Super User 2015-09-20 12:30
Quoting jati:
I got 120 sms notification water is leak, hmmm how to notif just one if GPIO status value is 1



Simply check when is last time when you send SMS and if time is to short do not send message again.
If I remember correctly one of community members post solution on forum.
+1 #3 jati 2015-09-19 23:25
I got 120 sms notification water is leak, hmmm how to notif just one if GPIO status value is 1
+1 #2 Super User 2015-05-26 21:23
Quoting DarioCdj:
Mr.EasyIoT, there are two programs because you can choose one or the other ? Normally i disable sms notifications going in automation and disabling program... Second program is just to have a switch in groups?


Yes, there are two programs. One without switch and one with enable/disable switch.
#1 DarioCdj 2015-05-23 22:34
Mr.EasyIoT, there are two programs because you can choose one or the other ? Normally i disable sms notifications going in automation and disabling program... Second program is just to have a switch in groups?

You have no rights to post comments

Forum latest

  • No posts to display.