Trying to make 17track integration useful again

I used and loved the 17track integration for years. It’s been refactored and I’ve never been more frustrated with Home Assistant than trying to get this data displaying on my dashboard again.

The official documentation is straight up incorrect and out-dated. It does not create a sensor per status. When it did I could use it. Instead, you need to call the get_packages action to get data out.

There is no example of that on the site. I found this commit on a pull request with an example. I tried to use that and I can do everything except do anything useful with the response variable. If I try to define the sensor in the YAML of the automation as per the example in the PR, it tells me it is invalid and won’t save. If I try to create a template sensor in configuration.yaml it has no value for packages_var and does nothing.

I have no idea how to do anything sensible with the results of the get_packages call. All I want to do is get the info about the packages into a form I can display. I can call it from debug and verify it works but I am failing to persist the results from that call in the automation into anything I can use. Can anyone help please?

Full YAML of the automation:

alias: Update 17Track Packages
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.17track_delivered
  - trigger: state
    entity_id:
      - sensor.17track_in_transit
  - trigger: state
    entity_id:
      - sensor.17track_ready_to_be_picked_up
  - trigger: state
    entity_id:
      - sensor.17track_returned
  - trigger: state
    entity_id:
      - sensor.17track_undelivered
conditions: []
actions:
  - action: seventeentrack.get_packages
    metadata: {}
    data:
      config_entry_id: REDACTED
    response_variable: packages_var
sensor:
  - name: packages_data
    unique_id: packages_data
    state: "{{ packages_var['packages']|length }}"
    attributes:
      packages: "{{ packages_var['packages']  }}"
mode: single

The error I get from this is Message malformed: extra keys not allowed @ data['sensor']. I’ve also been trying to find the full specification of what is allowed here and failing. HA does not want sensor where it is but I don’t know what can be. This page has some information but it does not seem to be exhaustive.

To close on this, I found a workable solution on Discord. I had to modify from there because inexplicably writing to an input variable too small to hold the text doesn’t generate an error. It just silently does nothing.

I ended up using the variable function of Saver to store the formatted results. This data is back on my dashboard again!