kukulich/home-assistant-jablotron100

Read error: 'device_4'

Closed this issue · 5 comments

Hello,
I dont have anything connected to device_4 (the output is blocked in the Jablotron app), however the integration tries to read data from this device and therefore my log is spammed with:
Logger: custom_components.jablotron100 Source: custom_components/jablotron100/jablotron.py:1027 Integration: Jablotron 100 ([documentation](https://github.com/kukulich/home-assistant-jablotron100), [issues](https://github.com/kukulich/home-assistant-jablotron100/issues)) First occurred: 17:57:40 (13 occurrences) Last logged: 19:40:05 Read error: 'device_4'

Also it means that all the sensors are often marked as "unavaiable" for a few seconds, potencially triggering automations. Is it possible to fix this please?

Please try to find the complete log.

Hi, I tried the get enable the diagnostics and I got following stacktrack - is this what you mean?

2023-01-29 20:52:01.003 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 81, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/diagnostics/init.py", line 245, in get
data = await info.config_entry_diagnostics(hass, config_entry)
File "/config/custom_components/jablotron100/diagnostics.py", line 26, in async_get_config_entry_diagnostics
"section": jablotron_instance.get_device_section(device_number),
File "/config/custom_components/jablotron100/jablotron.py", line 1148, in get_device_section
return self._devices_data[device_id][DeviceData.SECTION]
KeyError: 'device_4'

I'm sorry, I dont know anything about programming for HA, however I added a new log so it logs whole exception and I got this:

Traceback (most recent call last):
File "/config/custom_components/jablotron100/jablotron.py", line 1014, in _read_packets
self._parse_device_info_packet(packet)
File "/config/custom_components/jablotron100/jablotron.py", line 1399, in _parse_device_info_packet
self._add_battery_to_device(device_number, device_battery_state)
File "/config/custom_components/jablotron100/jablotron.py", line 1941, in _add_battery_to_device
self._devices_data[device_id][DeviceData.BATTERY] = True
KeyError: 'device_4'

I went through the code and is it possible that the Jablotron unit is somehow sending info about device 4 although it's blocked and according to the technician there is nothing connected to it? I marked it as "Empty" in the JA100 integration, however it seems that the integration is not ignoring the device as it should, instead it tries to save the device info into a dictionary which is not present because the device should be Empty?

Just an idea :-)

Please try version master. I think I've just fixed it.