Setting manual tracker

Hi all,

I’ve got two kids at preschool. They don’t have any smartphones or other trackable devices, but I do get e-mails whenever they arrive/depart.

I’m trying to setup a person tracker for each of them, to show if they’re at preschool or not.

So far:

  • I did set up a fake device tracker, using deprecated known_devices.yaml (better ways?).
  • I did manage to create the persons with connection to the fake trackers.
  • I did manage to manually set the tracker to preschool or away using a entity card, and click/long click.
  • I managed to install IMAP email content to parse my emails for the check in/out emails.

So far so good.

To the question:
I cannot figure out how to integrate the mail parser function to set the fake tracker value. Any and all ideas would be great, please!

Fake tracker:

kid1_fake_device_tracker:
  name: kid1_fake_device_tracker
  mac:
  icon:
  picture:
  track: true

E-mail parser:

# IMAP email content, email parser
sensor:
  - platform: imap_email_content
    server: imap.gmail.com
    name: tempushemma
    port: 993
    username: [email protected]
    password: !secret gmail1
    senders:
      - [email protected]
    value_template: >-
      {% if 'Kid1 check out' in subject %}
        Away
      {% elif 'Kid1 check in' in subject %}
        Preschool
      {% endif %}

To (sucessfully) set the tracker manually in the entity card, I use:

type: entity-button
tap_action:
  action: call-service
  service: device_tracker.see
  service_data:
    dev_id: kid1_fake_device_tracker
    location_name: Preschool
hold_action:
  action: call-service
  service: device_tracker.see
  service_data:
    dev_id: kid1_fake_device_tracker
    location_name: away
show_icon: true
show_name: true
entity: person.kid1

If your imap_email_content sensor works, use that as an automation trigger.

- alias: Kids Tracker Update
  trigger:
    - platform: sensor
      entity_id: sensor.tempushemma
  action:
    - service: device_tracker.see
      data:
        dev_id: kid1_fake_device_tracker
        location_name: "{{ trigger.to_state.state }}"
1 Like

Ah good idea! Thanks! Will try, and report back

Great idea!

Did you ever complete this?