barleybobs / homeassistant-ecowater-softener

A Homeassistant custom component to integrate Ecowater water softeners
https://github.com/barleybobs/homeassistant-ecowater-softener
MIT License
31 stars 9 forks source link

"Yesterday" returned by API and causing integration crash #39

Closed aicarmic closed 4 months ago

aicarmic commented 1 year ago

First; This is a really helpful integration for monitoring our water use, so wanted to start with a big thanks to the contributors!

### Issue: Integration fails with the following, which appears to be an invalid response from the status API:

Logger: homeassistant.components.sensor
Source: helpers/update_coordinator.py:258
Integration: Sensor (documentation, issues)
First occurred: June 19, 2023 at 8:40:04 PM (9 occurrences)
Last logged: 9:30:27 PM

Error while setting up ecowater_softener platform for sensor
Traceback (most recent call last):
  File "/config/custom_components/ecowater_softener/coordinator.py", line 64, in _async_update_data
    data[OUT_OF_SALT_ON] = datetime.strptime(data_json['out_of_salt'], '%d/%m/%Y').strftime('%Y-%m-%d')
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data 'Yesterday' does not match format '%d/%m/%Y'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ecowater_softener/coordinator.py", line 83, in _async_update_data
    raise UpdateFailed(f"Error communicating with API: {e}")
homeassistant.helpers.update_coordinator.UpdateFailed: Error communicating with API: time data 'Yesterday' does not match format '%d/%m/%Y'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 320, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/ecowater_softener/sensor.py", line 107, in async_setup_entry
    await coordinator.async_config_entry_first_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in async_config_entry_first_refresh
    raise ex
homeassistant.exceptions.ConfigEntryNotReady: Error communicating with API: time data 'Yesterday' does not match format '%d/%m/%Y'

### Symptoms + Steps taken: I'm repeatedly running into this issue, and the API response does not match the app status.

Not sure what else to do to troubleshoot the issue so any guidance would be appreciated 🙏

somarkram commented 8 months ago

Not sure if you have this working yet, but I just started using this integration, and it seems after 8pm/20 hours, mine returns this "Yesterday" error as well, may be related since I see your errors happened after this tike as well, seems to correct itself after midnight, I'm east coast, USA. Not sure if it's a time zone thing?

This error originated from a custom integration.

Logger: custom_components.ecowater_softener.coordinator Source: helpers/update_coordinator.py:322 Integration: Ecowater Softener (documentation, issues) First occurred: October 30, 2023 at 20:03:37 (2 occurrences) Last logged: October 31, 2023 at 20:02:59

Error fetching Ecowater ########## data: Error communicating with API: time data 'Yesterday' does not match format '%m/%d/%Y'

brilthor commented 4 months ago

seeing the same issue with fully updated system

barleybobs commented 4 months ago

Sorry for the late fix. This should now be fixed in v3.3.0

Thanks 👍

almoney commented 4 months ago

Thank you for the fix. I am still very concerned about HA systems polling at 10 minutes. I am still updating my interval to 60 minutes.