Hallo. I get a emails from ebanking that shows changes in a bank account.
I want to set up an imap sensor to track the email, but I want it to use the values in the email for sensor information so I can see it on a graph or card in the front end.
How would I go about that?
My current “half working” email sensor template come from tutorial example
but is parsing random numbers
IMAP sensor config works:
# Example configuration.yaml entry
sensor:
- platform: imap_email_content
server: mail.myemail.cz
port: 993
username: user@myemail.cz
password: somepassword
folder: Inbox
senders:
- automat@fio.cz
Relevant part of email message look like
Date: Mon, 8 Jun 2020 08:18:04 +0200 (CEST)
From: automat@fio.cz
To: info@myemail.cz
Message-ID: 921120689.2352251.3591597084361.JavaMail.ums@sap1.private.fio.cz
Subject: Fio banka - prijem na konte
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-UMS-Id: 186437230
P=C5=99=C3=ADjem na kont=C4=9B: 80155454(1903540123)
=C4=8C=C3=A1stka: 190,00
VS: 877
Zpr=C3=A1va p=C5=99=C3=ADjemci: Pivo
Aktu=C3=A1ln=C3=AD z=C5=AFstatek: 4 386,86
Proti=C3=BA=C4=8Det: 3874103271/0100
SS:=20
KS: 0
Part of line what I’m traying parse to sensor is number after : in line
Aktu=C3=A1ln=C3=AD z=C5=AFstatek: 4 386,86
that mean
4 386,86
“Half working” template part look like:
- platform: template
sensors:
fio_recent_min:
friendly_name: Fio Min
unit_of_measurement: Kč
value_template: >
{{ state_attr('sensor.info_ebank_cz','body') | regex_findall_index(find='(\d+\,?\d+)', index=6, ignorecase=False) }}
fio_recent_max:
friendly_name: Fio Max
unit_of_measurement: Kč
value_template: >
{{ state_attr('sensor.info_ebank_cz','body') | regex_findall_index(find='(\d+\,?\d+)', index=7, ignorecase=False) }}
or tested template part solo
fio_recent_difference:
friendly_name: Fio Difference
unit_of_measurement: Kč
value_template: >
{{ state_attr('sensor.info_ebank_cz','body') | regex_findall_index(find='(-?\d+\, ?\d+)', index=0, ignorecase=False) }}
without success
Thank you for help with value template