gtdiehl / iotawatt_ha

IoTaWatt for Home Assistant
Apache License 2.0
16 stars 16 forks source link

iotawatt.py", line 81, in _createSensors AttributeError: 'NoneType' object has no attribute 'text' #7

Open kocsenc opened 3 years ago

kocsenc commented 3 years ago

Logger: custom_components.iotawatt Source: custom_components/iotawatt/init.py:106 Integration: iotawatt First occurred: August 2, 2021, 10:48:17 PM (2400 occurrences) Last logged: 6:52:41 PM Unexpected error fetching IoTaWatt data: 'NoneType' object has no attribute 'text'

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/iotawatt/__init__.py", line 106, in _async_update_data
    await self.api.update()
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 67, in update
    await self._createSensors()
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 81, in _createSensors
    results = response.text
AttributeError: 'NoneType' object has no attribute 'text'
gtdiehl commented 3 years ago

Does HA ever retrieve the data, are sensors created? Or is this a continuous error occurring every 30secs? Does restarting HA resolve the issue? What firmware is running on the IoTaWatt?

gtdiehl commented 3 years ago

It looks like this is an issue with the API. When I run example.py from iotawattpy repo, I run into this error. The example.py runs in a loop, and I saw it after a few minutes. Might have to add a retry on the API side?

gtdiehl commented 3 years ago

@kocsenc Can you open an issue under the iotawatt repo? Thanks!

kocsenc commented 3 years ago

Does HA ever retrieve the data, are sensors created?

Yes, sensors are created on a first config - and then on reboot it stops working and this issue starts happening.

What firmware is running on the IoTaWatt?

Firmware version: 02_06_05

@kocsenc Can you open an issue under the iotawatt repo? Thanks!

Done

OzGav commented 2 years ago

I am seeing similar:

Logger: custom_components.iotawatt.coordinator
Source: custom_components/iotawatt/coordinator.py:65
Integration: IoTaWatt
First occurred: 9:33:06 AM (3 occurrences)
Last logged: 9:56:26 AM

Unexpected error fetching 192.168.1.233 data: 'NoneType' object has no attribute 'text'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/iotawatt/coordinator.py", line 65, in _async_update_data
    await self.api.update(lastUpdate=self._last_run)
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 76, in update
    await self._refreshSensors(timespan, lastUpdate)
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 242, in _refreshSensors
    values = json.loads(response.text)
AttributeError: 'NoneType' object has no attribute 'text'
OzGav commented 2 years ago

and

Logger: custom_components.iotawatt.coordinator
Source: custom_components/iotawatt/coordinator.py:65
Integration: IoTaWatt
First occurred: 9:29:50 AM (10 occurrences)
Last logged: 9:55:38 AM

Unexpected error fetching 192.168.1.233 data: 'NoneType' object has no attribute 'text'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/iotawatt/coordinator.py", line 65, in _async_update_data
    await self.api.update(lastUpdate=self._last_run)
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 76, in update
    await self._refreshSensors(timespan, lastUpdate)
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 154, in _refreshSensors
    results = response.text
AttributeError: 'NoneType' object has no attribute 'text'

and

Logger: custom_components.iotawatt.coordinator
Source: custom_components/iotawatt/coordinator.py:65
Integration: IoTaWatt
First occurred: 9:46:44 AM (6 occurrences)
Last logged: 9:54:25 AM

Unexpected error fetching 192.168.1.233 data: 'NoneType' object has no attribute 'text'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/iotawatt/coordinator.py", line 65, in _async_update_data
    await self.api.update(lastUpdate=self._last_run)
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 76, in update
    await self._refreshSensors(timespan, lastUpdate)
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 161, in _refreshSensors
    query = query.text
AttributeError: 'NoneType' object has no attribute 'text'

and

Logger: custom_components.iotawatt.coordinator
Source: custom_components/iotawatt/coordinator.py:65
Integration: IoTaWatt
First occurred: 9:40:43 AM (2 occurrences)
Last logged: 9:51:21 AM

Unexpected error fetching 192.168.1.233 data: 'NoneType' object has no attribute 'text'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/iotawatt/coordinator.py", line 65, in _async_update_data
    await self.api.update(lastUpdate=self._last_run)
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 76, in update
    await self._refreshSensors(timespan, lastUpdate)
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 302, in _refreshSensors
    values = json.loads(response.text)
AttributeError: 'NoneType' object has no attribute 'text'
OzGav commented 2 years ago

Above for info will follow along in the iotawatt PR

jherby2k commented 2 years ago

Getting this also. Firmware version: 02_06_05

OzGav commented 2 years ago

For completeness also this one on HA startup: Logger: custom_components.iotawatt.coordinator Source: custom_components/iotawatt/coordinator.py:56 Integration: IoTaWatt

First occurred: 11:24:11 AM (1 occurrences)
Last logged: 11:24:11 AM

Unexpected error fetching 192.168.1.233 data: 'NoneType' object has no attribute 'status_code'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/iotawatt/coordinator.py", line 56, in _async_update_data
    is_authenticated = await api.connect()
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 48, in connect
    if results.status_code == httpx.codes.OK:
AttributeError: 'NoneType' object has no attribute 'status_code'