ha-pesc
ha-pesc copied to clipboard
Failed setup, will retry: strptime() argument 1 must be str, not None
[{"id": {"provider": 61, "registration": "2"}, "name": "Газоснабжение", "numberOfDigitsLeft": 6, "numberOfDigitsRight": 0, "serial": "", "status": "ACTIVE", "indications": [{"previousReadingDate": null, "meterScaleId": 2, "indicationId": null, "scaleName": null, "previousReading": 6.0, "registerReading": null, "unit": null}], "subserviceId": 4656}]
2025-04-02 13:42:29.654 ERROR (MainThread) [custom_components.pesc] Unexpected error fetching pesc data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 380, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/pesc/__init__.py", line 77, in _async_update_data
await self.relogin_and_fetch_(False)
File "/config/custom_components/pesc/__init__.py", line 84, in relogin_and_fetch_
await self.api.async_fetch_all()
File "/config/custom_components/pesc/pesc_api.py", line 233, in async_fetch_all
await self.async_fetch_data()
File "/config/custom_components/pesc/pesc_api.py", line 255, in async_fetch_data
await asyncio.gather(*(self._load_account(account) for account in accounts))
File "/config/custom_components/pesc/pesc_api.py", line 260, in _load_account
await asyncio.gather(
...<4 lines>...
)
File "/config/custom_components/pesc/pesc_api.py", line 282, in _load_meters
ind = MeterInd(acc, met, met_ind)
File "/config/custom_components/pesc/pesc_api.py", line 60, in __init__
self.date = datetime.strptime(ind["previousReadingDate"], "%d.%m.%Y").date()
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: strptime() argument 1 must be str, not None
@dentra, is there any chance this will be fixed before the 25th of this month? can I help somehow?
curl --oauth2-bearer 'token' https://ikus.pesc.ru/api/v6/accounts/18900712/meters/info | jq gives:
[
{
"id": {
"provider": 61,
"registration": "2"
},
"name": "Газоснабжение",
"numberOfDigitsLeft": 6,
"numberOfDigitsRight": 0,
"serial": "",
"status": "ACTIVE",
"indications": [
{
"previousReadingDate": null,
"meterScaleId": 2,
"indicationId": null,
"scaleName": null,
"previousReading": 6.0,
"registerReading": null,
"unit": null
}
],
"subserviceId": 4656
}
]
--- pesc_api.py.orig
+++ pesc_api.py
@@ -57,7 +57,7 @@
ind: pesc_client.MeterIndication,
) -> None:
self.value = ind["previousReading"]
- self.date = datetime.strptime(ind["previousReadingDate"], "%d.%m.%Y").date()
+ self.date = datetime.strptime(ind["previousReadingDate"], "%d.%m.%Y").date() if ind["previousReadingDate"] is not None else None
self.unit = ind["unit"]
self.name = ind["scaleName"]
self.scale_id = ind["meterScaleId"]
It's a workaround, of course, but it allows integration to load and other meters work fine.
спасибо за решение.
пока в мастере