How to reset an email sensor?

Hello fellow Home Assistant enthusiasts,

I am currently trying to use Wyze Cam motion detection to action events.
The only way I have been able to do this is to connect Wyze through IFTTT.

When motion is detected on the camera, an email get set to my email address, HA monitors my email for the subject line “Motion Detected” and then my sensor is marked as “Detected” when email found.

My issue is that I don’t know how to reset the sensor to “Clear” after 5 seconds…

sensor:
#MOTION DETECTION IN EMAIL FROM IFTTT - WYZECAMPAN
  - platform: imap_email_content
    server: imap.gmail.com
    name: Outdoor Garage Cam Motion email
    port: 993
    username: [email protected]
    password: !secret gmail_password
    senders:
      - [email protected]
    value_template: >-
      {% if 'Motion detected - WyzeCAMPAN' in subject %}
        Detected
      {% else %}
        Clear
      {% endif %}

I would very much appreciate any assistance.

Thank you in advance :slight_smile:

I am guessing this sensor stays on Detected, as it only reads similar emails, one after another, or at least until another email comes in with a different subject.

Although I feel there should be an easier way, what you could do is work with an input_select:

input_select:
  motion_detected:
    name: Motion Detected
    options:
      - Detected
      - Clear
    initial: Clear

Then have an automation with two triggers:
Check sensor.imap_email_content’s status for

  • Clear->Detected
  • Detected -> Detected

This automation would fire a script which would do two things:

  • Set input_select.motion_detected -> Detected
  • Wait 5 seconds
  • Set input_select.motion_detected -> Clear

You can also set up an extra template sensor (binary or not) that would have the same value as the input_select or would be on/off

1 Like

G’day @krash,

Many thanks for your support - I’ll have a play around with it and see how I go.
Cheers! :slight_smile:

Did you ever figure out the best solution to this? I have the same question/issue!