How to check sensor is live ?

8 years 8 months ago #2068 by DaTT
Replied by DaTT on topic How to check sensor is live ?

bit wrote: hello, i'm back with my code.
it seems to work properly, but i please you to test it..

I confirm the functionality of code! Only when editing CRON time I have a problem to write * / 10 but when I try to create a new so it goes. And I see there still time to 4:48 PM in automation, what does it mean this time? thank you

I'm sorry for my poor english. I speak Czech.
The following user(s) said Thank You: osalval

Please Log in or Create an account to join the conversation.

8 years 8 months ago - 8 years 8 months ago #2069 by bit
Replied by bit on topic How to check sensor is live ?
hmm....i'm having your same issues, I had not noticed before.
4:48 is shown in all automations, examples too.
i think these are little bugs in easyiot, maybe we should report these problems to developer.

I'm sorry for my poor english.
The following user(s) said Thank You: osalval

Please Log in or Create an account to join the conversation.

8 years 8 months ago #2080 by EasyIoT

DaTT wrote: Is there any way to determine if the sensor alive? I have NRF24L01 Arduino door / window sensor connected via NRF24L01 to the raspberry pi server. Alarms (open / closed) go right. But when I unplug the power Arduino sensor, the server does not know it. So the server indicates the last state of sensor and thinks that sensor lives. Can I keep using automation to check whether the sensor is live and connected, if so, how? Thank you.


In MySensor driver I send status at least once in 24h. I wrote script to check if sensor is alive and send email if sensor is dead.
/*
  This code is running one time when program is enabled
*/
public void Setup()
{
  //System.Threading.Thread.Sleep(100);
  //Thread.Sleep(100);
}

/*
  This code is running periodicaly when program is enabled. 
  Cron job detirmine running period.
*/
public void Run()
{
  EmailHelper.SetupSmtp("xxxxx@gmail.com", "password", "smtp.gmail.com", 587, true);
  
  String outTxt = "";
  
  foreach (Module m in Modules.Instance.ModuleList)
  {
    // we do not check those modules
    if (
      	m.Domain == "RPiGPIO" ||
      	m.Domain == "Virtual" || 
      	m.Domain == "Esp8266" && m.Address == "N1S10" ||
        m.Domain == "Esp8266" && m.Address == "N1S11" ||
        m.Domain == "Esp8266" && m.Address == "N1S12" ||
        m.Domain == "Esp8266" && m.Address == "N1S13" ||
        m.Domain == "Esp8266" && m.Address == "N1S14" ||
        m.Domain == "Esp8266" && m.Address == "N1S15" ||
        m.Domain == "Esp8266" && m.Address == "N1S16" ||
        m.Domain == "Esp8266" && m.Address == "N1S6" ||
        m.Domain == "Esp8266" && m.Address == "N1S7" ||
        m.Domain == "Esp8266" && m.Address == "N1S8" ||
        m.Domain == "Esp8266" && m.Address == "N1S9" ||
        m.Domain == "Virtual" && m.Address == "N1S0"              
       )
      continue;
    
    
    bool connectionOk = false;

    foreach (ModuleParameter p in m.Properties)
    {
      // if not settings and Status.Connection
      if (p.Name.IndexOf("Settings.") == -1 && m.Domain != "Esp8266")
      {
        if ((DateTime.UtcNow - p.UpdateTime).TotalHours <= 27)
        {
          connectionOk = true;
          break;
        }
      }
      else if (p.Name == "Status.Connection" && p.Value == "1")
      {
          connectionOk = true;
          break;
      }
    }
    
    if (!connectionOk)
      outTxt += "Module not connected: "+ m.Domain + " "+ m.Address + ":"+m.Description + "\n\r";
      
  }
  
  if (outTxt != "")
    EmailHelper.SendEmail("xxx@gmail.com", "xxxx@gmail.com", "[EasyIoT server] Module connection status alert", outTxt);
}
The following user(s) said Thank You: osalval

Please Log in or Create an account to join the conversation.

8 years 8 months ago - 8 years 8 months ago #2090 by osalval
OK.

Please Log in or Create an account to join the conversation.

8 years 8 months ago #2091 by osalval
I think it would be more simple to check status connection at Node level instead module level. Normally problems are related to a power down of Arduino Node and if the Node have 4 sensors, 2 relays....

In addition of sending a email or SMS, at first, it is more interesting to note this lost of communication, in WEB UI, by for example shadow grey cover all lines of Node.
The following user(s) said Thank You: cdj

Please Log in or Create an account to join the conversation.

8 years 6 months ago #2295 by skywatch
That's a good idea osalval!

Please Log in or Create an account to join the conversation.

Time to create page: 0.274 seconds

Forum latest

  • No posts to display.