X10 Community Forum

📱🖥️PiX10Hub ( Always Evolving Open Source) => 💬General Discussion => 📝User created HG Scripts (programs/macros/widgets) => Topic started by: mike on January 30, 2020, 09:56:41 AM

Title: 142 E-mail Account program Upgrade
Post by: mike on January 30, 2020, 09:56:41 AM
Maybe someone can add some diagnostics to the 142 E-mail Account program?

It is presently:
// detect when an option of this program is changed and store the new value to system settings
When.ModuleParameterChanged((module, parameter)=>{
  if (module.Instance.Equals(Program.Module) && parameter.Name.StartsWith("ConfigureOptions.")) {
   var settingName = parameter.Name.Substring(17); // skip "ConfigureOptions." part
    Settings.Parameter("Messaging."+settingName).Value = parameter.Value;
  }
  return true;
});
Program.GoBackground();


If this would have a quick email send routine in it if something changed and maybe a list of what the parameters are now, it wold go a long way!
Title: Re: 142 E-mail Account program Upgrade
Post by: brobin on January 30, 2020, 09:59:10 AM

The magic words “at least for now”. That’s exactly what users have experienced. Works today, doesn’t work tomorrow. Not ideal for a reliable notification system.
Well 3 years and running is pretty reliable in this day and age and I'm sure they'd tell users to convert to a paid account before dropping their free plan.  There are plenty of paid services that disappear with little to no notice - there are no guarantees at any price.
Title: Re: 142 E-mail Account program Upgrade
Post by: mike on January 30, 2020, 10:03:30 AM
I added test send to it for when a value changes;  it just sent for first time with this added inwho knows how long?

// detect when an option of this program is changed and store the new value to system settings
When.ModuleParameterChanged((module, parameter)=>{
  if (module.Instance.Equals(Program.Module) && parameter.Name.StartsWith("ConfigureOptions.")) {
   var settingName = parameter.Name.Substring(17); // skip "ConfigureOptions." part
    Settings.Parameter("Messaging."+settingName).Value = parameter.Value;

 var subject = "test email";
var messagetext = "HG Test Email";
var recipients = "mike@xxxere.com";
Net.SendMessage( recipients, subject, messagetext );

   if (Net.SendMessage(recipients, subject, messagetext) == true)
      Program.Notify("E-Mail Notification", "SUCCESS! Notification sent.");
   else Program.Notify("E-Mail Notification", "ERROR: Notification **NOT** sent.");
 
  }
  return true;
});
Program.GoBackground();
Title: Re: 142 E-mail Account program Upgrade
Post by: mike on January 30, 2020, 10:06:03 AM
It's as if the issue I have with HG not accepting changes to the email account program may be it ends too quickly?  before it has chance to really rewrite the parameters?  adding the test send email slowed it down and it did not end the program until the send was finished in 20 seconds...  now everything magically works again...
Title: Re: 142 E-mail Account program Upgrade
Post by: Tuicemen on January 30, 2020, 10:10:54 AM
Nice!  #:)
Title: Re: 142 E-mail Account program Upgrade
Post by: bkenobi on January 30, 2020, 10:52:36 AM
I find that hard to believe, but if that's true then you could add a pause to the program to let it finish.  If that fixes it, just leave the delay in there.  Unless you need the notification of course...
Title: Re: 142 E-mail Account program Upgrade
Post by: Tuicemen on January 30, 2020, 10:55:59 AM
I find that hard to believe, but if that's true then you could add a pause to the program to let it finish.  If that fixes it, just leave the delay in there.  Unless you need the notification of course...
Agreeded, a simple sleep 20 may do the trick. However the notification is a nice touch.
Title: Re: 142 E-mail Account program Upgrade
Post by: petera on January 30, 2020, 11:01:41 AM
Is this being tested on a Raspberry Pi Zero fully loaded. A side by side comparison between the Pi Zero and a Raspberry Pi 3b+ and you'll not be experiencing difficulties like this.

You have all the diagnostics you need if you run HG in debug mode. Stop your HG service. Locate the folder where the HomeGenie.exe file resides and switch to it. From there type

sudo mono HomeGenie.exe


and your HG server will start manually. You can watch everything happening in HG from that screen while you access HG from your web browser. To close the server just press the Ctrl-C keys. That's all the diagnostics you will ever need in JG