kdeyev / eyeonwater

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

Meter and Statistic Unavailable #107

Closed zackaryssmith closed 3 months ago

zackaryssmith commented 4 months ago

The integration is unable to pull usage data from the meter, other sensors pull in fine. I am able to see all data from the eyeonwater sources directly.

Logger: homeassistant Source: components/recorder/statistics.py:2230 First occurred: 9:49:21 AM (3 occurrences) Last logged: 9:58:32 AM Error doing job: Task exception was never retrieved

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 291, in async_refresh await self._async_refresh(log_failures=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners update_callback() File "/config/custom_components/eyeonwater/sensor.py", line 130, in _state_update self.import_historical_data() File "/config/custom_components/eyeonwater/sensor.py", line 157, in import_historical_data async_import_statistics(self.hass, metadata, statistics) File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 2230, in async_import_statistics raise HomeAssistantError("Invalid statistic_id") homeassistant.exceptions.HomeAssistantError: Invalid statistic_id

Logger: homeassistant.components.sensor Source: helpers/entity_platform.py:580 integration: Sensor (documentation, issues) First occurred: 9:49:21 AM (3 occurrences) Last logged: 9:58:31 AM Error adding entity sensor.water_meter_REDACTED_temperature for domain sensor with platform eyeonwater

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 580, in _async_add_entities await coro File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 892, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1359, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1009, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state state, attr, capabilities, shadowed_attr = self.async_calculate_state() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in async_calculate_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1015, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 543, in state value = self.native_value ^^^^^^^^^^^^^^^^^ File "/config/custom_components/eyeonwater/sensor.py", line 188, in native_value return self.meter.meter_info.sensors.endpoint_temperature.seven_day_min ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'endpoint_temperature'

image

kdeyev commented 4 months ago

@zackaryssmith thank you for reporting the issue. Is it a new issue? or you just installed the extension for the first time?

zackaryssmith commented 4 months ago

@kdeyev I had it previously installed but had removed it due to the usage resulting in a negative number. This issue is appearing from a reconfiguration of the integration.

Odd behavior, if I change the unit for the stats sensor I am able to get a number but it doesn't seem to have updated in the last week.

kdeyev commented 4 months ago

@zackaryssmith Could you please try to downgrade to extension version v2.5.6? I think it may be a regression in the pyonwater module

zackaryssmith commented 4 months ago

@kdeyev I spent some time downgrading versions to see when it last worked and it seems that for my issue it was 2.5.0. Curiously, this is the update before the Statistics sensor was added. I still need to toggle the units to get any usage to show and the history import service does not work but it never has in my case.

I also noticed that in the energy dashboard configuration, I have the following errors with the current versions: image image

kdeyev commented 4 months ago

The warning messages are expected: there is short explanation in the extension wiki. But I'm puzzled with the error messages you shared, my best guess there is a problem with the meter ID parsing. If you have some programming experience - it would be very helpful if could run the pyonwater example with your credentials. Thank you!

zackaryssmith commented 4 months ago

@kdeyev Here is the output of the example.py with personal data removed and readable formatting.

\example.py:45: DeprecationWarning: There is no current event loop loop = asyncio.get_event_loop() Starting example Meters found: 1 Meter 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, 6, 3, 12, 0), encoder_magnetic_tamper=False, meter_temperature_sensor_error=False), latest_read=LatestRead(full_read=43072.3, units=<EOWUnits.UNIT_CUBIC_FEET: 'CUBIC_FEET'>, bill_read='43072.3 ', bill_display_units=<EOWUnits.UNIT_CF: 'CF'>, read_time=datetime.datetime(2024, 6, 3, 11, 59, 59), has_endpoints=True, method='Network'), battery=None, customer_uuid='REDACTED ', aggregation_seconds=3600, last_communication_time=datetime.datetime(2024, 6, 3, 13, 23, 27), firmware_version=' ', communication_security='Unknown ', meter_size_desc='1" ', barnacle_uuid='REDACTED ', unit=<EOWUnits.UNIT_CUBIC_FEET: 'CUBIC_FEET'>, customer_name='REDACTED ', cell_type='NA ', pi_status=' ', second_carrier=False, input_config='encoder ', meter_size_unit='INCHES ', endpoint_status='Active ', gas_pressure_compensation=1.0, serial_number='REDACTED ', activated_on=None, sim_vendor='NA ', pwr=None, communication_seconds=3600, cell_endpoint_name='Unknown ', rf_communication=False, low_read_limit=None, utility_use_1=' ', timeslots=None, encoder=Encoder(time=datetime.datetime(2019, 6, 20, 22, 0), dials=8, register_id='NA ', totalizer=999999), endpoint_type='ORION Fixed Network ', utility_use_2=' ', multiplier='0.0748051948 ', sim_type='NA ', register_number='single ', wired_interface='encoder ', endpoint_install_date=datetime.datetime(2019, 7, 16, 6, 59, 59), high_read_limit=None, gas_sub_count=1, billing_number='REDACTED ', meter_size=1.0, flow=Flow(this_week=546.9755843776001, months_updated='2024-06-03T10:51:04.129331-04:00 ', last_month=2438.4997400904, last_year_last_month_ratio=0.2880864522930943, last_year_last_month=851.4327272136001, delta_positive=20.0, time=datetime.datetime(2024, 6, 3, 11, 59, 59), time_positive='2024-06-03T05:59:59 ', last_month_ratio=0.10058899318976625, last_week_avg=84.34820036519999, last_year_this_month_ratio=0.5679889139095791, delta=0.0, this_month=245.2862337492, week_ratio=0.9263904725706325, weeks_updated='2024-06-03T07:45:34 ', last_year_this_month=431.8503895804, last_week=590.4374025563999, this_week_avg=78.1393691968), hardware_version=' ', connector_type='Unspecified ', model='DISPLACE ', resolution=0.01) sensors=None utility=Utility(fluid_barrel_billing_unit='FLUID_BARREL ', cm_billing_unit='CM ', cf_billingunit='CF1 ', type='NORMAL ', utility_name='REDACTED', eow_service_selector='LOCATION_STATE ', gas_cf_billing_unit='CF ', eow_type='CLASSIC_BRANDED ', oil_barrel_billing_unit='OIL_BARREL ', date_created='2014-04-16T14:31:01 ', gal_billing_unit='G1 ', gas_cm_billing_unit='CM ', utility_uuid='REDACTED ', imp_billing_unit='Imp1') updated=4175 last_updated='2024-06-03T14:51:05.474Z' service=Service(class_code_normalized='SingleFamilyResidential ', route='309 ', active=True, class_code='SingleFamily ', service_type='W ', service_id='1 ', start_date=datetime.datetime(2023, 9, 21, 6, 59, 59), service_point_uuid='REDACTED ', cycle='003') location=Location(city='REDACTED ', parcel_number=' ', location_name='REDACTED ', parity='O ', country='US ', route='309 ', geocode_status=2, zip_code='REDACTED ', longitude='REDACTED ', display_address_3=' ', state='REDACTED ', location_uuid='REDACTED ', county_name=' ', latitude=REDACTED ', display_address_2=' ', location_id='REDACTED ', display_address='REDACTED', display_street_name=' ', cycle='003') alerts=Alerts(leak_alert=LeakAlert(alert_type='CONTINUOUS_FLOW ', name='Continuous flow ', residential_user_name='REDACTED', date_updated=None, alert_uuid='REDACTED ', state='active ', date_created='2023-12-07T16:32:59 ', creator_user_uuid='REDACTED')) account=AccountInfo(status=' ', first_name='REDACTED ', billing_address='REDACTED ', billing_city='REDACTED ', account_uuid='REDACTED ', billing_address_2=' ', full_name='REDACTED ', email=' ', phone=' ', portal_status=' ', last_name='REDACTED ', account_id='REDACTED ', class_code='SingleFamily ', billing_address_3=' ', person_id=' ', date_created='REDACTED ', account_billing_cycle=' ', billing_zip_code='REDACTED ', billing_country='USA ', billing_state='REDACTED ', eyeonwater='Yes') meter=MeterData(sensors_available=None, has_endpoint=True, install_date=datetime.datetime(2019, 7, 16, 6, 59, 59), meter_uuid='REDACTED ', fluid_type='Water ', timezone='US/Pacific ', firmware_version=None, communication_security='Unknown ', meter_size_unit='INCHES ', cell_type='NA ', geocode_status=2, geo='REDACTED ', last_read_time=datetime.datetime(2024, 6, 3, 11, 59, 59), note='2nsll2eec (VAC 4-2023) ', battery=None, endpoint_status='Active ', alert_code=0, gas_pressure_compensation=1.0, service_type='W ', serialnumber='REDACTED ', type='W ', pwr=None, endpoint_connector='Unspecified ', communication_seconds=3600, meter_size_desc='1" ', is_compound='No ', latitude='REDACTED ', typical_read_method='Network ', endpoint_type='ORION Fixed Network ', meter_id='REDACTED ', last_communication_time=datetime.datetime(2024, 6, 3, 13, 23, 27), pit_type='Unspecified ', meter_spec_uuid='REDACTED ', manufacturer='BAD ', has_valve=False, has_sensor=False, gas_sub_count=1, notes=Notes(count=0), meter_size=1.0, flow=Flow(this_week=546.9755843776001, months_updated='2024-06-03T10:51:04.129331-04:00 ', last_month=2438.4997400904, last_year_last_month_ratio=0.2880864522930943, last_year_last_month=851.4327272136001, delta_positive=20.0, time=datetime.datetime(2024, 6, 3, 11, 59, 59), time_positive='2024-06-03T05:59:59 ', last_month_ratio=0.10058899318976625, last_week_avg=84.34820036519999, last_year_this_month_ratio=0.5679889139095791, delta=0.0, this_month=245.2862337492, week_ratio=0.9263904725706325, weeks_updated='2024-06-03T07:45:34 ', last_year_this_month=431.8503895804, last_week=590.4374025563999, this_week_avg=78.1393691968), longitude='-121.447513 ', flags=ActiveFlags(active_flags=[], time=datetime.datetime(2024, 6, 3, 12, 0)), model='DISPLACE ', sequence_number=4600) service_agreement=ServiceAgreement(service_agreement_uuid='REDACTED ', start_date=datetime.datetime(2023, 9, 21, 6, 59, 59)) version='2' user=User(user_uuid='REDACTED ', user_name='REDACTED ', date_created='2023-12-07T16:31:10') groups=Groups(irrigation='No ', continuous_flow='No ', is_irrigatable='No ', disable_valve_shutoff='No') Meter reading: DataPoint(dt=datetime.datetime(2024, 6, 3, 11, 59, 59), reading=43072.3, unit=<NativeUnits.CF: 'cf'>) Historical data: 2024-06-01 00:00:00-07:00 43039.51 NativeUnits.CF Historical data: 2024-06-01 01:00:00-07:00 43039.51 NativeUnits.CF Historical data: 2024-06-01 02:00:00-07:00 43039.51 NativeUnits.CF Historical data: 2024-06-01 03:00:00-07:00 43039.69 NativeUnits.CF Historical data: 2024-06-01 04:00:00-07:00 43039.69 NativeUnits.CF Historical data: 2024-06-01 05:00:00-07:00 43039.69 NativeUnits.CF Historical data: 2024-06-01 06:00:00-07:00 43039.69 NativeUnits.CF Historical data: 2024-06-01 07:00:00-07:00 43040.16 NativeUnits.CF Historical data: 2024-06-01 08:00:00-07:00 43040.66 NativeUnits.CF Historical data: 2024-06-01 09:00:00-07:00 43040.68 NativeUnits.CF Historical data: 2024-06-01 10:00:00-07:00 43043.99 NativeUnits.CF Historical data: 2024-06-01 11:00:00-07:00 43044.75 NativeUnits.CF Historical data: 2024-06-01 12:00:00-07:00 43045.69 NativeUnits.CF Historical data: 2024-06-01 13:00:00-07:00 43045.69 NativeUnits.CF Historical data: 2024-06-01 14:00:00-07:00 43048.01 NativeUnits.CF Historical data: 2024-06-01 15:00:00-07:00 43049.05 NativeUnits.CF Historical data: 2024-06-01 16:00:00-07:00 43049.28 NativeUnits.CF Historical data: 2024-06-01 17:00:00-07:00 43049.63 NativeUnits.CF Historical data: 2024-06-01 18:00:00-07:00 43049.63 NativeUnits.CF Historical data: 2024-06-01 19:00:00-07:00 43049.86 NativeUnits.CF Historical data: 2024-06-01 20:00:00-07:00 43049.89 NativeUnits.CF Historical data: 2024-06-01 21:00:00-07:00 43050.57 NativeUnits.CF Historical data: 2024-06-01 22:00:00-07:00 43050.98 NativeUnits.CF Historical data: 2024-06-01 23:00:00-07:00 43050.98 NativeUnits.CF Historical data: 2024-06-02 00:00:00-07:00 43050.98 NativeUnits.CF Historical data: 2024-06-02 01:00:00-07:00 43050.98 NativeUnits.CF Historical data: 2024-06-02 02:00:00-07:00 43050.98 NativeUnits.CF Historical data: 2024-06-02 03:00:00-07:00 43050.98 NativeUnits.CF Historical data: 2024-06-02 04:00:00-07:00 43050.98 NativeUnits.CF Historical data: 2024-06-02 05:00:00-07:00 43050.98 NativeUnits.CF Historical data: 2024-06-02 06:00:00-07:00 43051.18 NativeUnits.CF Historical data: 2024-06-02 07:00:00-07:00 43052.01 NativeUnits.CF Historical data: 2024-06-02 08:00:00-07:00 43052.06 NativeUnits.CF Historical data: 2024-06-02 09:00:00-07:00 43060.64 NativeUnits.CF Historical data: 2024-06-02 10:00:00-07:00 43062.2 NativeUnits.CF Historical data: 2024-06-02 11:00:00-07:00 43063.03 NativeUnits.CF Historical data: 2024-06-02 12:00:00-07:00 43065.92 NativeUnits.CF Historical data: 2024-06-02 13:00:00-07:00 43065.92 NativeUnits.CF Historical data: 2024-06-02 14:00:00-07:00 43069.28 NativeUnits.CF Historical data: 2024-06-02 15:00:00-07:00 43069.28 NativeUnits.CF Historical data: 2024-06-02 16:00:00-07:00 43069.9 NativeUnits.CF Historical data: 2024-06-02 17:00:00-07:00 43070.57 NativeUnits.CF Historical data: 2024-06-02 18:00:00-07:00 43070.83 NativeUnits.CF Historical data: 2024-06-02 19:00:00-07:00 43071.48 NativeUnits.CF Historical data: 2024-06-02 20:00:00-07:00 43071.7 NativeUnits.CF Historical data: 2024-06-02 21:00:00-07:00 43072.1 NativeUnits.CF Historical data: 2024-06-02 22:00:00-07:00 43072.3 NativeUnits.CF Historical data: 2024-06-02 23:00:00-07:00 43072.3 NativeUnits.CF Historical data: 2024-06-03 00:00:00-07:00 43072.3 NativeUnits.CF Historical data: 2024-06-03 01:00:00-07:00 43072.3 NativeUnits.CF Historical data: 2024-06-03 02:00:00-07:00 43072.3 NativeUnits.CF Historical data: 2024-06-03 03:00:00-07:00 43072.3 NativeUnits.CF Historical data: 2024-06-03 04:00:00-07:00 43072.3 NativeUnits.CF

kdeyev commented 4 months ago

@zackaryssmith I cannot spot any problem: the output looks as expected. I still suspect that it's may be something odd with the meter UUID:

homeassistant.exceptions.HomeAssistantError: Invalid statistic_id

Could you please check if it includes spaces or any special symbols? My meter UUID looks like: '200010106', and the meter sensor id: 'sensor.water_meter_200010106', statistic id: 'water_meter_200010106_statistic'.

zackaryssmith commented 4 months ago

@kdeyev When I run the example.py, I get a meter_uuid='19 digit number'.

My water meter name in home assistant looks like "Water Meter 200010106+2019-07-15" with a entry ID of "sensor.water_meter_200010106_2019_07_15_2 "

The statistic entry name is "Water Meter 200010106+2019-07-15" with a entity ID of "sensor.water_meter_200010106_2019_07_15"

kdeyev commented 4 months ago

@zackaryssmith It seems that HA takes care of the special symbols. I can try to normalize the UUID by replacing '+' and '-' but '_', but I'm not really sure that it's the problem. BTW, for energy dashboard you need to use an entity with '_statistic' suffix.

zackaryssmith commented 4 months ago

@kdeyev No worries, seems like it is specific to my meter/ install for now. Thank you for taking the time to look into it, I appreciate it.

kdeyev commented 3 months ago

@zackaryssmith please try this one: https://github.com/kdeyev/eyeonwater/releases/tag/v2.5.8-beta.4 It's prerelease version, so you may need to check "show beta" checkbox: https://hacs.xyz/docs/faq/select_version/

zackaryssmith commented 3 months ago

@kdeyev No luck. Statistic sensor still shows as unavailable.

From the debug log when reloading the service:

      2024-06-10 16:34:44.598 DEBUG (MainThread) [custom_components.eyeonwater.coordinator] Discovered 1 meter(s)
      2024-06-10 16:34:44.599 DEBUG (MainThread) [custom_components.eyeonwater] Fetching latest data
      2024-06-10 16:34:44.603 DEBUG (MainThread) [custom_components.eyeonwater.statistic_helper] last_stats {}
      2024-06-10 16:34:44.604 ERROR (MainThread) [homeassistant.components.sensor] Error adding entity sensor.water_meter_123456_2019_07_15_temperature for domain sensor with platform eyeonwater
      Traceback (most recent call last):
        File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 600, in _async_add_entities
          await coro
        File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 914, in _async_add_entity
          await entity.add_to_platform_finish()
        File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1355, in add_to_platform_finish
          self.async_write_ha_state()
        File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1000, in async_write_ha_state
          self._async_write_ha_state()
        File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1126, in _async_write_ha_state
          state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1061, in __async_calculate_state
          state = self._stringify_state(available)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in _stringify_state
          if (state := self.state) is None:
                       ^^^^^^^^^^
        File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 543, in state
          value = self.native_value
                  ^^^^^^^^^^^^^^^^^
        File "/config/custom_components/eyeonwater/sensor.py", line 194, in native_value
          return self.meter.meter_info.sensors.endpoint_temperature.seven_day_min
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      AttributeError: 'NoneType' object has no attribute 'endpoint_temperature'
      2024-06-10 16:34:45.234 DEBUG (MainThread) [custom_components.eyeonwater] Finished fetching EyeOnWater data in 0.635 seconds (success: True)
      2024-06-10 16:34:45.235 DEBUG (MainThread) [custom_components.eyeonwater.statistic_helper] last_imported_time None - data 2024-06-10 10:00:00-07:00
      2024-06-10 16:34:45.235 INFO (MainThread) [custom_components.eyeonwater.statistic_helper] 59 data points found
      2024-06-10 16:34:45.235 INFO (MainThread) [custom_components.eyeonwater.sensor] 59 data points will be imported
      2024-06-10 16:34:45.235 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
      Traceback (most recent call last):
        File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 288, in async_refresh
          await self._async_refresh(log_failures=True)
        File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 411, in _async_refresh
          self.async_update_listeners()
        File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 165, in async_update_listeners
          update_callback()
        File "/config/custom_components/eyeonwater/sensor.py", line 133, in _state_update
          self.import_historical_data()
        File "/config/custom_components/eyeonwater/sensor.py", line 160, in import_historical_data
          async_import_statistics(self.hass, metadata, statistics)
        File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 2235, in async_import_statistics
          raise HomeAssistantError("Invalid statistic_id")
      homeassistant.exceptions.HomeAssistantError: Invalid statistic_id

From the System Logs:

      Logger: homeassistant
      Source: components/recorder/statistics.py:2235
      First occurred: June 8, 2024 at 2:22:09 PM (202 occurrences)
      Last logged: 4:34:45 PM
      Error doing job: Task exception was never retrieved (None)

      Traceback (most recent call last):
        File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 255, in _handle_refresh_interval
          await self._async_refresh(log_failures=True, scheduled=True)
        File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 411, in _async_refresh
          self.async_update_listeners()
        File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 165, in async_update_listeners
          update_callback()
        File "/config/custom_components/eyeonwater/sensor.py", line 133, in _state_update
          self.import_historical_data()
        File "/config/custom_components/eyeonwater/sensor.py", line 160, in import_historical_data
          async_import_statistics(self.hass, metadata, statistics)
        File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 2235, in async_import_statistics
          raise HomeAssistantError("Invalid statistic_id")
      homeassistant.exceptions.HomeAssistantError: Invalid statistic_id

And the temp sensor log, which I believe is expected:

      Logger: homeassistant.components.sensor
      Source: helpers/entity_platform.py:600
      integration: Sensor (documentation, issues)
      First occurred: June 8, 2024 at 2:07:08 PM (2 occurrences)
      Last logged: 4:34:44 PM
      Error adding entity sensor.water_meter_123456_2019_07_15_temperature for domain sensor with platform eyeonwater

      Traceback (most recent call last):
        File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 600, in _async_add_entities
          await coro
        File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 914, in _async_add_entity
          await entity.add_to_platform_finish()
        File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1355, in add_to_platform_finish
          self.async_write_ha_state()
        File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1000, in async_write_ha_state
          self._async_write_ha_state()
        File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1126, in _async_write_ha_state
          state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1061, in __async_calculate_state
          state = self._stringify_state(available)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in _stringify_state
          if (state := self.state) is None:
                       ^^^^^^^^^^
        File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 543, in state
          value = self.native_value
                  ^^^^^^^^^^^^^^^^^
        File "/config/custom_components/eyeonwater/sensor.py", line 194, in native_value
          return self.meter.meter_info.sensors.endpoint_temperature.seven_day_min
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      AttributeError: 'NoneType' object has no attribute 'endpoint_temperature'
hrana commented 3 months ago

Popping in here to state that my meter is named in the same format and I am having the same issue with custom integration. Let me know if there is a faster way to help debug and any additional info you require.

kdeyev commented 3 months ago

@zackaryssmith sorry for the delay. @hrana welcome to the thread. I've looked how HA core verifies the ids and added similar check in the integration:

    if not valid_entity_id(statistic_id):
        raise Exception("Invalid statistic_id {statistic_id} for meter {meter.meter_id}")

Please try this one: https://github.com/kdeyev/eyeonwater/releases/tag/v2.5.8-beta.7

zackaryssmith commented 3 months ago

@kdeyev It is pulling data when on beta 7.

I get this in the debug log but I don't see anything failing, I even get historical stats. Thank you for all the trouble you've gone through on this.


2024-06-25 09:22:54.797 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open inside the event loop by custom integration 'eyeonwater' at custom_components/eyeonwater/coordinator.py, line 43: await meter.read_historical_data( (offender: /usr/local/lib/python3.12/site-packages/pytz/__init__.py, line 108: return open(filename, 'rb')), please report it to the author of the 'eyeonwater' custom integration
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 288, in async_refresh
    await self._async_refresh(log_failures=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 268, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/eyeonwater/__init__.py", line 52, in async_update_data
    await eye_on_water_data.read_meters(days_to_load=3)
  File "/config/custom_components/eyeonwater/coordinator.py", line 43, in read_meters
    await meter.read_historical_data(
hrana commented 3 months ago

@kdeyev Amazing! It's pulling data for me as well. Thank you again so so so much for providing the support.

@zackaryssmith I am seeing similar errors in my logs but, like yours, mine is working.

kdeyev commented 3 months ago

fixed in https://github.com/kdeyev/eyeonwater/releases/tag/v2.5.7