Hi All,
Hoping someone can help. I used to use the IMAP_Email_Content integration to control a sensor for my alarm panel, showing if it was armed or not based on an email. It worked perfectly.
A few releases ago i was migrated to the ‘IMAP’ integration instead as email content was being depreciated. It did work (after a lot of trial and error) but has recently become extremely delayed at updating the sensor. Sometimes 15 mins, sometimes up to an hour delayed.
I have verified that the IMAP inbox is receiving the email instantly, so i know the issue is within HA. I’m not quite sure where to start so here is my config for the 2 sensors (Alarm and UPS).
Thanks in advance!
template:
- trigger:
- platform: event
event_type: "imap_content"
id: "alarm_status_event"
sensor:
- name: imap_content
state: "{{ trigger.event.data['subject'] }}"
attributes:
Message: "{{ trigger.event.data['text'] }}"
Server: "{{ trigger.event.data['server'] }}"
Username: "{{ trigger.event.data['username'] }}"
Search: "{{ trigger.event.data['search'] }}"
Folder: "{{ trigger.event.data['folder'] }}"
Sender: "{{ trigger.event.data['sender'] }}"
Date: "{{ trigger.event.data['date'] }}"
Subject: "{{ trigger.event.data['subject'] }}"
To: "{{ trigger.event.data['headers'].get('Delivered-To', ['n/a'])[0] }}"
Return-Path: "{{ trigger.event.data['headers'].get('Return-Path',['n/a'])[0] }}"
Received-first: "{{ trigger.event.data['headers'].get('Received',['n/a'])[0] }}"
Received-last: "{{ trigger.event.data['headers'].get('Received',['n/a'])[-1] }}"
- trigger:
- platform: event
event_type: "imap_content"
id: "network_cupboard_ups_event"
sensor:
- name: imap_content
state: "{{ trigger.event.data['subject'] }}"
attributes:
Message: "{{ trigger.event.data['text'] }}"
Server: "{{ trigger.event.data['server'] }}"
Username: "{{ trigger.event.data['username'] }}"
Search: "{{ trigger.event.data['search'] }}"
Folder: "{{ trigger.event.data['folder'] }}"
Sender: "{{ trigger.event.data['sender'] }}"
Date: "{{ trigger.event.data['date'] }}"
Subject: "{{ trigger.event.data['subject'] }}"
To: "{{ trigger.event.data['headers'].get('Delivered-To', ['n/a'])[0] }}"
Return-Path: "{{ trigger.event.data['headers'].get('Return-Path',['n/a'])[0] }}"
Received-first: "{{ trigger.event.data['headers'].get('Received',['n/a'])[0] }}"
Received-last: "{{ trigger.event.data['headers'].get('Received',['n/a'])[-1] }}"
template:
- trigger:
- platform: event
event_type: "imap_content"
id: "alarm_status_event"
event_data:
sender: "[email protected]"
sensor:
- name: alarm_status_new
state: >-
{% if 'Alarm Set' in trigger.event.data["subject"] %}
Armed
{% elif 'Alarm Un-Set' in trigger.event.data["subject"] %}
Disarmed
{% elif 'Alarm Stopped' in trigger.event.data["subject"] %}
AlarmStopped
{% elif 'Alarm Sounding' in trigger.event.data["subject"] %}
AlarmSounding
{% elif 'Mains Power Lost' in trigger.event.data["subject"] %}
MainsLost
{% elif 'Mains Power Restored' in trigger.event.data["subject"] %}
MainsRestored
{% elif 'Device Missing' in trigger.event.data["subject"] %}
Offline
{% endif %}
- trigger:
- platform: event
event_type: "imap_content"
id: "network_cupboard_ups_event"
event_data:
sender: "[email protected]"
sensor:
- name: network_cupboard_ups_status_new
state: >-
{% if 'battery mode' in trigger.event.data["subject"] %}
Battery
{% elif 'AC mode' in trigger.event.data["subject"] %}
Mains
{% elif 'low battery' in trigger.event.data["subject"] %}
NAS_Shutdown
{% elif 'connected' in trigger.event.data["subject"] %}
Mains
{% endif %}