I have an old security camera DVR that cannot be directly connected to HA. But it can send emails. So I have it setup to send an email when there is motion detected i.e. a car has entered the driveway. I want to turn on the z-wave outside light.
Hi Bill, it’s not easy to be a beginner.
But @VDRainer points out the first thing you must do, and I think it’s well meant.
When you post code examples you must format the code correctly. If you don’t it’s almost impossible to help.
What to do next? Well, first of all you have to confirm that your imap_email_content sensor actually works. Then you should create some automations to turn your outside light on when motion is detected, and of course off again when you don’t want the light on anymore.
I wish you the best of luck Home Assistant is really fun, but can sometimes be a little frustrating when you are a beginner.
I assume you’re receiving an email when the camera detects motion?
Then the next step is to confirm that the imap_email_content sensor exists in Home Assistant and works properly. If the sensor exists you should see it listed under States in the Developer Tool. And you should also see that the state is motion if it reads the email correctly.
If you don’t see the sensor then it would have been very useful to see your code formatted…
I have a couple of imap_email_content sensors myself and one looks like (sorry the values are in my native language):
- platform: imap_email_content
server: imap.gmail.com
port: 993
username: !secret gmail_username
password: !secret gmail_password
senders:
- [email protected]
name: pollen_burot
value_template: >-
{% if 'Beskjeden spredning av Burot' in body %}
Beskjeden
{% elif 'Moderat spredning av Burot' in body %}
Moderat
{% elif 'Kraftig spredning av Burot' in body %}
Kraftig
{% elif 'Ekstrem spredning av Burot' in body %}
Ekstrem
{% else %}
Ingen
{% endif %}
In the Developer Tool I see a sensor named sensor.pollen_burot and one of the states in the value_template.
You don’t see a sensor named sensor.motion_status in the Developer Tool? Or you see it, but it hasn’t got any state? Your sensor definition looks okay as far as I can see.
Another thing, when the camera stops detecting motion, will you then receive a new email? Otherwise your sensor will always have the state motion_yes . Or are you planning an automation that resets it to motion_no a few minutes after motion is detected?
That is correct;. I do not see sensor.motion_status in the developer tool.
Another thing that’s told me I’ve goofed, I can’t find the inbox. I have that samba app installed so I can see my RPi folders on my W10 PC… just nothing that’s like an inbox. Am I supposed to create one and if so where does it go?
And your right about my if statement. I’ll do an elif later on.
If you don’t see the sensor, try restarting Home Assistant and look in the log for errors.
I receive the emails in my regular gmail inbox (somewhere up in the Google cloud) and that’s where my imap_email_content sensors looks for new emails. I have configured Gmail with an app password as described here and I use this app password within Home Assistant. If your camera has a build-in email server I guess emails can be sent to your gmail address and then read by the sensor (if it’s configured correctly).
No, you don’t need https…
Open a terminal window on your RPi (or use the ssh plugin in HA) and simply see if you can reach out to Google’s IMAP server by sending ping -c 5 imap.gmail.com . If success, the response should be something like:
If you don’t get any response, something must be wrong in your end.
Well, at least now you know that you can get in touch with gmail from HA.
But do you receive emails in your gmail inbox from your camera when motion is detected?
(jnrksv assumes you are receiving emails, but I can’t see you confirming that you are actually receiving emails when motion is detected.)
Yes, I’m checking my Gmails. I’m recieving new ones often. I’ve temporarily set the sensitivity of the camera motion sensor to trigger if a bird sneezes so I get plenty of emails to the gmail account.
Nice. If you have enabled multi-factor authentication in your Google account, you have to create an app password (as described in the link above in the last reply from jnrksv).