Can I ask for help here or should I ask in another spot?
sending email when sensor triggers fails - says it is old HG C+ code:
//Parameters
Program.Setup(()=>
{
Program.AddInputField("Sensor", "garage", "Sensors to alert on (comma separated)"); //e.g.: garage,window1
Program.AddInputField("Email.Recipients", "a@a.com", "Email recipients"); //e.g.: a@a.com,b@a.com
});
//Code that executes on sensor changes:
When.ModuleParameterChanged((module, parameter)=> {
if( parameter.Name == "Sensor.Generic")
{
if(Program.InputField("Sensor").Value.Contains(module.Instance.Name))
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
DateTime time = DateTime.Now;
string format = "HH:mm MMM ddd d";
var openClosed = parameter.DecimalValue == 0 ? "closed":"open";
var messagetext = module.Instance.Name + " " + openClosed + time.ToString(format);
//Program.Notify("debug", "sending email " + messagetext); //uncomment for debugging
var subject = "HomeGenie: Open/Closed" + messagetext;
var recipients = Program.InputField("Email.Recipients").Value;
if (recipients != "")
{
Program.RunAsyncTask(()=>{
Net.SendMessage(recipients, subject, messagetext);
});
}
}
}
return true;
});
Error says:
CR,4,13: `HomeGenie.Automation.Scripting.ProgramHelper.AddInputField(string, string, string)' is obsolete: `use 'Program.AddOption(<field>, <defaultValue>, <description>, <type>)' instead'
200 /hg/html/pages/control/widgets/homegenie/generic/doorwindow.html [OPEN]
CR,5,13: `HomeGenie.Automation.Scripting.ProgramHelper.AddInputField(string, string, string)' is obsolete: `use 'Program.AddOption(<field>, <defaultValue>, <description>, <type>)' instead'
CR,12,13: `HomeGenie.Automation.Scripting.ProgramHelper.InputField(string)' is obsolete: `use 'Program.Option' instead'
CR,22,32: `HomeGenie.Automation.Scripting.ProgramHelper.InputField(string)' is obsolete: `use 'Program.Option' instead'
I've tried replacing but it is still missing something... If someone can update this for me I would post it back as exmple for HG?