Hello,
I have setup the Imap integration to receive notification successfully on my smartphone and to mark the mail as seen but the email is not marked as seen due to the error below
- The “imap.seen” configuration in automation ( edited in yaml format) has been setup as per "IMAP - Home Assistant chapter “Example - post - processing”
action: imap.seen
metadata: {}
data:
entry: 01KEF0XQQGCQ9T4MFBK3WME4TA
uid: "\"{{ trigger.event.data['uid'] }}\""
- The error message is :
IMAP 'Mark message as seen'
Executed: 10 January 2026 at 18:10:10
Error: Error rendering data template: UndefinedError: 'dict object' has no attribute 'event'
Please advice
Thank you
Thank you @boheme61 for your reply
- The configuration.yaml from the template section , for 1 sensor ( out of 4)
- triggers:
- trigger: event
event_type: "imap_content"
id: "custom_event"
event_data:
sender: "[email protected]"
sensor:
- name: "notif_ik"
state: "{{ trigger.event.data['subject'] }}"
attributes:
Entry: "{{ trigger.event.data['entry_id'] }}"
UID: "{{ trigger.event.data['uid'] }}"
Sender: "{{ trigger.event.data['sender'] }}"
Subject: "{{ trigger.event.data['subject'] }}"
- The automation configuration
id: '1766402713788'
alias: Imap_messages
description: ''
triggers:
- trigger: state
entity_id: []
- trigger: numeric_state
entity_id:
- sensor.imap_gerard_ik_me_messages
above: 0
below: 10
- trigger: numeric_state
entity_id:
- sensor.imap_gerard_ik_me_messages_2
above: 0
below: 10
- trigger: numeric_state
entity_id:
- sensor.imap_gerard_ik_me_messages_3
above: 0
below: 10
- trigger: numeric_state
entity_id:
- sensor.imap_gerard_ik_me_messages_4
above: 0
below: 10
conditions: []
actions:
- if:
- condition: numeric_state
entity_id: sensor.notif_nas_noreply
above: 0
below: 10
then:
- action: notify.mobile_app_sm_s711b
metadata: {}
data:
title: Notification NAS No reply
message: '"{{ states(''sensor.notif_nas_noreply'') }}"'
- if:
- condition: numeric_state
entity_id: sensor.imap_gerard_ik_me_messages
above: 0
below: 10
then:
- action: notify.mobile_app_sm_s711b
metadata: {}
data:
title: Notification NAS Sns
message: '"{{ states(''sensor.notif_nas_sns'') }}"'
- if:
- condition: numeric_state
entity_id: sensor.imap_gerard_ik_me_messages_3
above: 0
below: 10
then:
- action: notify.mobile_app_sm_s711b
metadata: {}
data:
message: '"{{ states(''sensor.notif_ik'') }}"'
title: Notification IK
- action: imap.seen
metadata: {}
data:
entry: 01KEF0XQQGCQ9T4MFBK3WME4TA
uid: '"{{ trigger.event.data[''uid''] }}"'
- if:
- condition: numeric_state
entity_id: sensor.imap_gerard_ik_me_messages_4
above: 0
below: 10
then:
- action: notify.mobile_app_sm_s711b
metadata: {}
data:
message: '"{{ states(''sensor.notif_sg'') }}"'
title: Notification Sg
mode: single
With a test config , the mail is not marked as seen
id: '1761298013033'
alias: Imap_ik
description: ''
triggers:
- trigger: state
entity_id:
- sensor.imap_gerard_ik_me_messages
to: null
conditions: []
actions:
- if:
- condition: template
value_template: '{{ states(''sensor.notif_imap_test'') > "0" }}'
then:
- action: notify.mobile_app_sm_s711b
metadata: {}
data:
title: Notification
message: '{{ states(''sensor.notif_imap_test'') }}'
- action: imap.seen
metadata: {}
data:
uid: '1082'
entry: 01KEVBFYDM9S2JGQ7Z7YG3NQGV
mode: single
What does your automation trace shows ?
Sorry , I forgot .There is no error
IMAP ‘Mark message as seen’
Executed: January 14, 2026 at 2:22:11 PM
Result:
params:
domain: imap
service: seen
service_data:
uid: ‘1082’
entry: 01KEVBFYDM9S2JGQ7Z7YG3NQGV
target: {}
running_script: false
I
That’s not a functional trigger.
What are you expecting from the Numeric State triggers?
As shown, they will only fire in either of the following two circumstances:
- The value goes from 0 to some number between 1-9.
- The value goes from above 10 to some number between 1-9.
Changes of value within the range of 1-9 will not trigger the automation.
This template is performing a string comparison, not a true numeric value comparison, for accurate and reliable results, use the int filter on the state value and compare it to an integer or float:
value_template: '{{ states("sensor.notif_imap_test") | int(0) > 0 }}'
@Didgeridrew ,
Thanks for your advice.
After changing the value template as proposed , I had difficulty with the Uid parameter in the imap.seen action , which has to be set as follow
( from the configuration.yaml file )
{{ state_attr('sensor.notif_imap_test', 'UID') | int }}