Hello everyone i am stuck with smth quite simple i guess… I have UPS Salicru configured to get email alarms with this topic "Alarmas SAI R5 " using IMAP. When i get them i have a helper called input_text.alarmas_sai_r5 which through an automation get the text value Alarmas SAI R5 or Sin Alarmas. It works, but the issue comes when i get a new email that doesnt have the subject “Alarmas SAI R5” but the input_text.alarmas_sai_r5 already had it. It does not keep it. Same if i get and email with diferent subject, it consider last email only. Not sure if you get me…sorry for my english.
Please post the automation so we can see how it’s structured.
What is the purpose of the Helper?
alias: ALARMAS SAI R5 V3
description: >
Mantiene el estado del ayudante mientras haya correos con el asunto “Alarmas
SAI R5 PRENSAS”. Cambia a “Sin alarmas” solo si no queda ninguno.
triggers:
- event_type: imap_content
trigger: event
conditions:
actions: - variables:
correo_asunto: “{{ trigger.event.data.subject | default(‘’) }}” - choose:
- conditions:
- condition: template
value_template: “{{ ‘Alarmas SAI R5 PRENSAS’ in correo_asunto }}”
sequence: - target:
entity_id: input_text.alarmas_sai_r5_prensas
data:
value: Alarmas SAI R5 PRENSAS
action: input_text.set_value
default:
- condition: template
- condition: template
value_template: >-
{{ is_state(‘input_text.alarmas_sai_r5_prensas’, ‘Alarmas SAI R5
PRENSAS’) }} - target:
entity_id: input_text.alarmas_sai_r5_prensas
data:
value: Sin alarmas
action: input_text.set_value
mode: single
- conditions:
the purpose of the helper is because i didnt know any other way to do it. basically i need to check in subject content Alarmas SAI R5 PRENSAS, if it is, i want to put in red a label card. this is what i get so far. but the issue is that when i get a new email without this subject, despite the first one remains unreaded or in the mail box, the alarm dissapear
Please format the configuration in your post… It makes it much easier for us to copy and edit.
alias: ALARMAS SAI R5 V3
description: >
Mantiene el estado del ayudante mientras haya correos con el asunto "Alarmas
SAI R5 PRENSAS". Cambia a "Sin alarmas" solo si no queda ninguno.
triggers:
- event_type: imap_content
trigger: event
conditions: []
actions:
- variables:
correo_asunto: "{{ trigger.event.data.subject | default('') }}"
- choose:
- conditions:
- condition: template
value_template: "{{ 'Alarmas SAI R5 PRENSAS' in correo_asunto }}"
sequence:
- target:
entity_id: input_text.alarmas_sai_r5_prensas
data:
value: Alarmas SAI R5 PRENSAS
action: input_text.set_value
default:
- condition: template
value_template: >-
{{ is_state('input_text.alarmas_sai_r5_prensas', 'Alarmas SAI R5
PRENSAS') }}
- target:
entity_id: input_text.alarmas_sai_r5_prensas
data:
value: Sin alarmas
action: input_text.set_value
mode: single
Are you using a general search in your IMAP integration sensor or a search specific for these emails? If you are using a general search, my first suggestion would be to set up an IMAP sensor specifically for this use, so that you don’t have to control for the interference from other emails.
Okay, I understand how the Helper connects.
The part that I don’t understand is what event/trigger you want to use to “clear” the helper’s value. Is there an email when the alarm stops or is it something you have to do manually?
This is my current problem, that when for example, in the case i have an email that arrives and has the subject that triggers my automation…
Then i get red card with helper input text containing the subject…
so far so god even when i delete this email from my inbox it works because trigger is considering the default way that is “sin alarmas”, BUT when arrives a new email that does not match with the subject BUT the email that triggered before the automation stills there, it goes to “sin alarmas” instead of keeping the state
Do you receive an email when the alarm clears?
If there is no email to signal that the alarm is clear, then there is no reason for default
action you are using.
It is the opposite. i mean for example: currently my inbox is with:
so my alarm is according to this:
.
Now if i get a new mail with Alarmas SAI R5 PRENSAS and in my inbox also still Alarmas R7 FISA1 unreaded, both cards should be in red, right? but it does not because only considers last email…
No, because you have set it to change to “Sin alarmas” on any email that does not contain “Alarmas SAI R5 PRENSAS”… your trigger and the conditions for default
option of the “Choose” action are both very non-specific.
What event do you want the value to change to “Sin alarmas”?
thanks for your patience. I am a bit confused right now. I want what i said…
1- i get and email with Alarmas SAI R5 PRENSAS–>red card in ESTADO SAI R5 PRENSAS card.
2-i get any other email then GREY CARD and sin alarmas in ESTADO SAI R5 PRENSAS card.
3. i get any other email, but inbox still email with ESTADO SAI R5 PRENSAS -->keeps Red card in ESTADO SAI R5 PRENSAS card.
To do that you have 2 option:
- Use specific conditions in the automation that check the event data.
- Set up an IMAP sensor with a search that is specific to the email.
And you may actually need to do both…
Have you seen the baby that tried for his first time wassaby? i am him…HELP
Start by setting up a second IMAP integration sensor that is specific to one of the alarms.
-
From the Integrations dashboard select IMAP.
-
At the bottom there should be a button that says “ADD ENTRY”. Click the button
-
Fill in all your email info.
-
From the screenshots you posted, it looks like this is a GMail account, which means you can use the X-GM-RAW search functions. For the “IMAP Search” field you should use:
UnSeen UnDeleted X-GM-RAW "subject: Alarmas SAI R5 PRENSAS"
- Save the configuration.
Now you can make your automation specific to the new sensor by using a more specific trigger, and you should be able to use the initial
attribute to tell if it’s an active alarm:
alias: ALARMAS SAI R5 V3
description: >
Mantiene el estado del ayudante mientras haya correos con el asunto "Alarmas
SAI R5 PRENSAS". Cambia a "Sin alarmas" solo si no queda ninguno.
triggers:
- event_type: imap_content
trigger: event
event_data:
search: UnSeen UnDeleted X-GM-RAW "subject: Alarmas SAI R5 PRENSAS"
conditions: []
actions:
- action: input_text.set_value
target:
entity_id: input_text.alarmas_sai_r5_prensas
data:
value: |
{{"Alarmas SAI R5 PRENSAS" if trigger.event.data.initial else "Sin alarmas" }}
mode: single
ok, step by step…now i have two sensor
first one checks inbox unread and undeleted
second one did it as you said:
then if i set the new automation as you told me, its behaviour is the same, it does not take into account wheter there is a mail with Alarmas SAI R5 PRENSAS or not in inbox folder…
Focus on getting the IMAP sensor working as expected… The sensor’s value being “0” means there are no emails that match all parts of the search criteria. The search criteria currently has 3 parts, and all must be true:
- The email must not be marked as “Seen”.
- The email must not be marked as “Deleted”.
- The subject must match.
Did the automation run at all? If so, you should download and post the json file of the debug Trace.
Since UnSeen
is the most volatile of the 3 criteria, I would remove it then re-run your tests.