HomeGenie Forum
Automation Program Plugins and Wizard Scripting => Help => Topic started by: genieman on October 15, 2014, 01:26:08 PM
-
Hello again. I would like to know how to configure send email when my sensor DHT-11 notice temperature over 38 degrees ? Any instruction ?
-
I am a Home Automation "enthusiast"...but not a programmer.. :-(
I have the same need as the one expressed in the previous post...
It would be great if somebody could bring together a brief set of instructions on what has to be done in order to have HG send an email when some condition happens...
Thanks in advance !
-
Hi,
Here's an example in C#, You might need to change some things here, but the basics should work, I hope... :)
Put this in your trigger code:
// Remember to Change 'SensorName' to the correct name of your sensor
var mySensor = Modules.WithName("SensorName").Get();
// Debug code
//Program.Notify("Debug", mySensor.Parameter("Sensor.Generic").DecimalValue.ToString())
// Returns 'True' if the value of the sensor is 38 or higher
return (mySensor.WasFound && mySensor.Parameter("Sensor.Generic").DecimalValue >= 38);
And this in the 'Code to run'
var mySensorValue = Modules.WithName("SensorName").Get().Parameter("Sensor.Generic").DecimalValue.ToString();
Net.SendMessage("[email protected]", "Sensor", "Sensor value is " + mySensorValue );
Edit: Don't forget to set the trigger to "When condition evaluation switches to 'true'" or you'll get a lot of mail as bkenobi mentions below.
HTH, Marcel.
-
Two comments.
1) This code will run constantly when the temperature on the sensor is above 38. That will result in sending countless emails. Be careful if you use this code without adding a delay in the trigger section like "pause(60)" for 60 second intervals.
2) In order for email to send, you must set up the email setup code. That requires you to enter an SMTP server location and necessary login details. I'd recommend sending a test email prior to setting up and running the previous code so you know that email itself works.
-
This code will run constantly when the temperature on the sensor is above 38
That depends on the 'Trigger'. If you leave it at 'When condition evaluation returns 'true'" it will run continuously, but if you set it to "When condition evaluation switches to 'true'" it will run once.
-
That depends on the 'Trigger'. If you leave it at 'When condition evaluation returns 'true'" it will run continuously, but if you set it to "When condition evaluation switches to 'true'" it will run once.
Good point.
-
Hi,
Where would I find the exact name to replace for "SensorName"?
I would like to use my DS18B20 that is called "Main Bedroom" in the Dashboard.
Thanks,
Eugene
-
'SensorName' needs to replaced with the name you gave to the module, so in your case, replace it with 'Main Bedroom'.
(Name is case-sensitive I think)