Hello HA community! As my name would suggest, I am a “noob” at home assistant. However I posted this question but before I could get help I figured out a way to extract what I needed so will post this for someone who ends up here from a search.
Goal: To extract a dollar value to be presented in home assistant to know what was last months bill for different services. For this to work, the email from your utility company must include the bill amount in the body and not in PDF or something else.
What I put in my Configuaration.yaml:
- platform: imap_email_content
name: Bills Email
server: imap.gmail.com
port: 993
username: [email address]
password: [password]
folder: Bills
senders:
- [senders email goes here]
This works to create a sensor for me
The "bill2’ is my subject from the test email I sent to the location to see if it works and the body is the actual content.
{{ state_attr('sensor.bills_email','body')
| regex_findall ("\$([0-9.]+)") }}
I used the developer tool and tested it. It spit back 29 which is the amount in my body as the picture shows. I used the above in a mark down card in lovelace to show me the amount.
After my first successful try. I created different folders for different utilities and forwarded those emails. If I figure out a way to add PDF’s someway, I will add that too. There is a post Parsing PDF email attachments - Share your Projects! / Custom Components - Home Assistant Community (home-assistant.io) doing exactly this with PDF but I could not get it to work.
I am sure there might have been a simpler or better way of doing this and if there is let me know. But for now, without any coding experience, I am going with this.