so i converted to the new IMAP way of doing things… i have the IMAP intergration setup and its setup for INBOX and UnSeen UnDeleted
and my code template is
#######################################
### Intelcom Deliveries Template ###
#######################################
- trigger:
- platform: event
event_type: "imap_content"
id: "Intelcom Amazon Delivery Content"
event_data:
sender: "[email protected]"
sensor:
- name: Intelcom Amazon Delivery
state: >-
{% if 'Your package has been received!' in trigger.event.data["subject"] %}
received
{% elif 'Your package has been delivered!' in trigger.event.data["subject"] %}
delivered
{% elif 'Your order has been delivered!' in trigger.event.data["subject"] %}
delivered
{% elif 'Your package is on the way!' in trigger.event.data["subject"] %}
on_the_way
{% endif %}
#################################
### FedEx Deliveries Template ###
#################################
- trigger:
- platform: event
event_type: "imap_content"
id: "FedEx Delivery Content"
event_data:
sender: "[email protected]"
sensor:
- name: FedEx Delivery
state: >-
{% if 'Your package has been received!' in trigger.event.data["subject"] %}
received
{% elif 'Your package has been delivered!' in trigger.event.data["subject"] %}
delivered
{% elif 'Your order has been delivered!' in trigger.event.data["subject"] %}
delivered
{% elif 'Your package is now out for delivery today' in trigger.event.data["subject"] %}
on_the_way
{% endif %}
and i have a package coming from intel today… but its not reading the emails… it should be on the way but its still set to unknown and logs show no errors… what is coded wrong?
the old way worked where you did it in the under sensor… and had each one log into your email…
except for FedEx that one caued Log issues and would go blank state because when it loaded the body of the of the email… it was outside the database limits and it buggered up the state even though reading just for subject… so state was never working for fedex in the old way… but currently testing for intelcom and its not working at all this new way
You didn’t answer the question. Is your IMAP sensor,not your template-based content sensors,working properly?
You can still configure individual IMAP sensors based on specific search terms. Once you have the IMAP sensor setup, you can then create content sensors tied specifically to that IMAP sensor by setting the event trigger to a specific search…
now i not sure what you mean… i setup the imap sensor if you mean the “IMAP Intergration” then i said in the orginal post i have that setup but if you mean the imap sensors that sensor: - name: Intelcom Amazon Delivery state: >- {% if 'Your package has been received!' in trigger.event.data["subject"] %} received {% elif 'Your package has been delivered!' in trigger.event.data["subject"] %} delivered {% elif 'Your order has been delivered!' in trigger.event.data["subject"] %} delivered {% elif 'Your package is on the way!' in trigger.event.data["subject"] %} on_the_way {% endif %}
that thats what i have shown from the developer page that its showing unknown…
it finally worked well not really… it didnt detect the on its way… it did detect the delivered… i got another package coming tomorrow so ill see if the on its way and recieved will work tomorrow… but it just didnt work
as for that template for the fedex does that also skip getting the body… i know with the old way of doing it… it loaded up the entire body the message from fedex and all the html code and thats what i figured buggered up the fedex one… but ill find out tomorrow if it works for intel
so far it didnt detect. received or the on its way one just the delivered… so i hoping just a glitch
What I’m trying to determine is if the issue is with your template or actually a deeper issue. Each instance of the IMAP integration that you set up creates a sensor entity of its own. Normally, the sensor will have an entity id like sensor.imap_example_address. Check the States tool for that sensor and make sure it has a state value. The template-based content sensor will only ever be triggered if the IMAP sensor/integration instance is working properly.
Go to Developer Tools > States. Type sensor.imap in the ‘Filter entities’ field. If the value in the “State” column is a number, then your IMAP sensor is probably working. If it is ‘none’, ‘unknown’, or ‘unavailable’ then you should check the configuration of the IMAP sensor integration.
so my imap sensor says 2273 that seems to be the number of unread emails i have in my inbox… i noticed that number when i first setup the imap intergration this morning… just it didnt detect the email for my amazon delivery only later in the afternoon when it was delivered… so i figured maybe something wrong as normally the old way… if i rebooted home assistant it would detect the emails right away… well when it eventually booted up thats another story other issues i having taking too long to load up and some errors i have no idea what they mean and heartbeats etc
so i looked at home assistant this morning the imap sensor still showed 2272 from like 10pm last night now being 7:55am it still read that… i rebooted home assistant full reboot… and it jumped to 2279 the number which matchs the inbox… but the other sensor didnt detect the received email check… the state ist still unknown yet should flipped to received… like yesterday it couldnt detect the receieved or on the way setting one i have just the delivered…
i going to try just change it to received in the code to search for … not sure why it not checking right
so i got the received to work but it doesnt work like it used to…
how it used to work say if there was 10 emails after the email you looking for and reboot home assistant and it finds it like scans for it…
this new way doesnt…
to get it to work
i deleted say 10 emails that came after intel email and then home assistant detected… how is it supposed to work
as my internet is not the best and if it has to detect right away… i dunno is there something else i can add like search the current date
so say you have 20 emails today… it will scan the 20 emails not scan yesterday and days before… cuz my internet is flaky as i get like 3megabit or less when you live out in the country…
It looks like there is an issue with the IMAP integration which already has a fix in place for 2023.5.4. Read the issue report, if it matches the behavior you are experiencing make sure to update when 2023.5.4 is released. If it doesn’t match, open a new issue.
I´m trying to create a template with similar IMAP integration, and looking at the code below I have the following issue:
template:
- trigger:
- platform: event
event_type: "imap_content"
id: "custom_event"
event_data:
sender: "[email protected]"
sensor:
- name: Garmin_W
state: >-
{% if 'atividade' in trigger.event.data["subject"] %}
Em Atividade
{% elif no 'atividade' in trigger.event.data["subject"] %}
Descansando
{% endif %}
The elif seems to be a problem because when I delete the email from the inbox (or the subject isn´t there anymore) I need the sensor status to be the one indicated at the 2nd line.
I guess what I´m looking for is: if there´s an email from sender X in my mailbox, then status = true. If there´s no email from sender X in my mailbox, then status = false. Any way to adapt into that template/sensor, please?
Set up a second IMAP sensor from the Integrations page with the appropriate search criteria i.e. UnSeen UnDeleted FROM "[email protected]" BODY "atividade"
hummm can you send me an example so I can try to adapt? If I follow you correctly this 2nd sensor will do the same, no? Or will it let me know if the email was actually deleted? Didn´t understand that quite well sorry