OpenEPaperLink / Home_Assistant_Integration

Home assistant Integration for the OpenEPaperLink project
https://openepaperlink.de
Apache License 2.0
159 stars 35 forks source link

Communication with newly added AP causes plugin crash #168

Closed 0xjmux closed 2 months ago

0xjmux commented 2 months ago

Describe the bug

I just installed the plugin, and added my AP by IP address. I can't seem to find any of my tags however, so I went to check the log and found this.

To Reproduce

Expected behavior I expected my tags to show up in the interface

Additional context

2024-09-21 23:35:36.777 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.ap_state fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/open_epaper_link/sensor.py", line 92, in update
self._attr_native_value = lut[self._hub.data["ap"]["apstate"]]
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'apstate'
2024-09-21 23:35:36.778 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.ap_run_state fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/open_epaper_link/sensor.py", line 106, in update
self._attr_native_value = lut[self._hub.data["ap"]["runstate"]]
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'runstate'
2024-09-21 23:35:36.779 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.ap_wifi_state fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/open_epaper_link/sensor.py", line 138, in update
self._attr_native_value = lut[self._hub.data["ap"]["wifistatus"]]
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: 'wifistatus'
2024-09-21 23:35:36.779 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.ap_wifi_ssid fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/open_epaper_link/sensor.py", line 151, in update
self._attr_native_value = self._hub.data["ap"]["wifissid"]
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'wifissid'
2024-09-21 23:36:06.771 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.ap_systime fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/open_epaper_link/sensor.py", line 165, in update
self._attr_native_value = datetime.datetime.fromtimestamp(self._hub.data["ap"]["systime"], datetime.timezone.utc)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object cannot be interpreted as an integer
2024-09-21 23:36:06.773 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.ap_free_heap fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/open_epaper_link/sensor.py", line 181, in update
self._attr_native_value = round(int(self._hub.data["ap"]["heap"]) / 1024,1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
0xjmux commented 2 months ago

Found the issue - I pasted the IP into the 'AP Address' field without manually removing thehttp://, and that caused the crash.

I still think that probably shouldn't cause a crash and it should just remove the protocol prefix, but feel free to close if that's not in the roadmap.