Cereal2nd / velbus-aio

Velbus Asyncio
Apache License 2.0
14 stars 10 forks source link

handle unknown channels #68

Closed Cereal2nd closed 1 year ago

Cereal2nd commented 1 year ago

In case we do not find the channel, make sure we catch the key-error and throw a nice error message

found via: home-assistant/core#82857

2022-11-30 19:07:25.025 DEBUG (MainThread) [velbus-protocol] RX: RawMessage(priority=fb, address=71, rtr=False, command=245, data=b'f5 10')
2022-11-30 19:07:25.025 DEBUG (MainThread) [velbus-packet] Received {"name": "ClearLedMessage", "priority": 251, "address": 113, "rtr": false, "data": "", "leds": [5]}
2022-11-30 19:07:25.026 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/velbusaio/protocol.py", line 169, in _process_message
    await self._message_received_callback(msg)
  File "/usr/local/lib/python3.10/site-packages/velbusaio/controller.py", line 55, in _on_message_received
    await self._handler.handle(msg)
  File "/usr/local/lib/python3.10/site-packages/velbusaio/handler.py", line 96, in handle
    await (self._velbus.get_module(msg.address)).on_message(msg)
  File "/usr/local/lib/python3.10/site-packages/velbusaio/module.py", line 394, in on_message
    await self._channels[channel].update({"led_state": "off"})
KeyError: 13