#IMAP Content Template sensor

1 messages · Page 1 of 1 (latest)

unborn canyon
#

@analog gale You will need to access your configuration.yaml file.

#

Do you know how to do that?

analog gale
#

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 ?

unborn canyon
#

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.

analog gale
#

Yes i have one for my door

unborn canyon
#

Ok

analog gale
#

template:

  • binrary_sensor:
    • name: "Switch Porte Sensor"
      state: '{{ is_state("input_boolean.switch_pprte","") }}'
      device_class: "door"
unborn canyon
#
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.

analog gale
#

Ok restart in progress. So i will send me the email and the sensor testmail shoud switch to on ?!

unborn canyon
#

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.

analog gale
#

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 ?

unborn canyon
#

Yes

analog gale
#

I suppose i just need to remove sender: blablabla

unborn canyon
#
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
analog gale
#

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

unborn canyon
#

When I started using HA I had no previous coding or computer science training, so I know how it is.