HomeGenie Forum
Automation Program Plugins and Wizard Scripting => Help => Topic started by: duch on February 07, 2014, 05:23:41 PM
-
Hello,
First of all, I am not familiar at all with C# and have no time to spend to understand how it works.
Here is my problem :
I want to receive an email when my Aeon Door/window sensor equals 255 (when the door is opened)
I have found an exemple of the Code to run in the Sourceforge Homegenie forum
// send email
string smtpserver = "smtp.myserver.com";
Net.MailService(smtpserver).WithCredentials("myuser", "mypass")
.SendMessage("[email protected]", //from
"[email protected];[email protected]", // recipients
"Warning", // subject
"Security Alarm Triggered"); // message text
Could you help me for writting the trigger code please ?
Thank you for your help
-
// trigger code
return Modules.InGroup("Living Room")
.WithName("Door Sensor").Get() // get reference to the selected module
.Parameter("Sensor.DoorWindow").DecimalValue == 255;
just change the group and the module name.
Though I would encourage you in using the built-in Security Alarm System feature:
http://www.homegenie.it/docs/alarmsystem.php
The first screenshot is from an older HG release and the e-mail configuration has been moved to the Configure->Automation->Messaging and Social section.
If you still want to use a custom C# app and you configured e-mail from Messaging and Social, you can simplify the email send command to:
// send email
Net.SendMessage("[email protected];[email protected]", // recipients
"Warning", // subject
"Security Alarm Triggered"); // message text
-
Thank U for your help and I will try the built-in Security Alarm System feature as soon as possible.
I've tried the trigger code you wrote. But unfortunately, I have got that message (in french) when I've tried to compile ...
Errors:
1. Line 4, Column 15 'HomeGenie.Automation.Scripting.ModulesManager' ne contient pas une definition pour 'Parameter' et aucune methode d'extension 'Parameter' acceptant un premier argument de type 'HomeGenie.Automation.Scripting.ModulesManager' n'a ete trouvee (une directive using ou une reference d'assembly est-elle manquante ?) (CS1061) (Condition)
Program disabled, fix errors first.
Here is the code I change with my parameters :
// trigger code
return Modules.InGroup("Salle de technologie")
.WithName("Porte")
.Parameter("Sensor.DoorWindow").DecimalValue == 255;
Do I miss something ?
Merci
-
Sorry!! it was me missing something ;D
// trigger code
return Modules.InGroup("Salle de technologie")
.WithName("Porte").Get() // <--- get reference to the selected module
.Parameter("Sensor.DoorWindow").DecimalValue == 255;
or to make it more readable
var doorsensor = Modules.InGroup("Salle de technologie").WithName("Porte").Get();
return doorsensor.Parameter("Sensor.DoorWindow").DecimalValue == 255;
-
Wonderfull ... :)
It's working fine now !
Thank you for your fantastic job....
-
Hello,
I've updated HG with r345
Since, I have a problem for sendig an email.
In the "Code to run" window, i have now to fix some errors ...
Errors:
1. La reference d'objet n'est pas definie e une instance d'un objet.
2. e HomeGenie.Automation.Scripting.ScriptingInstance.EvaluateConditionScript()
3. e HomeGenie.Automation.Scripting.ScriptingInstance.EvaluateCondition()
Program disabled, fix errors first.
Can you Help me ?
Thank you
Solved : :) I have done a new installation, and it works now