I’m using an the 17track integration to track packages (for some automation I’m planning).
I’m seeing some really strange behavior and I can’t seem to resolve, the simplest way to demonstrate my issue is with this one automation step that defines some variables:
variables:
packages: "{{ state_attr('sensor.seventeentrack_in_transit','packages') }}"
p_test1: "{{(packages)[0]}}"
p_test2: "{{ state_attr('sensor.seventeentrack_in_transit','packages')[0] }}"
In the “trace” for the automation, this is what I’m seeing:
packages: >-
[{'tracking_number': 'PH8000218XXX', 'location': '', 'status': 'In Transit',
'timestamp': datetime.datetime(2025, 2, 8, 19, 59, tzinfo=<UTC>), 'info_text':
'Arrived at linehaul office, Carrier note: Arrived at linehual office',
'friendly_name': "LED Project + RJ45"}, {'tracking_number':
'PH800023XXX', 'location': '', 'status': 'In Transit', 'timestamp':
datetime.datetime(2025, 2, 8, 7, 21, tzinfo=<UTC>), 'info_text': 'Arrived at
departure transport hub, Carrier note: Arrived at departure transport hub',
'friendly_name': 'Adapter for RJ45'}, {'tracking_number': 'PH80002XXXX',
'location': '', 'status': 'In Transit', 'timestamp': datetime.datetime(2025,
2, 8, 2, 35, tzinfo=<UTC>), 'info_text': 'Arrived at departure transport hub,
Carrier note: Arrived at departure transport hub', 'friendly_name': 'dddd'}]
p_test1: '['
p_test2: >-
{'tracking_number': 'PH800021XXXX', 'location': '', 'status': 'In Transit',
'timestamp': datetime.datetime(2025, 2, 8, 19, 59, tzinfo=<UTC>), 'info_text':
'Arrived at linehaul office, Carrier note: Arrived at linehual office',
'friendly_name': "LED Project + RJ45"}
My real issue here is that somewhere later in this automation I want to do a “repeat/for_each” on “packages” and it won’t let me, saying packages is not an array. So I don’t understand how to turn it into one, and if it’s not, how come I’m able to use indices to get individual members here, which seems to work directly in the line where the variable is defined, but not later.
Something doesn’t make sense… Any help will be greatly appreciated.
Thanks.