HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: duch on February 07, 2014, 05:23:41 PM

Title: Aeon Door/Window sensor - Trigger code [Solved]
Post 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

Code: [Select]
// 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
Title: Re: Aeon Door/Window sensor - Trigger code
Post by: Gene on February 08, 2014, 01:38:17 AM
Code: [Select]

// 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:

Code: [Select]

// send email
Net.SendMessage("[email protected];[email protected]",   // recipients
                "Warning",                          // subject
                "Security Alarm Triggered");        // message text


Title: Re: Aeon Door/Window sensor - Trigger code
Post by: duch on February 08, 2014, 12:38:48 PM
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 ...

Quote
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 :

Code: [Select]
// trigger code
return Modules.InGroup("Salle de technologie")
             .WithName("Porte")
             .Parameter("Sensor.DoorWindow").DecimalValue == 255;

Do I miss something ?

Merci
Title: Re: Aeon Door/Window sensor - Trigger code
Post by: Gene on February 08, 2014, 02:01:59 PM
Sorry!! it was me missing something  ;D

Code: [Select]

// 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

Code: [Select]

var doorsensor = Modules.InGroup("Salle de technologie").WithName("Porte").Get();
return doorsensor.Parameter("Sensor.DoorWindow").DecimalValue == 255;


Title: Re: Aeon Door/Window sensor - Trigger code
Post by: duch on February 08, 2014, 03:59:33 PM
Wonderfull ...  :)

It's working fine now !

Thank you for your fantastic job....
Title: Re: Aeon Door/Window sensor - Trigger code [Solved]
Post by: duch on March 05, 2014, 11:34:05 AM
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 ...

Quote
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