Page 1 of 1
Send e-mail to Domoticz to start an event
Posted: Friday 13 November 2015 22:47
by dutchnld
Hi,
I'm looking for a way to start an event (i.e. blockly) or just turn on a (dummy) switch by sending an e-mail.
So I send an e-mail to a predefined e-mail address that will be delivered to Domoticz.
Then based on the subject or contents of the e-mail the activation takes place.
Been looking on the forum, but couldn't find whether or not this has been suggested already.
Thanks!
Re: Send e-mail to Domoticz to start an event
Posted: Friday 13 November 2015 23:22
by rgroothuis
Have you looked at Telegram? Have not tried it myself (yet) but with Telegram it is possible to send instructions to Domoticz. From what I've seen/read you almost can control everything in Domoticz through this interface.
Re: Send e-mail to Domoticz to start an event
Posted: Saturday 14 November 2015 8:53
by remb0
I don't understand the benefits. Is it not easier to schedule, use an app, make better events with blocky/lua etc etc?
Re: Send e-mail to Domoticz to start an event
Posted: Saturday 14 November 2015 9:18
by Egregius
What if someone finds out the emailaddress and subject etc?
Re: Send e-mail to Domoticz to start an event
Posted: Saturday 14 November 2015 10:28
by dutchnld
Hi all,
thanks for the replies.
I might look into telegram, but then I still prefer e-mail.
This give a huge flexibility! You can have (autoforwarded) important e-mails in domoticz to notify you (on Kodi, turn on a lamp, doorbell, or what ever).
Or you can just send an e-mail from work.
Then you also don't need to have domoticz accessible from the internet and use an app or the website, which might be blocked.
If you make the event not critical it shouldn't be a big problem if someone finds out the address / subject combination.
The chance of that happening is also very small.
greets
Re: Send e-mail to Domoticz to start an event
Posted: Saturday 14 November 2015 13:21
by gizmocuz
or you can just login and activate the switch/scene, takes the same time as writing an email

Re: Send e-mail to Domoticz to start an event
Posted: Saturday 14 November 2015 13:46
by dutchnld
I mainly would like to use it for e-mail forwarding from specific persons or systems (for example stock notifications, external server monitoring tools, etc)
Re: Send e-mail to Domoticz to start an event
Posted: Saturday 14 November 2015 16:27
by Egregius
To get a notification of a mail? Isn't that one of the reason they invinted smartphones?
Re: Send e-mail to Domoticz to start an event
Posted: Saturday 14 November 2015 16:52
by dutchnld
Egregius,
When I'm home I don't constantly walk around with my phone to check e-mails... it's mostly lying around in some room.
But when I'm home and receive an important e-mail I could auto-forward it to domoticz.
Then it could send a notification on Kodi, while watching a movie, ring one of my doorbells (i have 2).
The possibilities are huge, because you can connect e-mail to domoticz. E-mail is used lot of things, like motion detection on camera's, online monitoring tools, stock alerts, etc, etc ,etc.
And I don't have to open up ports on my router to have remote access to domoticz. functionalities.
greetz
Re: Send e-mail to Domoticz to start an event
Posted: Saturday 14 November 2015 17:22
by Egregius
There are possibilities...
I just managed to have a PHP script executed upon arrival of an email.
But...
That requires a mailserver where you have access to the aliasses file.
You could install postfix on the Rpi but still then you would need a domainname and MX record.
There are also some command line mail clients, maybe something is possible with those.
My guess is that it would be a huge development to put this in Domoticz and there is maybe no userbase for it.
Re: Send e-mail to Domoticz to start an event
Posted: Saturday 14 November 2015 17:46
by Egregius
Funny how you sometimes come up with ideas...
Receiving a telegram when a mail arrives with the sender and subject in it
In the aliases table of postfix add , |/path/to/script/mail.php
mail.php
Code: Select all
#!/usr/bin/php -q
<?php
// start output buffering
ob_start();
// read from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
// handle email
$lines = explode("\n", $email);
// empty vars
$from = "";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;
for($i=0; $i<count($lines); $i++) {
if($splittingheaders) {
// this is a header
$headers .= $lines[$i]."\n";
// look out for special headers
if(preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
$subject = $matches[1];
}
if(preg_match("/^From: (.*)/", $lines[$i], $matches)) {
$from = $matches[1];
}
} else {
// not a header, but message
$message .= $lines[$i]."\n";
}
if(trim($lines[$i])=="") {
// empty line, header section has ended
$splittingheaders = false;
}
}
// clean the output
ob_end_clean();
$url = 'https://api.telegram.org/bot123456789:Axxxyyyzzz/sendMessage';
$data = array('chat_id' => '123456789', 'text' => $from.":".$subject);
$options = array(
'http' => array(
'method' => 'POST',
'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
The last lines sent it to telegram. You can use the variables $from and $subject to secure it and define actions.
Don't know yet how to post to Domoticz, except to a virtual text switch but don't know if you can trigger stuf on that. Unless you trigger the switch with a JSON call.
Re: Send e-mail to Domoticz to start an event
Posted: Saturday 14 November 2015 18:03
by dutchnld
I already figured out a workaround concept for my own wish!
Haven't tried/implemented it yet but it's basically like this:
1 e-mail arrives to my personal inbox
2 based on a filter it auto-forwards to a special e-mail address
3.i have outlook 2010 running on my server, that receives the e-mail
4. within outlook I create a filter for all e-mail received from my personal e-mail
4.1 the action could be, move to subfolder, but i choose for 'run a program'
5. I'll create an html-file (or .bat file that opens the html, not sure if i can open directly) that has the url to control the value of an dummy-device in domoticz.
I was playing around with updating values, but haven't tried the on/off button yet; i guess thats possible.
http://192.168.0.110:8080/json.htm?type ... svalue=130
6. I use blockly to do what i want to do in domoticz based on the dummy device.
Re: Send e-mail to Domoticz to start an event
Posted: Saturday 14 November 2015 20:02
by alfred_j_kwak
Why dont use Android tablet or phone with Tasker to send commands to Domoticz?
Re: Send e-mail to Domoticz to start an event
Posted: Friday 17 December 2021 23:51
by tjabas
i also wonder if its possible to trigger an switch in domoticz with an email in my hotmail.
i have a ipcamera that sends emails if something trigger it, with this email would like to trigger an switch to turn on or off.
can this be done?
Re: Send e-mail to Domoticz to start an event
Posted: Friday 17 December 2021 23:53
by tjabas
i also wonder if its possible to trigger an switch in domoticz with an email in my hotmail.
i have a ipcamera that sends emails if something trigger it, with this email would like to trigger an switch to turn on or off.
can this be done?
Re: Send e-mail to Domoticz to start an event
Posted: Monday 20 December 2021 10:15
by lost
tjabas wrote: ↑Friday 17 December 2021 23:53
i also wonder if its possible to trigger an switch in domoticz with an email in my hotmail.
i have a ipcamera that sends emails if something trigger it, with this email would like to trigger an switch to turn on or off.
can this be done?
Why using the mail sent by camera to the outside world to (always?) trigger a switch inside Domoticz?
Best option would be a camera able to send a configurable frame directly to Domoticz on internal events like captures/motion, able to trigger a switch (using http/json API), but that's usually not possible.
But most IP cams are able to send snapshots/short video on captures to a FTP server. So, after installing a FTP server on the machine that hosts Domoticz, you may monitor configured FTP server directory for file creation & trigger a (virtual) switch in Domoticz?
This may be done using inotify for instance:
https://unix.stackexchange.com/question ... -new-files
Re: Send e-mail to Domoticz to start an event
Posted: Tuesday 21 December 2021 0:38
by tjabas
i use cheap Tapo cameras, they do not have any ftp upload possibilities, not what i know anyway.
these cameras can send an email alert or push to my android phone if something is registered in the camera,
so the only link i can think of is to get the email from my camera to trigger a switch in domoticz, but is it possible to do it, thats the question?