Cereal2nd / velbus-aio

Velbus Asyncio
Apache License 2.0
14 stars 10 forks source link

pickle error on selectedprogram #69

Closed Cereal2nd closed 1 year ago

Cereal2nd commented 1 year ago
DEBUG:velbus-protocol:RX: RawMessage(priority=fb, address=19, rtr=False, command=255, data=b'ff 17 eb f1 00 18 22')
DEBUG:velbus-packet:Received {"name": "ModuleTypeMessage", "priority": 251, "address": 25, "rtr": false, "data": "", "module_type": 23, "led_on": [], "led_slow_blinking": [], "led_fast_blinking": [], "serial": 60401, "memory_map_version": 0, "build_year": 24, "build_week": 34}
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-12' coro=<VelbusProtocol._process_message() done, defined at /home/cereal/home-assistant/venv/lib/python3.9/site-packages/velbusaio/protocol.py:167> exception=AttributeError("Can't get attribute 'SelectedProgram' on <module 'velbusaio.channels' from '/home/cereal/home-assistant/venv/lib/python3.9/site-packages/velbusaio/channels.py'>")>
Traceback (most recent call last):
  File "/home/cereal/home-assistant/venv/lib/python3.9/site-packages/velbusaio/protocol.py", line 169, in _process_message
    await self._message_received_callback(msg)
  File "/home/cereal/home-assistant/venv/lib/python3.9/site-packages/velbusaio/controller.py", line 55, in _on_message_received
    await self._handler.handle(msg)
  File "/home/cereal/home-assistant/venv/lib/python3.9/site-packages/velbusaio/handler.py", line 66, in handle
    await self._handle_module_type(msg)
  File "/home/cereal/home-assistant/venv/lib/python3.9/site-packages/velbusaio/handler.py", line 179, in _handle_module_type
    await self._velbus.add_module(
  File "/home/cereal/home-assistant/venv/lib/python3.9/site-packages/velbusaio/controller.py", line 79, in add_module
    mod = self._load_module_from_cache(self._cache_dir, addr)
  File "/home/cereal/home-assistant/venv/lib/python3.9/site-packages/velbusaio/controller.py", line 113, in _load_module_from_cache
    return pickle.load(fl)
AttributeError: Can't get attribute 'SelectedProgram' on <module 'velbusaio.channels' from '/home/cereal/home-assistant/venv/lib/python3.9/site-packages/velbusaio/channels.py'>
Cereal2nd commented 1 year ago

@DannyDeGaspari this is something i see since the merge of #66

DannyDeGaspari commented 1 year ago

I'll try to reproduce it, did not get this error while testing. Maybe because I cleared the cache first?

Cereal2nd commented 1 year ago

nevermind indeed it was the cache ....

DannyDeGaspari commented 1 year ago

I'm afraid HA users will bump into the same issue. Is there something foreseen on the HA side that with breaking cache releases of velbus-aio, the cache needs to be cleared ?

Cereal2nd commented 1 year ago

no, we will have to implement this

and befor this is implemented we can not upgrade, so i have a lot of work on the hass side:

DannyDeGaspari commented 1 year ago

Let me know if I can be of any help with testing.

niobos commented 1 year ago

I've run into the same problem when developing. This is something that's on my "I'll need to fix this"-list, but haven't gotten around to. I think the best way to solve this is to move from pickle to our own (de)serializer (e.g. JSON?), where the deserializer takes care of the upgrade path.

@Cereal2nd Should this be a separate Issue specifically for "Make deserializer from cache backward compatible"? Or can we re-purpose this issue for that?

Cereal2nd commented 1 year ago

We can do whatever we want reuse this one or create a new one.

But we either fix this asap, or we continue to handle this on the Hass side. On the Hass side this change is minimal and I have this almost implemented

If we fix this on the velbusaio side we need to have a solution before we can upgrade Hass to this newer version.

niobos commented 1 year ago

I'll open a new issue, for the 'long term solution'; when and if we get around to that. Go ahead with the Hass-side fix.