In my Home Assistant setup, I created an SMTP notification that would email my phone’s SMS gateway when certain conditions were met. Except it didn’t work.
When monitoring the log file, I found the following when the condition was supposed to trigger:
WARNING (MainThread) [homeassistant.core] Unable to find service notify/txt_smeg
When I did additional digging in the log file, I found this:
ERROR (Thread-6) [homeassistant.components.notify.smtp] Login not possible. Please check your setting and/or your credentials
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/notify/smtp.py", line 120, in connection_is_valid
server = self.connect()
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/notify/smtp.py", line 113, in connect
mail.login(self.username, self.password)
File "/usr/lib/python3.5/smtplib.py", line 729, in login
raise last_exception
File "/usr/lib/python3.5/smtplib.py", line 720, in login
initial_response_ok=initial_response_ok)
File "/usr/lib/python3.5/smtplib.py", line 641, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Error: authentication failed:')
ERROR (MainThread) [homeassistant.components.notify] Failed to initialize notification service smtp
But everything in my configuration looked OK. I checked and the password works. Restarting the Home Assistant service resulted in the same error.
After seeing this discussion where a machine restart magically fixes this problem, I restarted my entire device. After it booted back up, the notification worked correctly. My only guess is that smtplib must keep a cache somewhere, or holds something in memory across application re-loads.