- Posts: 4
- Thank you received: 2
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 youbit wrote: hello, i'm back with my code.
it seems to work properly, but i please you to test it..
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
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.
/*
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);
}
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.