17track integration

with the help of Petro, Taras and google translate I try to share one of my automation that provides me with notifications, even TTS, if and when my shipments have some type of update: example … 'your parcel with the new one Raspberry is currently at Hong Kong airport ‘, or’ just arrived with the new drill '…

requirements:
1: open an account on 17track.net where to record the codes of your shipments and a friendly name to recognize the package
2: add 17track integration on Home assistant
3: activate a notification service on the Home assistant. To get voice notifications (TTS) to your phone, I recommend Lannouncer ( which only works locally) or Ariela (for those who can access HA also remotely … good app also for the device tracker). For the TTS directly from the raspberry instead I use Mopidy
4: only for Lannouncer, you should set a fixed IP address for your smartphone

on configuration.yaml set this:

# TTS mopidy
tts:
  - platform: google_translate
    time_memory: 57000
    language: 'xx'  # language code

# notify Lannouncer
notify:
  - platform: lannouncer
    name: ttslannouncer
    host: 192.168.1.121 # your smartphone static IP 
    port: 1035

on Automations.yaml

- id: 'packages in transit'
  alias: packages in transit
  trigger:
  - entity_id: sensor.seventeentrack_packages_in_transit
    platform: state
  condition:
  action:
  - condition: time
    after: '08:00:00'
    before: '23:50:00'
  - service: tts.google_translate_say    # TTS with Mopidy on Raspberry
    entity_id: media_player.mpd
    data_template:
      message: >
        {% set ns = namespace(items = 'update on the packages you are waiting for: ') %}
        {% for item in state_attr('sensor.seventeentrack_packages_in_transit', 'packages') %}
        {% set ns.items = ns.items ~ 'the package with {}: is  in {}, '.format(item.friendly_name, item.info_text) %}
        {% endfor %}
        {{ns.items}}     
  - service: mqtt.publish       # TTS with Ariela
    data_template:
      topic: 'homeassistant/tts/yourphonenamebyariela_tts/tts'  # see TTS voice on Ariela settings
      payload_template: >
        {% set ns = namespace(items = 'update on the packages you are waiting for: ') %}
        {% for item in state_attr('sensor.seventeentrack_packages_in_transit', 'packages') %}
        {% set ns.items = ns.items ~ 'the package with {}: is  in {}, '.format(item.friendly_name, item.info_text) %}
        {% endfor %}
        {{ns.items}}

- id: 'packages delivered'
  alias: packages delivered
  trigger:
  - entity_id: sensor.seventeentrack_packages_delivered
    platform: state
  action:
  - condition: time
    after: '08:00:00'
    before: '23:50:00'
  - service: notify.ttslannouncer     # lannouncer notifications only work locally
    data_template:
      message: "package delivered with {{ state_attr('sensor.seventeentrack_packages_delivered', 'packages') | map(attribute='friendly_name') | list | first }}"
  - service: tts.google_translate_say
    entity_id: media_player.mpd
    data:
      message: "you just got a package"   

I hope it can be useful to someone! :wink:

3 Likes

With this and some other help (thanks discord chat!) I finally managed to do an automation whenever a package gets delivered (and not activate when I archive it).

Starts a popup (requires browser_mod), starts blinking my lights (activate scene) and sends a message to my phone

automation:

alias: Package Delivered
trigger:
  - platform: state
    entity_id: sensor.seventeentrack_packages_delivered
condition:
  - condition: template
    value_template: >-
      {{ (trigger.to_state.attributes.packages | length) -
      (trigger.from_state.attributes.packages | length) > 0 }}
action:
  - service: script.package_delivered_popup
    data: {}
  - scene: scene.delivery_blink
  - service: notify.mobile_app_xxxxx
    data:
      message: Paket angekommen
mode: restart

because I had to mess around with the package_delivered_popup script, here if anyone can use it (needed a big text and a way to stop the blinking of the light, which is done with a second scene that stops the blink). Requires browser_mod and card_mod.
script.package_delivered_popup:

alias: Package Delivered Popup
sequence:
  - service: browser_mod.popup
    data:
      deviceID:
        - this
        - all
      title: close
      hide_header: true
      large: true
      card:
        type: 'custom:mod-card'
        report_size: 0
        card:
          type: vertical-stack
          cards:
            - type: markdown
              content: |-
                <br><br><br>

                # <center> ! Package Delivered !</center>

                <br><br><br>
              style: |
                @keyframes blink {
                  50% {
                    background: green;
                  }
                }
                ha-card {
                  animation: blink 2s linear infinite;
                  font-size: x-large;
                  }   
            - type: horizontal-stack
              cards:
                - type: button
                  entity: scene.gang_delivery_blink
                  show_name: false
                  icon: 'mdi:package-variant-closed'
                  tap_action:
                    action: call-service
                    service: script.turn_on
                    service_data:
                      entity_id: script.package_delivered_popup_off
                  style: |
                    @keyframes blink {
                      50% {
                        background: green;
                      }
                    }
                    ha-card {
                      animation: blink 2s linear infinite;
                    }    
                - type: button
                  entity: scene.gang_delivery_blink
                  show_name: false
                  icon: 'mdi:package-variant-closed'
                  tap_action:
                    action: call-service
                    service: script.turn_on
                    service_data:
                      entity_id: script.package_delivered_popup_off
                  style: |
                    @keyframes blink {
                      50% {
                        background: green;
                      }
                    }
                    ha-card {
                      animation: blink 2s linear infinite;
                    }             
        style: |
          @keyframes blink {
            50% {
              background: green;
            }
          }
          ha-card {
            animation: blink 2s linear infinite;
          }             
mode: restart

script.package_delivered_popup_off:

alias: Package Delivered Popup Off
sequence:
  - scene: scene.gang_delivery_blink_off
  - service: browser_mod.close_popup