Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range #134

Open
kridgo opened this issue Jul 29, 2022 · 1 comment
Open

IndexError: list index out of range #134

kridgo opened this issue Jul 29, 2022 · 1 comment

Comments

@kridgo
Copy link

kridgo commented Jul 29, 2022

Hi,

I am using the enocean integration in Home Assistant, wich has been running fine for over a month. Out of a sudden, it chrashed on parsing an incoming packet as you can see in the log output underneath. After a restart of Home Assistant, the integration is operating normal again. It seems like the incoming packet was malformed or something so that the DB6.BIT_7 bit could not be accessed.
Maybe some form of exception handling could be used to drop packets in such cases instead of the integration crashing?

Thanks in advance and best regards

The Home Assistant Log Output looks like this: (I removed the sender ID)

2022-07-19 15:42:57 DEBUG (Thread-3) [homeassistant.components.enocean.dongle] Received radio packet: xx:xx:xx:xx->FF:FF:FF:FF (-73 dBm): 0x01 ['0xd5', '0x9', '0x0', '0x1', '0x98', '0xb6', '0x0'] ['0x0', '0xff', '0xff', '0xff', '0xff', '0x49', '0x0'] OrderedDict()
2022-07-19 15:42:57 ERROR (Thread-3) [root] Uncaught thread exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.9/site-packages/enocean/communicators/serialcommunicator.py", line 39, in run
    self.parse()
  File "/usr/local/lib/python3.9/site-packages/enocean/communicators/communicator.py", line 63, in parse
    status, self._buffer, packet = Packet.parse_msg(self._buffer, communicator=self)
  File "/usr/local/lib/python3.9/site-packages/enocean/protocol/packet.py", line 147, in parse_msg
    packet = UTETeachIn(packet_type, data, opt_data, communicator=communicator)
  File "/usr/local/lib/python3.9/site-packages/enocean/protocol/packet.py", line 372, in __init__
    super(UTETeachIn, self).__init__(packet_type=packet_type, data=data, optional=optional)
  File "/usr/local/lib/python3.9/site-packages/enocean/protocol/packet.py", line 46, in __init__
    self.parse()
  File "/usr/local/lib/python3.9/site-packages/enocean/protocol/packet.py", line 388, in parse
    self.unidirectional = not self._bit_data[DB6.BIT_7]
IndexError: list index out of range
@kridgo
Copy link
Author

kridgo commented Dec 30, 2022

Added an exception handler to fix the issue in #138

mak-gitdev added a commit to mak-gitdev/enocean that referenced this issue Jun 4, 2023
Apply patch from @kridgo.
See kipe#134 and kipe#138 for more details.
mak-gitdev added a commit to mak-gitdev/HA_enoceanmqtt that referenced this issue Jun 5, 2023
- Latest enocean-mqtt version which fixes status bits setting (see #65 and embyt/enocean-mqtt#41 for more details)
- From now, use mak-gitdev/enocean as Python EnOcean Library which fixes "list index out of range error" thanks to @kridgo patch (see kipe/enocean#134 and kipe/enocean#138 for more details).
- Add virtual A5-10-06 (#46)
- Add '%' as unit of measurement for A5-20-01 current value field (#53)
- Update F6-02-[01-02] mapping to send status bits thanks to @LarsKoeppel.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant