spacemanspiff2007 / HABApp

Easy home automation with MQTT and/or openHAB
Apache License 2.0
54 stars 23 forks source link

Investigate issue where traceback fails during removing of the event listener #447

Open spacemanspiff2007 opened 2 months ago

spacemanspiff2007 commented 2 months ago
2024-05-03 10:08:42.369 [ERROR] [HABApp.Rule] - File "/opt/habapp/lib/python3.11/site-packages/HABApp/core/internals/event_bus_listener.py", line 49 in describe
2024-05-03 10:08:42.369 [ERROR] [HABApp.Rule] - --------------------------------------------------------------------------------
2024-05-03 10:08:42.369 [ERROR] [HABApp.Rule] -      48 | def describe(self) -> str:
2024-05-03 10:08:42.369 [ERROR] [HABApp.Rule] - -->  49 |     return f'"{self.topic}" (filter={self.filter.describe()})'
2024-05-03 10:08:42.369 [ERROR] [HABApp.Rule] -    ------------------------------------------------------------
2024-05-03 10:08:42.369 [ERROR] [HABApp.Rule] -      self = <HABApp.core.internals.event_bus_listener.ContextBoundEventBusListener object at 0x7f2750327fd0>
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] - Error "__str__ returned non-string (type float)" in unload_rule:
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] - Error while formatting traceback: __str__ returned non-string (type float)
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] - Traceback (most recent call last):
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -   File "/opt/habapp/lib/python3.11/site-packages/HABApp/rule_ctx/rule_ctx.py", line 43, in unload_rule
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -     to_cancel.cancel()
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -   File "/opt/habapp/lib/python3.11/site-packages/HABApp/core/internals/event_bus_listener.py", line 57, in cancel
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -     self._ctx_unlink()
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -   File "/opt/habapp/lib/python3.11/site-packages/HABApp/core/internals/event_bus_listener.py", line 52, in _ctx_unlink
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -     event_bus.remove_listener(self)
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -   File "/opt/habapp/lib/python3.11/site-packages/HABApp/core/internals/event_bus/event_bus.py", line 76, in remove_listener
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -     habapp_log.warning(f'Event listener for {listener.describe()} has already been removed!')
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -                     ^^^^^^^^^^^^^^^^^^^
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -   File "/opt/habapp/lib/python3.11/site-packages/HABApp/core/internals/event_bus_listener.py", line 49, in describe
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -     return f'"{self.topic}" (filter={self.filter.describe()})'
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -             ^^^^^^^^^^^^^^^^^^^^^^
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -   File "/opt/habapp/lib/python3.11/site-packages/HABApp/core/events/filter/event.py", line 64, in describe
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -     values += f', {self.attr_name1}={self.attr_value1}'
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] -               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-03 10:08:42.375 [ERROR] [HABApp.Rule] - TypeError: __str__ returned non-string (type float)
spacemanspiff2007 commented 1 month ago

your str methods of a dimmer or rollershutter item return the value, not str(value). So if one tries to print an item with {item} instead of {repr(item)}, it fails with " TypeError: str returned non-string (type …)"

Presumably the str is also called in event.describe(), which casues the error I posted