17Track integration returns strange datetime for timestamp
#127037
Description
The problem
The 17track integration, when performing the get_packages
action, returns what by all rights look like regular JSON -- a list of dicts.
One of the fieds, timestamp
, shows up as 'timestamp': datetime.datetime(2024, 9, 28, 4, 44, tzinfo=<UTC>),
which makes the entire chunk invalid JSON. To me, it looks like someone forgot a {{ }}
somewhere.
Currently, the only way to get proper object data out of this is to do pretty invasive sanitizing, and throwing it at from_json
, then turning it back to a datetime on the consuming end. It's kinda ugly, hoping this can be addressed.
Repro steps below, including my halfassed workaround.
What version of Home Assistant Core has the issue?
core-2024.8.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
seventeentrack
Link to integration documentation on our website
https://www.home-assistant.io/integrations/seventeentrack/
Diagnostics information
No response
Example YAML snippet
- trigger:
- platform: time_pattern
seconds: /30
action:
- action: seventeentrack.get_packages
data:
config_entry_id: --- REDACTED ---
response_variable: response
sensor:
- name: Parcel Tracking
icon: mdi:package-variant-closed
state: >
{% for location, package_group in response.packages | groupby("location") if response.packages is defined %}
{{- location }}
{% for package in package_group %}
{{- package.friendly_name }} ({{ relative_time(package.timestamp) -}})
{% endfor %}
{% else %}
{{- "No tracked packages" }}
{% endfor %}
attributes:
raw: "{{ response.packages }}"
packages: >
{{
response.packages
| replace("'", '"' )
| regex_replace(
"datetime.datetime\((?P<tsvars>[^)]+?)?\)",
'"\g<tsvars>"'
)
}}
Anything in the logs that might be useful for us?
No response
Additional information
No response