Habapp 24.11- AssertionError: <class 'bytes'>

I’ve been having some problems with this, keeps happening now and then and I’m not sure what the problem really is. The icon image, “localCurrentConditionIcon”, is a low-res/small image or icon updated by the openweather binding, and should (afaik) not make much of a problem?
I’ve increased the connection buffer to 512kb to see if that helped but it still happens :thinking:

[2024-12-26 10:34:55,475] [                   HABApp]    ERROR | Error <class 'bytes'> in on_connected:
[2024-12-26 10:34:55,475] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.11/site-packages/HABApp/openhab/connection/plugins/load_items.py", line 40 in on_connected
[2024-12-26 10:34:55,475] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2024-12-26 10:34:55,475] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2024-12-26 10:34:55,475] [                   HABApp]    ERROR |      log = <Logger HABApp.openhab.items (INFO)>
[2024-12-26 10:34:55,475] [                   HABApp]    ERROR |      range(6) = range(0, 6)
[2024-12-26 10:34:55,475] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2024-12-26 10:34:55,475] [                   HABApp]    ERROR |
[2024-12-26 10:34:55,475] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.11/site-packages/HABApp/openhab/connection/plugins/load_items.py", line 90 in load_items
[2024-12-26 10:34:55,475] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR |       (...)
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR |      87 |         # error
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR |      88 |         if new_item is None:
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR |      89 |             continue
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR | -->  90 |         add_to_registry(new_item, True)
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR |      92 |     # remove items which are no longer available
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR |      frozenset(item.groups) = frozenset()
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR |      frozenset(item.tags) = frozenset()
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR |      item.label = 'Icon'
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR |      item.metadata = {}
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR |      item.name = 'localCurrentConditionIcon'
[2024-12-26 10:34:55,476] [                   HABApp]    ERROR |      item.type = 'Image'
[2024-12-26 10:34:55,477] [                   HABApp]    ERROR |      items_len = 792
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      len(items) = 792
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      log = <Logger HABApp.openhab.items (INFO)>
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.11/site-packages/HABApp/openhab/item_to_reg.py", line 41 in add_to_registry
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      29 | def add_to_registry(item: OpenhabItem, set_value=False):
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |       (...)
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      39 |         # If we load directly through the API and not through an event we have to set the value
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      40 |         if set_value:
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      43 |         # remove old groups
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      item.groups = frozenset()
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      item.label = 'Icon'
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      item.metadata = immutables.Map({})
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      item.tags = frozenset()
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      set(item.groups) = set()
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      log = <Logger HABApp.openhab.items (INFO)>
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      name = 'localCurrentConditionIcon'
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |      set_value = True
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR |
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.11/site-packages/HABApp/openhab/items/image_item.py", line 65 in set_value
[2024-12-26 10:34:55,478] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |      64 | def set_value(self, new_value) -> bool:
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR | -->  65 |     assert isinstance(new_value, RawValue) or new_value is None, type(new_value)
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |      67 |     if new_value is None:
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |      self.image_type = 'png'
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |      self.image_type[6:] = ''
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR | Traceback (most recent call last):
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.11/site-packages/HABApp/core/connections/base_connection.py", line 175, in _task_plugin
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.11/site-packages/HABApp/core/connections/plugin_callback.py", line 54, in run
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |     return await self.coro(**kwargs)
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |            ^^^^^^^^^^^^^^^^^^^^^^^^^
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.11/site-packages/HABApp/openhab/connection/plugins/load_items.py", line 40, in on_connected
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.11/site-packages/HABApp/openhab/connection/plugins/load_items.py", line 90, in load_items
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |     add_to_registry(new_item, True)
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.11/site-packages/HABApp/openhab/item_to_reg.py", line 41, in add_to_registry
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.11/site-packages/HABApp/openhab/items/image_item.py", line 65, in set_value
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |     assert isinstance(new_value, RawValue) or new_value is None, type(new_value)
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR |                                               ^^^^^^^^^^^^^^^^^
[2024-12-26 10:34:55,479] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>

Version: 24.11.1

This is most likely a bug :see_no_evil:
When does it happen? When you update the image or when the image is updated through the binding?

Ok, I’m not really sure but I will do some more debugging to figure out more details.
Not a big problem though just noticed it happens sometimes and wanted to see if anyone else has seen it and knew the reason :slight_smile:

I think this happens on (re-)connect. Does everything else work as expected?

Everything else seems fine but habapp restarts everytime 10 minute now.

Simple grep on the error message (for today):

[2025-01-26 06:45:19,665] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 06:55:19,819] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 07:05:19,976] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 07:15:20,142] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 07:25:20,297] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 07:35:20,453] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 07:45:20,687] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 07:55:20,849] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 08:05:21,005] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 08:15:21,159] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 08:25:21,325] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 08:35:21,481] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 08:45:21,636] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 08:55:21,871] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 09:05:22,033] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 09:15:22,200] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 09:25:22,365] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 09:35:22,532] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 09:45:22,697] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 09:55:22,861] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 10:05:23,022] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 10:15:23,263] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 10:25:23,428] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 10:35:23,592] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 10:45:23,759] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 10:55:23,922] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 11:05:24,094] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 11:15:24,256] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 11:25:24,499] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 11:35:24,666] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 11:45:24,829] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 11:55:24,992] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 12:05:25,152] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 12:15:25,314] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 12:25:25,567] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 12:35:25,730] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 12:45:25,980] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 12:55:26,153] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 13:05:26,321] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 13:15:26,489] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 13:25:26,655] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 13:35:26,818] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 13:45:26,981] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 13:55:27,158] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 14:05:27,406] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 14:15:27,582] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 14:25:27,756] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 14:35:27,921] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 14:45:28,085] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 14:55:28,251] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 15:05:28,411] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 15:15:28,648] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 15:25:28,810] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 15:35:28,964] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 15:45:29,118] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>
[2025-01-26 15:55:29,275] [                   HABApp]    ERROR | AssertionError: <class 'bytes'>

The item that is the cause of the error doesn’t change (but I’m not sure if its just updated with the same image/value and therefore not a “change”). Same log for changes, today:

2025-01-26 08:51:04.942 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'localCurrentConditionIcon' changed from raw type (image/png): 2565 bytes to raw type (image/png): 2773 bytes
2025-01-26 09:51:05.184 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'localCurrentConditionIcon' changed from raw type (image/png): 2773 bytes to raw type (image/png): 3901 bytes
2025-01-26 13:51:06.128 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'localCurrentConditionIcon' changed from raw type (image/png): 3901 bytes to raw type (image/png): 2773 bytes
1 Like

I guess you are not processing the image contents in HABApp, so as a quick workaround you can just edit the file and comment out the assertion.
I’ll provide a new HABApp version with a fix but since I’m sick at the moment it will take at least two weeks.

1 Like

Not on this system no (I do have another system though where I do update image data/item through a request.get and I get similar errors there aswell).

No worries, thanks for replying and get well soon!

Same here. habapp is producing traces on attempt to transfer an image of BMW car that BMW binding is exposing as car image. Waiting for a fix! Thanks!

I did a workaround for this while waiting for a fix, it worked for me atleast (so far):
Edit:
“/opt/habapp/lib/python3.11/site-packages/HABApp/openhab/items/image_item.py”
or wherever your image_item.py is and find “set_value”, somewhere around line 65

    def set_value(self, new_value) -> bool:
        #assert isinstance(new_value, RawValue) or new_value is None, type(new_value)

        if new_value is None:
            self.image_type = None
            return super().set_value(new_value)

        # image/png
        if hasattr(new_value, 'type'):
            self.image_type = new_value.type
        if self.image_type.startswith('image/'):
            self.image_type = self.image_type[6:]
        if hasattr(new_value, 'value'):
            return super().set_value(new_value.value)
        else:
            # bytes
            return super().set_value(new_value)
1 Like