Triggering a custom SMTP notification - Falling at the first hurdle

Update: I’m not using gmail, I’m using my own SMTP server so this isn’t a login\authentication issue. My issue is that I’m not able to call the notification service, it returns the error message “unable to find service”.

I’m an extremely new user setting up their first HAOS server. I don’t really understand programming, I’ve read the documentation but it’s just confusing me even more as I can’t get my head around some of the basic concepts like syntax, and where to put the code.

I have several CCTV camera and want to take a snapshot from all of the camera and send it to an email address using SMTP when a event is triggered.

For example, when a motion sensor on the rear entrance is triggered it takes a snapshot of whoever is at the door from one camera, while another camera takes a wide angle picture to see if anyone is hiding around the corner, and another camera takes a picture of the fence line to see if there are any vehicles waiting out there. Then it sends all three to an email address so that the pictures are stored somewhere that doesn’t require you to have the camera app on your phone to access (For example, from a laptop).

I have managed to take the snapshots and store them locally, but I can’t even seem to trigger the SMTP notification, let alone send it out.

Could someone please explain in the simplest way possible why I’m receiving the error below. I can deal with the actual message later on, right now I just want to know why I can’t even call the notification.

I don’t understand what the documentation is telling me, so please dumb it down as much as possible rather than linking to it, as I’ve been trying to get my head around it for a week and I’m still stuck.

This is my configuration. Yaml, the notification that I’m trying to create is called VMAIL. I don’t know if any of the contents are correct as I can’t even trigger it yet.

I’ve tried restarting my config files, powering down the server and restarting it that way, and changing the case on the names in case that was the problem.

This is the trigger automation. The automation triggers OK (Please ignore the disabled action, it functions OK when enabled). I’m trying to call notification.VMAIL from my configuration file.

When I trigger the automation, if says that it cannot find the notification

Please ignore the change in case from VMAIL to vmail. I tried both in case it was case sensitive, but only took the screenshot when it was on lower case.

trigger4

Could someone please explain to me why it can’t find the notification that I set up?

I understand that this code won’t send my actual snapshots as it is currently written, as I’ve not yet added any content to the SMTP message. That comes later once I’ve managed to even trigger it.

Have you taken the specific Google settings into account?

Hi

I’m not using a Google account, it’s my own SMTP server.

The actual account settings are a problem for later on.

Right now I’m just trying to call the routine, it’s not even gotten as far as the account settings.

I presume that you have restarted HA after setting up the SMTP integration.

Is the service available in Developer Tools ——> Services?
If not, check the link above, maybe you need to enable the security feature, too.

Yes, I’ve tried reloading the confic files using the Developer console and I powered down the server and rebooted it that way, I did this a couple of times.

From my original queston

maybe you need to enable the security feature,

I don’t want to cause any offense as you’re trying to help me off of your own back, but as I said in my answer to that question, I’m not using gmail, it’s my own server. According to the logs there have been no failed or attempted logins, so it’s a case of the message not going out rather than it failing to authenticate.

The problem that I’m having id that I can’t even call the function that that would do the authentication. The function that contains the instructions to log in to the server isn’t even being called. I’ve not even got far enough for it to fail.

I’ve understood you. I just wondered if there’s a similar authentification procedure regarding your server.
I had exactly the same problem you described when setting up SMTP for my Gmail account.

I’m sorry, I’m not sure that I’m explaining this very well.

My problem isn’t that the authentication is failing, it’s that I’m failing to even get that far.

I can’t trigger the code that does the authentication. It says that it cannot find Notify.vmail, not that there is an error with notify.vmail. It’s failing to run it, rather than failing while running it.

The service won’t work if the authentication fails. At least this was the reason in my case.

My problem isn’t that the service is failing, it’s that I can’t call the service. I I put some dummy code in the service it still can’t find it.

ERROR (MainThread) [homeassistant.components.automation.smtpmessage] SMTPMessage: Error executing script. Service not found for call_service at pos 2: Unable to find service notify.vmail

We are running in circles. If the service is unknown, there’s a chance that it’s not set up properly. Anything in the HA logs that would be helpful?

P.S.: The integration settings accept a debug option:

debug boolean (optional, default: false)
Enables Debug, e.g., true or false.

debug boolean (optional, default: false)
Enables Debug, e.g., true or false .

Sorry, but could you please dumb it down a little, I haven’t gotten that far in the documentation yet. I don’t know where this code should go or how to run it.

We are running in circles. If the service is unknown, there’s a chance that it’s not set up properly. Anything in the HA logs that would be helpful?

This is how I set it up

trigger4

The error log says:

ERROR (MainThread) [homeassistant.components.automation.smtpmessage] SMTPMessage: Error executing script. Service not found for call_service at pos 2: Unable to find service notify.vmail

I’ve not yet included the content of the message that I want to send as I can’t even get that far.


# Example configuration.yaml entry
notify:
  - name: "NOTIFIER_NAME"
    platform: smtp
    sender: "YOUR_SENDER"
    recipient: "YOUR_RECIPIENT"
    debug: true

Then go to Developer Tools / Services and try to call the notify service with the required fields.

I’m afraid that you’re going to need to dumb it down a little more

notify:
  - name: "vmail"
    platform: smtp
    sender: "..."
    recipient: "..."
    debug: true

If I write the above, with two valid email addresses on my sever in the … I get the error message

No service defined, please define a service: key

This looks like the same problem as I was having originally, HA can’t find notify.vmail. Which means that I’ve probably either tried to configure it in the wrong place or that I’ve gotten the syntax wrong and the system isn’t recognizing it as existing in the form that I want.

I still suspect your server settings.

I just noticed that the ssl option of the integration is enabled by default. So you could give it a try:


notify:
  - name: "vmail"
    platform: smtp
    sender: "..."
    recipient: "..."
    verify_ssl: false

I hate to sound like a broken record, but HA is telling me that it can’t find notify.vmail, not that there is a problem with notify.vmail.

I don’t think that it’s even gotten far enough to even reach that line of code. The error messages keep saying “service not found”.

I’ve changed it and restarted the server, but I get the same error message.

I don’t think that HA is even triggering notify.vmail, The log files keep saying that the can’t find it.

I’ve set up notify.vmail in the configuration.yaml. Do I need to set any permissions in order for it to be visible?