Closed turribeach closed 2 years ago
Hmm. I'm using the exact same format string for both timestamps. The space at the end is because there's a space before where it's supposed to put the TZ. But it's not going there. So I think this is because the timestamp received from the API does not have timezone info in it.
I hate dealing with timezones.
Ok, got that one figured out. It'll force the TZ to your local system TZ. So hopefully that's what the timestamp returned by the API is set to.
Fixed in next release.
Thanks! Now it's even better as the timestamp field shows in my local time zone rather than UTC. We are currently on BST which is UTC +1:00.
Turns out the API returns UTC, but not with the TZ actually set in the datetime object. So I had to force it to UTC, then convert to local time.
Yes I saw the same thing with the prior version of the plugin, this is how I was converting it:
car_Last_Updated_DT = datetime.datetime.strptime(my_car.states["timestamp"], "%d %B %Y %H:%M:%S %Z")
#Tell the datetime object that it's in UTC time zone since datetime objects are 'naive' by default
car_Last_Updated_DT = car_Last_Updated_DT.replace(tzinfo=utc_time_zone)
Many thanks for updates, all looks great! Are you interested in adding my geofencing alerting to the plugin? I can add a new issue and post the code I am using although I need to make some changes to remove all the window/door/lids states and use your new fields.
Open an issue and describe the functionality, but don't post any code yet.
Script Error embedded script error: Script Error time data '24 May 2022 15:37:11 ' does not match format '%d %B %Y %H:%M:%S %Z' Script Error Exception Traceback (most recent call shown last):
In fact there is a space at the end so even without the %Z it fails to convert to date. I think it will be best to have both dates with time zone. Thanks!