home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.14k stars 29.82k forks source link

ovo_energy - errors on startup #38805

Closed RogerSelwyn closed 4 years ago

RogerSelwyn commented 4 years ago

The problem

I've added the ovo_energy integration via the UI. It has successfully created the Integration card but how's now devices or entities. There are errors (shown below) in the configuration logs.

Environment

Problem-relevant configuration.yaml

Screenshot 2020-08-12 at 19 09 30

Traceback/Error logs

2020-08-12 19:01:55 ERROR (MainThread) [homeassistant.components.ovo_energy] Unexpected error fetching sensor data: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 143, in async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 131, in _async_update_data
    return await self.update_method()
  File "/usr/src/homeassistant/homeassistant/components/ovo_energy/__init__.py", line 43, in async_update_data
    return await client.get_daily_usage(now.strftime("%Y-%m"))
  File "/usr/local/lib/python3.8/site-packages/ovoenergy/ovoenergy.py", line 100, in get_daily_usage
    if "data" in gas:
TypeError: argument of type 'NoneType' is not iterable
2020-08-12 19:01:55 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up ovo_energy platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 184, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/ovo_energy/sensor.py", line 30, in async_setup_entry
    currency = coordinator.data.electricity[
AttributeError: 'NoneType' object has no attribute 'electricity'

Additional information

The account is electricity only, but is dual tariff (Economy 7).

RogerSelwyn commented 4 years ago

I'll try to see if I can look at doing some debugging tomorrow. I also notice when creating the integration that the username and password aren't translated properly.

Screenshot 2020-08-12 at 19 13 16
genericnerd99 commented 4 years ago

Hi - im also seeing same issue, added fine and shows my OVO account number but then nothing further, i also saw the same usr/pwd translations common::config_flow as per the screenshot above.

seeing the below in logs:

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 184, in _async_setup_platform await asyncio.shield(task) File "/usr/src/homeassistant/homeassistant/components/ovo_energy/sensor.py", line 30, in async_setup_entry currency = coordinator.data.electricity[ IndexError: list index out of range

Running Ubuntu 20 LTS, really grateful for the dev on this thank you!

RogerSelwyn commented 4 years ago

PR created here for my error - https://github.com/timmo001/ovoenergy/pull/6

probot-home-assistant[bot] commented 4 years ago

Hey there @timmo001, mind taking a look at this issue as its been labeled with an integration (ovo_energy) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

MartinHjelmare commented 4 years ago

Does https://github.com/home-assistant/core/pull/38835 fix this issue?

timmo001 commented 4 years ago

PR created here for my error - https://github.com/timmo001/ovoenergy/pull/6

I believe https://github.com/home-assistant/core/pull/38835 may have already fixed your issue

RogerSelwyn commented 4 years ago

PR created here for my error - timmo001/ovoenergy#6

I believe #38835 may have already fixed your issue

@timmo001 you will need to release a new version of the ovoenergy module, and then bump the version in the integration. I posted a PR against that as well.

timmo001 commented 4 years ago

The PR you have created I believe is already covered by line 98. The above PR should handle no gas or electricity data in the integration

RogerSelwyn commented 4 years ago

The PR you have created I believe is already covered by line 98. The above PR should handle no gas or electricity data in the integration

Sorry, no - this is a separate issue where there module errors when the gas data is None

RogerSelwyn commented 4 years ago

@timmo001 - I've updated my dev with your recent PR which has been merged. I'm afraid the ovoenergy module is still erroring at line 100. This is the stack trace from my log.

2020-08-14 13:43:12 ERROR (MainThread) [homeassistant.components.ovo_energy] Unexpected error fetching sensor data: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
  File "/workspaces/home-assistant/homeassistant/helpers/update_coordinator.py", line 143, in async_refresh
    self.data = await self._async_update_data()
  File "/workspaces/home-assistant/homeassistant/helpers/update_coordinator.py", line 131, in _async_update_data
    return await self.update_method()
  File "/workspaces/home-assistant/homeassistant/components/ovo_energy/__init__.py", line 47, in async_update_data
    return await client.get_daily_usage(now.strftime("%Y-%m"))
  File "/usr/local/lib/python3.8/site-packages/ovoenergy/ovoenergy.py", line 100, in get_daily_usage
    if "data" in gas:
TypeError: argument of type 'NoneType' is not iterable
timmo001 commented 4 years ago

OK, I'll merge that PR and release a package update

MitchHA commented 4 years ago

Hiya.

Would it be possible to add the ovoenergy export readings? On my meter, I need to press button 9 then find the export. I receive a total at the end of the month on my bill. Is this a possibility?

Thank you for the integration.

Mitch

RogerSelwyn commented 4 years ago

From what I can see this is the data available for electricity from OVO on a daily basis.

{'consumption': 10, 'cost': {'amount': '1.65', 'currencyUnit': 'GBP'}, 'hasHhData': True, 'interval': {'end': '2020-08-01T23:59:59.999', 'start': '2020-08-01T00:00:00.000'}, 'meterReadings': {'end': 3848.75, 'start': 3838.75}}

MartinHjelmare commented 4 years ago

Please don't use closed issues for feature requests or non related discussion.

If you want to suggest an enhancement please open a feature request in the Feature Requests section of our community forum.

Thanks!