Tiny Email server incorporated into Home Assistant

This is for those sensors that only report their status through email. Why would I want to have such sensor in my home that sends a message to an email server somewhere out there and then have my automation system connect to that email server to read the status of the sensor? I understand that such long travel outside of my home is required if the sensor has a proprietary protocol which only connects with the manufacturer cloud and then we are forced to connect to that cloud, but email??? I think it wouldn’t be difficult to develop a tiny email server with limited capacity to store emails (maybe last 10 emails just for debugging purpose) or even an option to not store any email, just process it (extract the status of the sensor) and discard it. Probably some already have implemented that (using some locally hosted email server) in their raspberry (or whatever server they have Home Assistant running) but those who are running the core version and don’t have additional hardware available are left out having to use an external email server. I think such addition will help keep Home Assistant all local.

A lot of ISPs block outgoing port 25 (SMTP) as a spam preventative measure. This means you would only receive mail while on your local network.

3 Likes

I wasn’t thinking on sensors located outside of home (internet), so yes, for those local sensors would work. Since the idea is to keep Home Assistant local then for sensors located outside of home (Internet) then it would make sense to use an outside (external) email server.

Oh right. I just re-read your post. I was thinking notifications to you.

Just out of interest what sort of sensors do you have that report via email?

There is no such thing as a small email server any more. Once you get a sufficient level of security into it, they become quite large.

Reolink Lumus camera. Has no web interface, it reports motion only to the reolink app or through email. I believe there are other devices out there with similar restrictions.

Until you get your request it does appear that some Reolink cameras have an api that you could use to get motion alerts with a Restful sensor. Not well documented but I did find one example on the OpenHab forum:

Try replacing the IP address, username and password in this and paste it in a web browser address bar:

http://192.168.x.x/api.cgi?cmd=GetMdState&user=admin&password=123456

It should return something like:

[
   {
      "cmd" : "GetMdState",
      "code" : 0,
      "value" : {
         "state" : 0
      }
   }
]

state Should change to 1 on motion. You would probably have to reduce the polling interval to something quite short (1 or 2 seconds) to capture events though. So not really a great solution.

Yes, as you have rightfully said, “some” Reolink cameras can do that. Sadfully, the Lumus model is in the exception list. Even for the models that this method works, you would need to flood your network with frequent polls or risk loose a short duration motion event. Thanks for the suggestion.

Maybe Nabu Casa can also make this part of the subscription. 50’ish email messages a month included. Or as an optional add-on.

That would still be outside the local network, causing delays and increasing the risk of outages.

If you run Home Assistant Supervised on Debian you could install an SMTP server on the same machine.

How about an SMTP server as an Add-on? I’ve been looking for it but couldn’t find anything similar.

Sorry, I think it would have to be an IMAP email server as this is how the existing integraron to get sensor status from an email can connect to an email server.

We have the IMAP integration that can read any email inbox via IMAP (ie gmail) https://www.home-assistant.io/integrations/imap_email_content/

Yes, but as I said in my original post, that means going outside of my local network to read the status of a sensor located in my local network. The goal of this post is to keep Home Assistant all local.

A quick google on ‘docker email server’ shows a lot of candidates.

It would really make more sense, in my opinion, to put such a thing into an add-on, spin up some other docker container or install a postfix locally or something.

2 Likes

Would be nice to have a Docker Install AddOn to create a nice small mailserver

An email system is more than an smtp server. You need to deliver the mail somewhere. And serve it up via (usually) pop or imap. This is beyond home assistant isn’t it?

Fill your boots. There are literally dozens of email server docker images out there.

Ages ago I helped make a similar plugin for EventGhost. I think everyone replying here is overthinking this and not really considering what is being asked by the OP.

The goal was very similar to what the OP outlines, we had cameras that only alerted via SMTP and didn’t want to send that email out of the network. The plugin acts as a simple SMTP host, will accept mail, and then turns the email into an event in EventGhost. It doesn’t deliver email or provide mailboxes or anything like that, just email comes in and events come out. The entire plugin is less than 100 lines of code.

I suspect something similar might work here. You don’t need a full MTA and python has a standard SMTP interface.

Accept an email, turn it into an actionable event in Home Assistant, and if you still want to get an actual email, use one of the existing notify. components to send it forward out of your network.

3 Likes

Thanks luma, that’s what I would like to see for Home Assistant.

Any volunteers out there? (I don’t have the programming skills to build this).