kdeyev / eyeonwater

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

list index out of range #85

Closed lsellens closed 9 months ago

lsellens commented 9 months ago

I've had this integration running fine for quite some time now. I noticed today that I haven't gotten a read since jan 21st. All of the entities are showing unavailable. This is the error in my logs.

Unexpected error fetching EyeOnWater data: list index out of range

Traceback (most recent call last):
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/site-packages/homeassistant/helpers/update_coordinator.py", line 300, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.pyenv/versions/3.11.6/lib/python3.11/site-packages/homeassistant/helpers/update_coordinator.py", line 256, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/dietpi_userdata/homeassistant/custom_components/eyeonwater/__init__.py", line 59, in async_update_data
    await eye_on_water_data.read_meters(days_to_load=3)
  File "/mnt/dietpi_userdata/homeassistant/custom_components/eyeonwater/coordinator.py", line 43, in read_meters
    await meter.read_historical_data(
  File "/mnt/dietpi_userdata/homeassistant/deps/lib/python3.11/site-packages/pyonwater/meter.py", line 78, in read_historical_data
    elif historical_data[-1].reading == self.last_historical_data[
         ~~~~~~~~~~~~~~~^^^^
IndexError: list index out of range

Restarted the integration and got the same error. I logged into eyeonwater.com to check the site was up and my credentials were still good which they were. Tried removing and reinstalling the integration but still getting the same error.

kdeyev commented 9 months ago

Thank you for reporting the issue. It seems that eyeonwater API stopped returning the readings for your account/meter. The simplest way for running a diagnostic would be a usage of pyonwater package directly:

"""Example showing the EOW Client usage."""

import asyncio

import aiohttp

from pyonwater import Account, Client

async def main() -> None:
    """Main."""
    account = Account(
        eow_hostname="eyeonwater.com",
        username="your EOW login",
        password="your EOW password",
    )
    websession = aiohttp.ClientSession()
    client = Client(websession=websession, account=account)

    await client.authenticate()

    meters = await account.fetch_meters(client=client)
    print(f"{len(meters)} meters found")
    for meter in meters:
        # Read meter info
        await meter.read_meter_info(client=client)
        print(f"meter {meter.meter_uuid} shows {meter.reading}")
        print(f"meter {meter.meter_uuid} info {meter.meter_info}")

        # Read historical data
        await meter.read_historical_data(client=client, days_to_load=3)
        for d in meter.last_historical_data:
            print(d)

    await websession.close()

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Could you please perform such a check and see if you get any readings?

lsellens commented 9 months ago

I tried loading this on a hassio box I was testing and got the same exact error. I noticed the info says last communication on 1-21-24 which is the last time I got a meter read in home assistant. I hopefully replaced all location info with xxxx

homeassistant@DNS:~/pyonwater$ python example.py 
1 meters found
meter xxxx shows DataPoint(dt=datetime.datetime(2024, 1, 21, 19, 45), reading=623146.2000000001, unit=<NativeUnits.GAL: 'gal'>)
meter xxxx info reading=Reading(flags=Flags(empty_pipe=False, leak=False, cover_removed=False, tamper=False, reverse_flow=False, low_battery=False, battery_charging=False, forced=False, magnetic_tamper=False, encoder_no_usage=False, encoder_temperature=False, encoder_reverse_flow=False, reading_changed=False, programming_changed=False, encoder_exceeding_max_flow=False, water_temperature_sensor_error=False, oscillator_failure=False, encoder_sensor_error=False, encoder_leak=False, water_pressure_sensor_error=False, min_max_invalid=False, end_of_life=False, encoder_dial_change=False, no_usage=False, device_alert=False, endpoint_reading_missed=False, encoder_removal=False, profile_read_error=False, encoder_programmed=False, time=datetime.datetime(2024, 1, 21, 19, 45), encoder_magnetic_tamper=False, meter_temperature_sensor_error=False), latest_read=LatestRead(full_read=623146.2000000001, units=<EOWUnits.UNIT_GAL: 'GAL'>, bill_read='623.1462', bill_display_units=<EOWUnits.UNIT_KGAL: 'KGAL'>, read_time=datetime.datetime(2024, 1, 21, 19, 45), has_endpoints=True, method='Network'), battery=Battery(register_=0, level=100, quality='good', thresh12mo=10, time=datetime.datetime(2024, 1, 21, 19, 57, 17)), customer_uuid='xxxx', aggregation_seconds=900, last_communication_time=datetime.datetime(2024, 1, 21, 19, 57, 17), firmware_version='1.15.1299', communication_security='VPN', meter_size_desc='5/8"', barnacle_uuid='xxxx', unit=<EOWUnits.UNIT_GAL: 'GAL'>, customer_name='xxxx', cell_type='LTE', pi_status='', second_carrier=False, input_config='encoder', meter_size_unit='INCHES', endpoint_status='Active', gas_pressure_compensation=1.0, serial_number='xxxx', activated_on='2018-07-17T21:01:24', sim_vendor='', pwr=Pwr(level=3, register_=0, signal_7days=7, signal_strength=-87, time=datetime.datetime(2024, 1, 21, 19, 57, 17), quality='good', signal_30days=24), communication_seconds=86400, cell_endpoint_name='LTE', rf_communication=True, low_read_limit=22000, utility_use_1='499532', timeslots=None, encoder=Encoder(time=datetime.datetime(2018, 7, 17, 21, 0, 11), dials=9, register_id='xxxx', totalizer=170), endpoint_type='ORION Cellular', utility_use_2='1', multiplier='0.0100000000', sim_type='DATA', register_number='single', wired_interface='encoder', endpoint_install_date=datetime.datetime(2018, 7, 18, 4, 59, 59), high_read_limit=484000, gas_sub_count=1, billing_number='23021', meter_size=0.625, flow=Flow(this_week=686.4000000000001, months_updated='2024-01-21T14:02:31.601717-06:00', last_month=None, last_year_last_month_ratio=0.7217068645640075, last_year_last_month=2695.0, delta_positive=2160.0, time=datetime.datetime(2024, 1, 21, 19, 44, 59), time_positive='2024-01-21T19:44:59', last_month_ratio=None, last_week_avg=64.17142857142858, last_year_this_month_ratio=0.386656859431843, delta=2160.0, this_month=1945.0, week_ratio=1.5280498664292075, weeks_updated='2024-01-21T14:02:25', last_year_this_month=5030.3, last_week=449.20000000000005, this_week_avg=98.05714285714286), hardware_version='v5.68305-002.12', connector_type='None', model='', resolution=0.01) sensors=Sensors(endpoint_temperature=EndpointTemperature(latest_average=14.0, last_reported='2024-01-21T19:45:00', seven_day_min='5.0', seven_day_average='11.9', seven_day_max='25.0', sensor_uuid='xxxx', conditions=Conditions(increasing=False, decreasing=False))) utility=Utility(fluid_barrel_billing_unit='FLUID_BARREL', cm_billing_unit='CM', cf_billing_unit='CCF', type_='NORMAL', utility_name='xxxx', eow_service_selector='NONE', gas_cf_billing_unit='CF', eow_type='CLASSIC', oil_barrel_billing_unit='OIL_BARREL', date_created='2017-03-14T15:24:27', gal_billing_unit='G1000', gas_cm_billing_unit='CM', utility_uuid='xxxx', imp_billing_unit='Imp1') updated=4614 last_updated='2024-01-21T20:02:32.178Z' service=Service(class_code_normalized='', route='251', active=True, class_code='R', service_type='W', service_id='NOR1', start_date=datetime.datetime(2018, 7, 18, 4, 59, 59), service_point_uuid='', cycle='') location=Location(city='xxxx', parcel_number='', location_name='xxxx', parity='E', country='US', route='251', geocode_status=1, zip_code='xxxx', longitude='xxxx', display_address_3='', state='xxxx', location_uuid='xxxx', county_name='', latitude='xxxx', display_address_2='', location_id='xxxx', display_address='xxxx', display_street_name='', cycle='') alerts=Alerts(leak_alert=LeakAlert(alert_type='CONTINUOUS_FLOW', name='Continuous flow', residential_user_name='xxxx@gmail.com', date_updated=None, alert_uuid='xxxx', state='active', date_created='2018-07-24T19:04:41', creator_user_uuid='xxxx')) account=AccountInfo(status='', first_name='', billing_address='xxxx', billing_city='xxxx', account_uuid='xxxx', billing_address_2='', full_name='xxxx', email='xxxx@GMAIL.COM', phone='xxxx', portal_status='', last_name='', account_id='xxxx', class_code='R', billing_address_3='', person_id='', date_created='2018-07-18T17:48:32', account_billing_cycle='', billing_zip_code='xxxx', billing_country='US', billing_state='xxxx', eyeonwater='Yes') meter=MeterData(sensors_available=SensorsAvailable(types=['endpoint_temperature']), has_endpoint=True, install_date=datetime.datetime(2018, 7, 18, 4, 59, 59), meter_uuid='xxxx', fluid_type='Water', timezone='US/Central', firmware_version='1.15.1299', communication_security='VPN', meter_size_unit='INCHES', cell_type='LTE', geocode_status=1, geo='xxxx', last_read_time=datetime.datetime(2024, 1, 21, 19, 45), note='', battery=Battery(register_=0, level=100, quality='good', thresh12mo=10, time=datetime.datetime(2024, 1, 21, 19, 57, 17)), endpoint_status='Active', alert_code=0, gas_pressure_compensation=1.0, service_type='W', serial_number='xxxx', type_='W', pwr=Pwr(level=3, register_=0, signal_7days=7, signal_strength=-87, time=datetime.datetime(2024, 1, 21, 19, 57, 17), quality='good', signal_30days=24), endpoint_connector='None', communication_seconds=86400, meter_size_desc='5/8"', is_compound='No', latitude='xxxx', typical_read_method='Network', endpoint_type='ORION Cellular', meter_id='xxxx', last_communication_time=datetime.datetime(2024, 1, 21, 19, 57, 17), pit_type='Unspecified', meter_spec_uuid='xxxx', manufacturer='UNSPECIFIED', has_valve=False, has_sensor=True, gas_sub_count=1, notes=Notes(count=0), meter_size=0.625, flow=Flow(this_week=686.4000000000001, months_updated='2024-01-21T14:02:31.601717-06:00', last_month=None, last_year_last_month_ratio=0.7217068645640075, last_year_last_month=2695.0, delta_positive=2160.0, time=datetime.datetime(2024, 1, 21, 19, 44, 59), time_positive='2024-01-21T19:44:59', last_month_ratio=None, last_week_avg=64.17142857142858, last_year_this_month_ratio=0.386656859431843, delta=2160.0, this_month=1945.0, week_ratio=1.5280498664292075, weeks_updated='2024-01-21T14:02:25', last_year_this_month=5030.3, last_week=449.20000000000005, this_week_avg=98.05714285714286), longitude='xxxx', flags=ActiveFlags(active_flags=[], time=datetime.datetime(2024, 1, 21, 19, 45)), model='', sequence_number=15790) service_agreement=ServiceAgreement(service_agreement_uuid='xxxx', start_date=datetime.datetime(2016, 11, 23, 5, 59, 59)) version='2' user=User(user_uuid='xxxx', user_name='xxxx@gmail.com', date_created='2018-07-24T18:59:52') groups=Groups(irrigation='No', continuous_flow='No', is_irrigatable='No', disable_valve_shutoff='No')
kdeyev commented 9 months ago

Could you please verify that you see your meter readings on eyeonwater.com? I suspect that the eyeonwater stopped to return the water meter readings at after Jan-21.

lsellens commented 9 months ago

Could you please verify that you see your meter readings on eyeonwater.com? I suspect that the eyeonwater stopped to return the water meter readings at after Jan-21.

Sure enough. The last read is 1-21. I guess there is something wrong with my meter or their site. Still a very arbitrary error message that was generated but thanks for pointing me in the right direction.

kdeyev commented 9 months ago

I've just added more verbose error message Thanks for reporting