#automations with different triggers and ids

1 messages ยท Page 1 of 1 (latest)

fast birch
#

Greetings all!
I am trying to mark an imap message read while in an automation with different imap trigger folders with new messages and having problems using the mail uid . I am guessing the trigger id somehow needs to be involved in the imap.seen action but i don't know the syntax i need other than what is shown in the example on the imap documentation page.
I used the following in the gui version of the automation editor for the uid field:

"{{ trigger.event.data['uid'] }}"

I am getting an error when the automation runs like so:

Error: Error rendering data template: UndefinedError: 'dict object' has no attribute 'event'

Help!

onyx shoal
#

Please share the entire automation YAML

dapper orchidBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

fast birch
#

ok, i think i edited it and it save as an attachment.

#

note that before i added the action to mark the message as seen/read, the automation was working good. and it still works until it stops from the error in the mark seen step.

eternal ore
#

You use trigger.event.data['uid'] but you only have numeric triggers. Numeric triggers don't have an event attribute. So what do you expect it to return?

fast birch
#

the trigger is indeed numeric. it is coming from the IMAP integration. I trigger based on it becoming greater than 0. as i mentioned earlier, before I added the attempt to mark the IMAP messages as seen, the automation is working fine. according to the IMAP integration page ( https://www.home-assistant.io/integrations/imap/ )there are several pieces of information in the trigger.event.data object and 'uid' is one of them.

Home Assistant

Instructions on how to integrate IMAP unread email into Home Assistant.

#

I'm not sure where to go next if i can't get the uid so that I can mark the message as being seen.

eager nexus
eternal ore
#

If you trigger on the event itself (via an event trigger) then yes, that data is avaialble. If you trigger with a numeric state trigger that's not available.
So did you "attempt to mark the IMAP messages as seen" included changing all the triggers?

fast birch
#

ok, so i have solved my problem.. I have indeed triggered on the event itself, rather than the count of messages. Silly me thinking they were tied together! ๐Ÿ™‚

#

I am also using multiple folders/labels so I have 4 different imap corresponding to the folders/labels, and created another that was for the inbox only. since i leave the inbox label intact and only add to it for the 4 different, i am able to use just 1 event trigger on the inbox to capture the message to be marked as seen.

#

I'm gonna do a 'howto' over on the forum for future uses of this as this is all interwoven together! ๐Ÿ™‚