- Posts: 44
- Karma: 2
- Thank you received: 8
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
esawyja wrote: I would also like this feature, if there is no data from a sensor for a configurable time period, either print it to console or email
/*
This code is running one time when program is enabled
*/
public void Setup()
{
}
/*
This code is running periodicaly when program is enabled.
Cron job detirmine running period.
*/
public void Run()
{
EmailHelper.SetupSmtp("xxxxx@gmail.com", "xxxxx", "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("xxxx@gmail.com", "xxxxxx@gmail.com", "[EasyIoT server] Module connection status alert", outTxt);
}
Please Log in or Create an account to join the conversation.