Help with IMAP_Email_Content Automation

Good morning,
I´m trying to make an automation for a motion detection from an Abus camera. For this, I took the imap_email_content feature. here the config and the automation:

  - platform: imap_email_content
    server: imap.gmail.com
    name: abus_motiondetection
    port: 993
    username: [email protected]
    password: 123456788
    senders:
      - [email protected]


- id: '42'
  alias: motiondetection abus
  trigger:
  - entity_id: sensor.abus_motiondetection
    platform: state
    to: 'motiondetection'
  condition: []
  action:
    service: notify.pushbullet
    data:
      message: Movement Detected
      target: email/[email protected]


I know this will work only one time, as the sensor “sensor.abus_motiondetection” always has the state “motiondetection”, even if there are other emails arriving.

Do I have to “reset” the sensor state somehow, or can I use another syntax in the automation?
My idea was to add another action, like sending an email with “clear_state” in the Topic, to change the sensor state, but don´t know if this is the easiest way.

Thanks Philipp

Why not just add a second service at the end of your automation to change indeed the state of your sensors to something else?

Do you also have a Synology? If yes, you can add the camera in it, Synology is able to send the state through API

What service would that be?

That’s the way to do it. Or use this python script.

well, you can change the state of a switch/light/sensor with a curl command
so your second service would be a call to a shellcommanc

as example :

state_sensor: "curl -k POST -H \"Authorization: Bearer BEARERTOKEN\" -d '{\"state\": \"WHATEVERSTATE\",\"attributes\": {\"friendly_name\": \"NAMESENSOR\"}}' https://127.0.0.1:8123/api/states/sensor.YOURSENSOR"

1 Like

Thanks, I´ll give it a try