Read email body problem

Hello,

I have an Interlogix ZeroWire Alarm I would like to integrate to Home Assistant. The only way possible is via email. It sents out an email with its status each time it changes. I can read the email via the IMAP integration. It ends up in a sensor (sensor.atvanosjes) and the attributes are the following:

from: [email protected]
subject: Beveiligingsrapport van ZeroWire Alarm System
date: Sat, 27 Jan 2018 11:48:19 +0000
body: Alarm uitgeschakeld
Tijd: 12:48:18
Datum: 27 Jan 2018

I would like to have an automation based on the content of the body.

  • If the content says “Alarm uitgeschakeld”, which means “Alarm disarmed”, I would like to turn on some lights.
  • If the content says “Alarm ingeschakeld”, which means “Alarm armed”, I would like to turn off a few things.

Also I would like to have the Value "Armed/Disarmed " to end up in the attribute of the “alarm_control_panel.ha_alarm” entity.

Can somebody help me with this final step?

Thank you!

Ralph

Hi Ralph,

Here is an example setup for alarm sensor reading state from email. It is using the email subject, but the procedure is identical for message body:

sensor:
  - platform: imap_email_content
    server: !secret alarmServer
    port: !secret alarmPort
    name: "Alarm"
    username: !secret alarmUsername
    password: !secret alarmPassword
    senders:
      - !secret alarmSenders
    value_template: >-
      {%- if subject.split('Area')[0].strip() == 'Arming' -%}
      Armed
      {%- elif subject.split('Area')[0].strip() == 'Disarming' -%}
      Disarmed
      {%- else -%}
      notAvailable
      {%- endif -%}

Expected subject is a message like 'Arming Zone ’ - this is why this script is only checking first word from it and setting sensor state to Armed/Disarmed.
Then it can be accessed with

{{states.sensor.alarm.state}}
1 Like

Hi Vans,

Thank you for the response, much appreciated! I will try this tonight when I get back from work.

Ralph.

Hi Guys,

I also have a zerowire and wondered if the ZME*RAZ2 Zwave module could be used in a device connected to say the 8way arduino relay card to switch multiple relays rather than it be plugged onto the pi… I may be being silly but had to ask…

Thanks

Jimmy

Hi Jimmy, can’t help you with that. I don’t have either. Ralph