Phype / purei9_unofficial

This project includes a client/library to connect to Electrolux and AEG cleaner robots.
https://pypi.org/project/purei9-unofficial
MIT License
29 stars 5 forks source link

Bugfix, invalid isoformat string #20

Closed Ekman closed 1 year ago

Ekman commented 1 year ago

When attempting to use getCleaningSessions() I get this error:

bug in cleaning sessions

Home Assistant is using an older version of Python that cannot parse the date time as an ISO format. I've verified by running docker run --rm -it --entrypoint bash python:3.10 and executed the following script:

from datetime import datetime

print(datetime.fromisoformat("2021-09-15T18:49:22.14")

Instead, this worked:

from datetime import datetime

print(datetime.strptime("2021-09-15T18:49:22.14", "%Y-%m-%dT%H:%M:%S.%f"))
Phype commented 1 year ago

Thanks! Sorry for not responding any faster, this reminds me of changing my github email to something a am monitoring more often ...

Phype commented 1 year ago

Actually, your fix didn't work for me because the date didn't include the millisecond part in my case. Either the API is playing me again or this isn't always the case. For now i've fixed it by truncating it and only using the part before the ".".