Send e-mail to Domoticz to start an event

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
dutchnld
Posts: 20
Joined: Friday 23 October 2015 22:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5974
Location: Amsterdam, Netherlands
Contact:

Send e-mail to Domoticz to start an event

Post 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!
-----
Raspberry Pi Model 2 B w/ Domoticz 3.5974 + Monit + Pi-Hole + RaZberry Z-wave module + RFXcom 433 USB
rgroothuis
Posts: 347
Joined: Friday 03 April 2015 17:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Send e-mail to Domoticz to start an event

Post 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.
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Send e-mail to Domoticz to start an event

Post 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?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Send e-mail to Domoticz to start an event

Post by Egregius »

What if someone finds out the emailaddress and subject etc?
dutchnld
Posts: 20
Joined: Friday 23 October 2015 22:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5974
Location: Amsterdam, Netherlands
Contact:

Re: Send e-mail to Domoticz to start an event

Post 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
-----
Raspberry Pi Model 2 B w/ Domoticz 3.5974 + Monit + Pi-Hole + RaZberry Z-wave module + RFXcom 433 USB
User avatar
gizmocuz
Posts: 2541
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Send e-mail to Domoticz to start an event

Post by gizmocuz »

or you can just login and activate the switch/scene, takes the same time as writing an email :mrgreen:
Quality outlives Quantity!
dutchnld
Posts: 20
Joined: Friday 23 October 2015 22:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5974
Location: Amsterdam, Netherlands
Contact:

Re: Send e-mail to Domoticz to start an event

Post 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)
-----
Raspberry Pi Model 2 B w/ Domoticz 3.5974 + Monit + Pi-Hole + RaZberry Z-wave module + RFXcom 433 USB
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Send e-mail to Domoticz to start an event

Post by Egregius »

To get a notification of a mail? Isn't that one of the reason they invinted smartphones?
dutchnld
Posts: 20
Joined: Friday 23 October 2015 22:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5974
Location: Amsterdam, Netherlands
Contact:

Re: Send e-mail to Domoticz to start an event

Post 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
-----
Raspberry Pi Model 2 B w/ Domoticz 3.5974 + Monit + Pi-Hole + RaZberry Z-wave module + RFXcom 433 USB
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Send e-mail to Domoticz to start an event

Post 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.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Send e-mail to Domoticz to start an event

Post 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.
dutchnld
Posts: 20
Joined: Friday 23 October 2015 22:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5974
Location: Amsterdam, Netherlands
Contact:

Re: Send e-mail to Domoticz to start an event

Post 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.
-----
Raspberry Pi Model 2 B w/ Domoticz 3.5974 + Monit + Pi-Hole + RaZberry Z-wave module + RFXcom 433 USB
alfred_j_kwak
Posts: 110
Joined: Friday 20 September 2013 18:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Finland
Contact:

Re: Send e-mail to Domoticz to start an event

Post by alfred_j_kwak »

Why dont use Android tablet or phone with Tasker to send commands to Domoticz?
tjabas
Posts: 562
Joined: Sunday 11 December 2016 13:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Send e-mail to Domoticz to start an event

Post 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?
tjabas
Posts: 562
Joined: Sunday 11 December 2016 13:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Send e-mail to Domoticz to start an event

Post 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?
lost
Posts: 660
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Send e-mail to Domoticz to start an event

Post 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
tjabas
Posts: 562
Joined: Sunday 11 December 2016 13:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Send e-mail to Domoticz to start an event

Post 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?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest