Iotawatt dropping data every few minutes (update: integration won't initialize)

Hi, several months ago my iotawatt power graphs started looking like the attached image, with gaps in the data every 10-20 minutes. I have not determined a pattern to the data loss.

Screenshot 2023-06-27 at 6.36.32 AM

When I use the graphing facility built in to the iotawatt, there are no gaps in the data. So the issue seems to be with the HA connection.

Is anyone else seeing this?
What else can I provide to help troubleshoot?

Home Assistant 2023.5.2
Supervisor 2023.06.2
Operating System 10.3
Frontend 20230503.3 - latest
Hardware is raspberry pi 4, connected via ethernet. The iotawatt is connected via wifi (with an eero repeater in the same room)

I just created a clean-slate, new installation of Home Assistant and the problem persists.

I found this in the logs

Logger: homeassistant.components.iotawatt.coordinator
Source: components/iotawatt/coordinator.py:76 
Integration: IoTaWatt (documentation, issues) 
First occurred: 6:58:35 AM (2 occurrences) 
Last logged: 6:59:55 AM

Unexpected error fetching 10.1.1.141 data:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/httpcore/backends/asyncio.py", line 34, in read
    return await self._stream.receive(max_bytes=max_bytes)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 1265, in receive
    await self._protocol.read_event.wait()
  File "/usr/local/lib/python3.11/asyncio/locks.py", line 213, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions
    yield
  File "/usr/local/lib/python3.11/site-packages/httpcore/backends/asyncio.py", line 32, in read
    with anyio.fail_after(timeout):
  File "/usr/local/lib/python3.11/site-packages/anyio/_core/_tasks.py", line 118, in __exit__
    raise TimeoutError
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 239, in __aiter__
    async for part in self._httpcore_stream:
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 338, in __aiter__
    async for part in self._stream:
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 319, in __aiter__
    raise exc
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 312, in __aiter__
    async for chunk in self._connection._receive_response_body(**kwargs):
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 181, in _receive_response_body
    event = await self._receive_event(timeout=timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 195, in _receive_event
    data = await self._network_stream.read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/backends/asyncio.py", line 31, in read
    with map_exceptions(exc_map):
  File "/usr/local/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc)
httpcore.ReadTimeout

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

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 "/usr/src/homeassistant/homeassistant/components/iotawatt/coordinator.py", line 76, in _async_update_data
    await self.api.update(lastUpdate=self._last_run)
  File "/usr/local/lib/python3.11/site-packages/iotawattpy/iotawatt.py", line 79, in update
    await self._refreshSensors(timespan, lastUpdate)
  File "/usr/local/lib/python3.11/site-packages/iotawattpy/iotawatt.py", line 264, in _refreshSensors
    response = await self._getQuerySelectSeriesIntegrate(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/iotawattpy/iotawatt.py", line 365, in _getQuerySelectSeriesIntegrate
    return await self._connection.get(url, self._username, self._password)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/iotawattpy/connection.py", line 18, in get
    return await self.__open(url, username=username, password=password)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/iotawattpy/connection.py", line 46, in __open
    raise e
  File "/usr/local/lib/python3.11/site-packages/iotawattpy/connection.py", line 37, in __open
    resp = await getattr(self._websession, method)(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1757, in get
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1530, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1631, in send
    raise exc
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1625, in send
    await response.aread()
  File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 909, in aread
    self._content = b"".join([part async for part in self.aiter_bytes()])
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 909, in <listcomp>
    self._content = b"".join([part async for part in self.aiter_bytes()])
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 927, in aiter_bytes
    async for raw_bytes in self.aiter_raw():
  File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 985, in aiter_raw
    async for raw_stream_bytes in self.stream:
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 146, in __aiter__
    async for chunk in self._stream:
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 238, in __aiter__
    with map_httpcore_exceptions():
  File "/usr/local/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ReadTimeout

Hello,
I’ve got the same problem from few months. Did you find the solution or some more info what could cause it?
Best regards,
Menuet88

No, I haven’t found a solution. In fact the situation gradually got much worse. I was eventually getting only one Iotawatt data point each 3-4 hours. I deleted the iotawatt integration and reinstalled it. Now I can’t even get the integration to initialize – same error as my first post.

I also posted in the iotawatt forum. Someone suggested downgrading HA core to 2023.3.1. I tried this but it didn’t help.

I am using the Iotawatt IP address for my Iotawatt integration – not iotawatt.local

I have also tried two forks of the iotawatt integration from github (kuralabs and gtdiehl). Neither one worked.

Now I disabled the iotawatt integration and have no solution :frowning: – I can only access Iotawatt through its web interface.

You should open a new issue here:

I had some lost data from my Iotawatt today, reloading the integration resulted in a failed setup. Restart of home assistant did not help, but restarting the Iotawatt and then reloading seems to have worked for me… just in case you haven’t tried restarting iotawatt before loading one of the integrations, maybe it’s worth trying. good luck!

Following up on my own issue:
I discovered that my iotawatt was in an endless reboot loop. Once I fixed this, the home assistant integration started working again. I don’t know if this was the problem all along – it’s hard for me to tell when the reboot loop started.

(The symptom of the reboot loop was that the iotawatt built-in grapher was very, very slow. When I checked the iotawatt logs I discovered it was rebooting constantly.)