Witam. Chciałbym wyodrębnić dane z wiadomości email. Przykład jest z strony HA.
Ale mam pytanie co robię źle lub czego może mi brakuje. Sensory Previous Day Energy Use i dwa pozostałe są nieaktywne i danych nie przekazują. Jeśli chodzi o pierwszy przykład z wyszukiwaniem w temacie wiadomości to piknie działa jeśli prześlę z danego maila na dany ,ale jeśli chodzi o wyodrębnienie z wiadomości to już nie Asystent oczywiście zrestartowany i błędów nie wskazuje. Dokładnie w sensor yaml mam tak jak w przykładzie
# pow mail rachunki
- platform: imap_email_content
server: imap.gmail.com
name: energy_email
port: 993
username: tttttt@gmail.com
password: xxxxxxxxx
senders:
- yyyyyyy@gmail.com
- platform: template
sensors:
previous_day_energy_use:
friendly_name: Previous Day Energy Use
unit_of_measurement: kWh
value_template: >
{{ state_attr('sensor.energy_email', 'body')
|regex_findall_index("\*Yesterday's Energy Use:\* ([0-9]+) kWh") }}
previous_day_cost:
friendly_name: Previous Day Cost
unit_of_measurement: $
value_template: >
{{ state_attr('sensor.energy_email', 'body')
|regex_findall_index("\*Yesterday's estimated energy cost:\* \$([0-9.]+)") }}
billing_cycle_total:
friendly_name: Billing Cycle Total
unit_of_measurement: $
value_template: >
{{ state_attr('sensor.energy_email', 'body')
|regex_findall_index("\ days:\* \$([0-9.]+)") }}
Wiadomość przesyłana o treści jak w przykładzie
Yesterday's Energy Use: 76 kWh
Yesterday's estimated energy cost: $8
Monthly Energy use-to-date for 23 days: 1860 kWh
Monthly estimated energy cost-to-date for 23 days: $198
To view your account for details about your energy use, please click here.
Ok sam sobie odpowiem Przykłąd działającego szablonu
- platform: template
sensors:
previous_day_energy_use:
friendly_name: Previous Day Energy Use
value_template: >
{{ state_attr('sensor.energy_email', 'body')
|regex_findall_index('wyszukiwanytekst ([\d\s,]+)') }}
@Rafał_Kasperski edytuj posty.