The scenario is that an Access Control system sends email to SMTP2MQTT on HA which then MQTT publishes. I’m trying to create automations that will complete based on certain words in the subject or content portion of the email. I trigger the automation based on the MQTT topic, which works, but can’t get the value template in condition to match a value for instance “Door-Unlocked”. I would also like to be able to reuse the matched value for a notification when the automation is triggered. The published json is below:
If you are using an MQTT trigger, you can reference the payloads by using the trigger variable (from the docs). In your case: trigger.payload_json.mime_parts[0].content
So that may get me closer as I was missing mime-parts but the problem I’m having is the syntax of the value template and getting it to match if trigger.payload_json.mime_parts[0].content contains value “x”
{{ 'Door-Unlocked' in trigger.payload_json.mime_parts[0].content }}
I already had this template in but without the mime-parts[0] so decided to give it a try and it worked. Do the other examples you gave differ in functionality from my solution or is just another way to solve it? Thank you by the way!
It’s just a different way… IIRC, using in is probably a little more efficient, so you might as well stick with that. One benefit to using search would be the option to control whether it is case sensitive or not… if that’s something you might need.