kdeyev / eyeonwater

HACS repository for EyeOnWater integration
MIT License
26 stars 6 forks source link

Unsupported measurement unit: CCF #63

Closed djonk closed 1 year ago

djonk commented 1 year ago

Thanks for maintaining this great integration. It looks like something may have changed on the Eye On Water API side. Both v2.2.0-beta.1 and v2.0.5 are giving me the same error message since recently.

Logger: homeassistant.config_entries Source: custom_components/eyeonwater/coordinator.py:48 Integration: EyeOnWater (documentation) First occurred: 9:59:35 PM (3 occurrences) Last logged: 10:00:04 PM

Error setting up entry XXXXX@XXX.COM for eyeonwater Traceback (most recent call last): File "/config/custom_components/eyeonwater/coordinator.py", line 46, in read_meters await meter.read_meter(client=self.client, days_to_load=days_to_load) File "/usr/local/lib/python3.11/site-packages/pyonwater/meter.py", line 64, in read_meter historical_data = await self.reader.read_historical_data( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyonwater/meter_reader.py", line 124, in read_historical_data statistics += await self.read_historical_data_one_day( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyonwater/meter_reader.py", line 186, in read_historical_data_one_day reading=self.convert(response_unit, d.bill_read), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyonwater/meter_reader.py", line 71, in convert raise EyeOnWaterAPIError( pyonwater.exceptions.EyeOnWaterAPIError: Unsupported measurement unit: CCF

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

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 388, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/eyeonwater/init.py", line 53, in async_setup_entry await eye_on_water_data.read_meters(days_to_load=30) File "/config/custom_components/eyeonwater/coordinator.py", line 48, in read_meters raise UpdateFailed(error) from error homeassistant.helpers.update_coordinator.UpdateFailed: Unsupported measurement unit: CCF

kdeyev commented 1 year ago

Thank you for reporting the issue. Please try v2.0.7-beta.1

kdeyev commented 1 year ago

Actually, the problem may be in your configuration: Could you please verify your HA configuration? It seems that HA is trying to use metric units, when eyeonwater provides US units. Screenshot 2023-09-05 003727

djonk commented 1 year ago

Thank you. Switching the units in my config indeed resolved the issue. It broke other integrations that only support Metric. Is there any way in a future release to make this less tied to the overall HA unit setting?

On Mon, Sep 4, 2023 at 10:40 PM Konstantin Deev @.***> wrote:

Actually, the problem may be in your configuration: Could you please verify your HA configuration? It seems that HA is trying to use metric units, when eyeonwater provides US units. [image: Screenshot 2023-09-05 003727] https://user-images.githubusercontent.com/3978157/265596136-e635ba12-fc6e-4f7b-80f4-5a92586fa323.png

— Reply to this email directly, view it on GitHub https://github.com/kdeyev/eyeonwater/issues/63#issuecomment-1705975190, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWNN6HGSWSSSLV76IY5FFDXY23ONANCNFSM6AAAAAA4LFYNMY . You are receiving this because you authored the thread.Message ID: @.***>

kdeyev commented 1 year ago

Ok, I tried to address this problem: https://github.com/kdeyev/eyeonwater/releases/tag/v2.0.7-beta.2. Please let me know if it works

disforw commented 1 year ago

We should move forward with getting rid of this ourselves and just providing HA with the native unit from the read. When we provide a native unit of measurement, HA will automatically convert to the unit that the user wants and allows them to change it on the fly. IMG_3473 This will remove all need for us to convert or even guess what the user wants. I realize there are some unites that we will still need to provide a calculation for (ie: 100gal) but this is much simpler to do.

kdeyev commented 1 year ago

@disforw I prepared the ground for this change in pyonwater. In this PR pyonwater does not convert units anymore but returns the value with unit code. Also, it provides helper functions for native unit deduction and conversion here

disforw commented 1 year ago

This is now fixed in PR #64 👍🏼