I want to use the imap integration with Home Assistant but am struggling to get this configured right. Here is my usecase:
I get a daily email at 7am each morning from my utility company about my water consumption from the day before. The sender is [email protected]
Subject is ‘Gallon Alert for Meter id XXXXXXXX WA Meter’
Messge content is:
Hello,
You requested the Town notify you when your water usage exceeded 0.0 gallons per day for Meter #: XXXXXXXX - WA. Yesterday, your actual usage was 340.00 gallons. </END of message>
I want to be able to listen for this email arrival event, parse it and extract the ‘340.00’ gallons to display on my dashboard. Ideally I want this number to be appended daily/contiguously so that I can use it as a Utility Meter and display charts etc for daily/monthly etc.
What I have done so far is configured the HA Imap integration with my mailbox
I can see the sensor.imap_myemailaccount_messages has ~7500 message
Next I added the following to the configuration.yaml file:
template:
- trigger:
- platform: event
event_type: "imap_content"
id: "my_mail_eventid"
event_data:
search: UnDeleted X-GM-RAW "Gallon Alert"
initial: true
- sensor:
- name: water_email_sensor
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'] }}"
Rebooted everything. Wait for the utility water usage email to hit the mail box.
However, my sensor ‘water_email_sensor’ shows as unavailable when I check its value in Developer tools > States.
I know I might be missing something more fundamental here but I have been spinning on this since the last few days and am seeking help from someone who has successfully used imap with HA.
Please help!