YAML & templating does take a while to get one’s head around. But eventually they’ll sink in.
You can certainly use two sensors – one that provides all the data for the most recently received e-mail, and the other that extracts a useful tidbit from the detail. However, if that’s all you’ll ever want, then you can just do it in the one sensor. Depends on what you want to do. E.g., you could just do this:
Never mind its working now, it appears it wont scrape old emails only new ones
now i just need to figure out my regex
Email Body
SARATOGA SPRINGS CITY AN ALLOCATION ALERT has been triggered based on your preferences. You have reached 108.59% of your allocation for the month. The alert has now been deactivated. To configure this alert again, please log on to https://MYWATER.SARATOGASPRINGSCITY.COM. Thank you!
- platform: template
sensors:
secondary_use:
friendly_name: Secondary Water Use
value_template: >
{{ state_attr('sensor.water_use', 'body')
|regex_findall_index("\d+([,.]\d{1,9})?[$%]") }}
email sensor data
from: [email protected]
subject: SARATOGA SPRINGS WATER ALERTS
date: Wed, 14 Jul 2021 10:30:07 -0600
body: “SARATOGA SPRINGS CITY AN ALLOCATION ALERT has been triggered bas=\r\ned on your preferences. You have reached 108.59% of your allocat=\r\nion for the month. The alert has now been deactivated. To config=\r\nure this alert again, please log on to https://MYWATER.SARATOGASP=\r\nRINGSCITY.COM. Thank you!\r\n\r\n”
friendly_name: water_use
the secondary water sensor only pulls the digits after the .