To start out you need the Email addon for the CCU, I have version 1.4 installed. To install, see the documentation on the Homematic-inside website:
http://www.homematic-inside.de/software/email
To generate a custom mail body for the email message there needs to be communication between the script code in the programm and the email addon. This is done through a system variable.
First we define the variable through the menu's:
Below choose Neu to define a new variable.
Fill in the details as follows.
This wil define a new string variable with the name EmailText.
Now we need to setup the email configuration. Open the setup through the following menu's:
Then choose the option
This should show the E-Mail addon you installed. In the line showing this add-on choose the optoin
Now go to the icon defined as
In this tab I used the following code
array set values [rega_script { var v3 = dom.GetObject("EmailText").Value(); } ]
set emailtext [encoding convertfrom utf-8 $values(v3)]
Which should look like this
Once defined, press the button Ubernehmen at the bottom of the screen.
Next we have to define an Email. Go to the tab
Choose an empty spot in the pull-down menu to define an email template. For me it is spot 4 that is being used to define the email for low battery warnings.
Below is an example of the configuration. Make sure you active the TCL for this email so the variable $emailtext will be expanded.
Press the button Ubernehmen to save the email.
Now that the email configuration is in place we need to define a program that will periodically check for devices that have a low battery and send an email when it finds one or more.
Go to the following menu:
And choose the button Neu to create a new program.
At the top of the screen you can click the text Neues Programm and change it to the name you would like.
I want the program to run daily at 12:00 noon. So for the first option press the plus symbol below Bedingung: Wenn... and choose the option Zeitsteurung from the pulldown. Next click the option Zeitmodul next to the pulldown. I filled out the popup window as follows:
And press OK to store.
Next press the plus symbol in the next part named Aktivitat: Dann... From the pulldown that appears choose the option Skript. Now click the option Skript erstellen to open a popup window. Copy & Paste the following script in the upper part of the window:
if ( (chanid.State() == true) && (chanid.Value() == true) ) { if ( count == 0 ) { message = dev.Name(); } else { message = message # "n" # dev.Name(); } count = count + 1; } } if ( message != "") { dom.GetObject("EmailText").State(message); string stdout; string stderr; system.Exec("/etc/config/addons/email/email 04", &stdout, &stderr); }
Make sure to change the 04 in the previous to last line to the number of the email template you choose before. It should look something like this:
And press OK to store the configuration.
And press OK to store the new program.
Now you're done! Ofcourse the program will only send out an email when one of the devices has reported a low battery status.