Can someone point me in the right direction I am just trying to make an automation trigger when i get an e-mail from a specific contact. I am not sure what i am doing wrong this does not seam to be working. Below is the template i have in the sensor.
Never used this particular trigger - but the syntax is wrong, fix an indentation starting from the 4th line.
But actually it will anyway not work - you are trying to define this code inside UI used for creating template sensors - and I do not think that it is possible to define trigger-based ones; not to mention a presence of a “template” keyword.
So, my 1st sentence is about creating this sensor in yaml.
Ok I put this in my configuration.yaml I am very new to utilizing yaml not sure if this is correct? Its not working though. I don’t really want to turn on the light just using this to test.
Your action: part is indented too far. It needs to be inline with trigger:
Please follow Questions Guideline #11… configuration and other code should be shared as properly formatted text. This makes it easier to help you because we can copy/paste and edit without having to rewrite the whole thing.
For your template sensor:
- Make sure the configuration for the trigger-based template sensor is set up under the top-level key
template
. action
needs to be at the same depth astrigger
, and should not have a hyphen.- The
entity_id
in service call action needs to be nested under either adata
ortarget
key. - Make sure the rest of the sensor configuration is included. What you have posted so far is missing significant parts.
Below is what I have now, still not triggering anything (i think i did the code blocks correctly here?)
- trigger:
- platform: event
event_type: imap_content
id: custom_event
event_data:
sender: ********@gmail.com
action:
- service: switch.turn_on
target:
entity_id: switch.in_wall_paddle_switch_qfsw_500s
But are we still talking about a template sensor? If yes - then where is the rest of a sensor’s definition? (state etc)
? this is everything I added to the configuration.yaml file I was trying to duplicate the code at the bottom of the integration page IMAP - Home Assistant they had all that left out?
Can you clarify your goal?
- Are you trying to create a template sensor?
- Or to trigger an automation?
Be aware that a template sensor can be used to trigger an automation but is not necessary, you can use the imap_content
event directly as the trigger of an automation.
My ultimate goal is to trigger an automation when i receive an e-mail from a specific sender. I was under the impression the way to do that was to make this template sensor in the yaml file.
Open the Automation editor, add a trigger, select the “Manual Event” trigger… add the appropriate information:
Perfect that is exactly what i needed. Thank you!