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

KNX hub craches: APCI not supported #32394

Closed
bmsec opened this issue Mar 2, 2020 · 5 comments · Fixed by XKNX/xknx#271 or #35154
Closed

KNX hub craches: APCI not supported #32394

bmsec opened this issue Mar 2, 2020 · 5 comments · Fixed by XKNX/xknx#271 or #35154

Comments

@bmsec
Copy link

bmsec commented Mar 2, 2020

The problem

KNX integration crashes about once a week. I think it is upon the reception of a specific telegram.

Environment

  • Home Assistant release with the issue: 0.105.5
  • Last working Home Assistant release (if known):
  • Operating environment (Hass.io/Docker/Windows/etc.): Docker
  • Integration causing this issue: knx hub
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/knx/

Problem-relevant configuration.yaml

knx:

Traceback/Error logs

2020-02-29 10:05:07 ERROR (MainThread) [xknx.log] <CouldNotParseKNXIP description="APCI not supported: 0b1000011100000000" />
ValueError: 34560 is not a valid APCICommand

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/cemi_frame.py", line 147, in from_knx_data_link_layer
    self.cmd = APCICommand(tpci_apci & 0xFFC0)
  File "/usr/local/lib/python3.7/enum.py", line 310, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.7/enum.py", line 564, in __new__
    raise exc
  File "/usr/local/lib/python3.7/enum.py", line 548, in __new__
    result = cls._missing_(value)
  File "/usr/local/lib/python3.7/enum.py", line 577, in _missing_
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 34560 is not a valid APCICommand

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/xknx/io/udp_client.py", line 87, in data_received_callback
    knxipframe.from_knx(raw)
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/knxip.py", line 78, in from_knx
    pos += self.body.from_knx(data[pos:])
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/tunnelling_request.py", line 48, in from_knx
    pos += self.cemi.from_knx(raw[pos:])
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/cemi_frame.py", line 116, in from_knx
    return self.from_knx_data_link_layer(raw)
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/cemi_frame.py", line 150, in from_knx_data_link_layer
    "APCI not supported: {0:#012b}".format(tpci_apci & 0xFFC0))
xknx.exceptions.exception.CouldNotParseKNXIP: <CouldNotParseKNXIP description="APCI not supported: 0b1000011100000000" />
2020-02-29 10:05:08 ERROR (MainThread) [xknx.log] <CouldNotParseKNXIP description="APCI not supported: 0b1000011100000000" />
ValueError: 34560 is not a valid APCICommand

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/cemi_frame.py", line 147, in from_knx_data_link_layer
    self.cmd = APCICommand(tpci_apci & 0xFFC0)
  File "/usr/local/lib/python3.7/enum.py", line 310, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.7/enum.py", line 564, in __new__
    raise exc
  File "/usr/local/lib/python3.7/enum.py", line 548, in __new__
    result = cls._missing_(value)
  File "/usr/local/lib/python3.7/enum.py", line 577, in _missing_
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 34560 is not a valid APCICommand

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/xknx/io/udp_client.py", line 87, in data_received_callback
    knxipframe.from_knx(raw)
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/knxip.py", line 78, in from_knx
    pos += self.body.from_knx(data[pos:])
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/tunnelling_request.py", line 48, in from_knx
    pos += self.cemi.from_knx(raw[pos:])
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/cemi_frame.py", line 116, in from_knx
    return self.from_knx_data_link_layer(raw)
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/cemi_frame.py", line 150, in from_knx_data_link_layer
    "APCI not supported: {0:#012b}".format(tpci_apci & 0xFFC0))
xknx.exceptions.exception.CouldNotParseKNXIP: <CouldNotParseKNXIP description="APCI not supported: 0b1000011100000000" />

Additional information

The KNX/IP gateway used is Viessmann Vitogate 200 type KNX

Update:

It turns out that xknx raises exception in case of any telegram that can not be parsed. This is not necessarily an issue, but the problem is that after the exception, no more updates are received in home-assistant from KNX.
Not identical exception, but with the same result (no more KNX updates in Home-assistant) can be triggered by doing a Line Scan using ETS.

2020-03-02 13:48:50 ERROR (MainThread) [xknx.log] <CouldNotParseKNXIP description="CEMI too small" />
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/xknx/io/udp_client.py", line 87, in data_received_callback
    knxipframe.from_knx(raw)
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/knxip.py", line 78, in from_knx
    pos += self.body.from_knx(data[pos:])
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/tunnelling_request.py", line 48, in from_knx
    pos += self.cemi.from_knx(raw[pos:])
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/cemi_frame.py", line 116, in from_knx
    return self.from_knx_data_link_layer(raw)
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/cemi_frame.py", line 122, in from_knx_data_link_layer
    raise CouldNotParseKNXIP("CEMI too small")
xknx.exceptions.exception.CouldNotParseKNXIP: <CouldNotParseKNXIP description="CEMI too small" />
2020-03-02 13:48:51 ERROR (MainThread) [xknx.log] <CouldNotParseKNXIP description="CEMI too small" />
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/xknx/io/udp_client.py", line 87, in data_received_callback
    knxipframe.from_knx(raw)
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/knxip.py", line 78, in from_knx
    pos += self.body.from_knx(data[pos:])
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/tunnelling_request.py", line 48, in from_knx
    pos += self.cemi.from_knx(raw[pos:])
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/cemi_frame.py", line 116, in from_knx
    return self.from_knx_data_link_layer(raw)
  File "/usr/local/lib/python3.7/site-packages/xknx/knxip/cemi_frame.py", line 122, in from_knx_data_link_layer
    raise CouldNotParseKNXIP("CEMI too small")
xknx.exceptions.exception.CouldNotParseKNXIP: <CouldNotParseKNXIP description="CEMI too small" />
@probot-home-assistant
Copy link

Hey there @Julius2342, mind taking a look at this issue as its been labeled with a integration (knx) you are listed as a codeowner for? Thanks!

@Julius2342
Copy link
Contributor

@basilfx is working on an extension for xknx to handle all these exotic (-: packages:

XKNX/xknx#253

@bmsec
Copy link
Author

bmsec commented Mar 2, 2020

That is really good news! I an waiting for the release.
But until then, is it possible to make a quick and dirty patch so these "exotic" telegram would just be dropped, and the home-assitent would continue to work?

@esnil
Copy link

esnil commented Mar 7, 2020

Hi @bmsec
Did you find any temporary sollution to get past this issue? I experiensing the same situation and all I-ve come up with so far is to restart HomeAssistant..

@bmsec
Copy link
Author

bmsec commented Mar 7, 2020

I made a Quick and dirty.....highly dirty.
In my specific case the issue was this exact APCI: 0b1000011100000000 because this appeared randomly from time to time. All the other "exotic" packages only appear if I am working with ETS, and than I can restart home assistant.
So for APCI 0b1000011100000000 I changed the exception handling in cemi_frame.py, so it would consider this "exotic" ACPI a read telegram (substitute 0b1000011100000000 with 0b0000000000000000). I know that this is a highly dirty solution, but I do not understand the code sufficiently to make a more decent workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants