Dear All,
I need some help, I have a device_tracker. created and updated with HTTP API using requests in python, works well when I update the Latitude and Longitude, but I need to update also “last_changed” - “last_reported” - “last_updated” value with value from my python script, below is the code:
date = datetime.datetime.fromtimestamp(loc.time).strftime('%Y-%m-%d %H:%M:%S')
print("Sending to HA")
print(latitude, longitude, date)
# Step 4: Send to HA
url = "https://hiddenbyme/api/services/device_tracker/see"
headers = {"Authorization": "Bearer HIDDEN BY ME"}
data = {"dev_id": "simba_GFM", "gps": [latitude, longitude,]}
response = post(url, headers=headers, json=data)
print(response)
response = get("http://hiddenbyme/api/states/device_tracker.simba_GFM", headers=headers)
print(response.text)
If I modify the data variable with this:
data = {"dev_id": "simba_GFM", "gps": [latitude, longitude,], "last_changed": date}
A 400 error message is raised…
I hope someone could help me.
Best Regards
Stefano