#IMAP Content Template sensor
1 messages · Page 1 of 1 (latest)
Yes that fine and i know how to set binary sensor on the config file. Is it what i need or we need to add stuff on that ?
Do you already have any template sensors set up?
If you aren't sure, look along the left hand edge for the template:... If you have that, you will need to put the new sensor configuration under that heading.
Yes i have one for my door
Ok
template:
- binrary_sensor:
- name: "Switch Porte Sensor"
state: '{{ is_state("input_boolean.switch_pprte","") }}'
device_class: "door"
- name: "Switch Porte Sensor"
template:
- binary_sensor:
- name: Switch Porte Sensor
state: "{{ is_state("input_boolean.switch_pprte","")}}"
device_class: door
- trigger:
- platform: event
event_type: "imap_content"
event_data:
sender: AFraser@christieinnomed.com
binary_sensor:
- name: testemail
auto_off: "00:01:00"
state: >
{% set current = this.state|default('off', 1) %}
{% if trigger.event.data['subject'] is search('Alerte-Bus', ignorecase=True) %}
on
{% else %}
{{ current }}
{% endif %}
Once you have that in your configuration.yaml file and it is saved, go to Developer Tools > YAML and click the Restart button. Wait for everything to load then send yourself a test email.
Ok restart in progress. So i will send me the email and the sensor testmail shoud switch to on ?!
As long as the email is from the correct sender and has "Alert-Bus" in the subject line it will switch on for 1 minute. Since we used the search() function in the template it should work for any subject that has "Alert-Bus", like "Alert-Bus 234" or "ABC Alert-Bus", etc.
Great ! So know i just need to do my automation on when my sensor go on send me a notification
Is it possible to skip the sender and search on each email comming ?
Yes
I suppose i just need to remove sender: blablabla
alias: Bus notification
description: ''
trigger:
- platform: event
event_type: "imap_content"
condition:
- condition: template
value_template: |
{{trigger.event.data['subject'] is search('Alerte-Bus', ignorecase=True)}}
action:
- service: notify.mobile_app_iphone_141
data:
message: Alerte Bus
Thank you for taking the time to explain to me how to do it! for a beginner it's not always easy to understand the subtleties
When I started using HA I had no previous coding or computer science training, so I know how it is.