spacemanspiff2007 / HABApp

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

KeyError: 'topic' in "HABApp/openhab/map_events.py" after upgrading OpenHAB to v3.3.0 stable #298

Closed lorenzodeveloper closed 1 year ago

lorenzodeveloper commented 2 years ago

Hi, After I updated openhab to v3.3.0 I cannot make my rules to work again. There is only an error that is popping up every time in the logs:

2022-07-07 11:15:34.467 [ERROR] [HABApp                              ] - Error 'topic' in on_sse_event:
2022-07-07 11:15:34.468 [ERROR] [HABApp                              ] - File "/opt/habapp/lib/python3.7/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 25, in on_sse_event
2022-07-07 11:15:34.468 [ERROR] [HABApp                              ] -     22   def on_sse_event(event_dict: dict):
2022-07-07 11:15:34.468 [ERROR] [HABApp                              ] -     23       try:
2022-07-07 11:15:34.468 [ERROR] [HABApp                              ] -     24           # Lookup corresponding OpenHAB event
2022-07-07 11:15:34.468 [ERROR] [HABApp                              ] - --> 25           event = get_event(event_dict)
2022-07-07 11:15:34.468 [ERROR] [HABApp                              ] -     26   
2022-07-07 11:15:34.469 [ERROR] [HABApp                              ] -     ..................................................
2022-07-07 11:15:34.469 [ERROR] [HABApp                              ] -      event_dict = {'type': 'ALIVE'}
2022-07-07 11:15:34.469 [ERROR] [HABApp                              ] -     ..................................................
2022-07-07 11:15:34.469 [ERROR] [HABApp                              ] - 
2022-07-07 11:15:34.469 [ERROR] [HABApp                              ] - File "/opt/habapp/lib/python3.7/site-packages/HABApp/openhab/map_events.py", line 29, in get_event
2022-07-07 11:15:34.469 [ERROR] [HABApp                              ] -     27   def get_event(_in_dict: dict) -> OpenhabEvent:
2022-07-07 11:15:34.469 [ERROR] [HABApp                              ] -     28       event_type: str = _in_dict['type']
2022-07-07 11:15:34.469 [ERROR] [HABApp                              ] - --> 29       topic: str = _in_dict['topic']
2022-07-07 11:15:34.470 [ERROR] [HABApp                              ] -     30   
2022-07-07 11:15:34.470 [ERROR] [HABApp                              ] -     ..................................................
2022-07-07 11:15:34.470 [ERROR] [HABApp                              ] -      _in_dict = {'type': 'ALIVE'}
2022-07-07 11:15:34.470 [ERROR] [HABApp                              ] -      OpenhabEvent = <class 'HABApp.openhab.events.base_event.OpenhabEvent'>
2022-07-07 11:15:34.470 [ERROR] [HABApp                              ] -      event_type = 'ALIVE'
2022-07-07 11:15:34.470 [ERROR] [HABApp                              ] -     ..................................................
2022-07-07 11:15:34.470 [ERROR] [HABApp                              ] - 
2022-07-07 11:15:34.470 [ERROR] [HABApp                              ] - KeyError: 'topic'

What I tried:

  1. Updating the system (everything was up to date)
  2. Updating habapp (but I'm already using the latest 0.31.2)
  3. rebooting the system
  4. restarting services (both openhab and habapp)

System info

Release = Debian GNU/Linux 10 (buster) - openhabian Kernel = Linux 5.10.103-v8+ Platform = Raspberry Pi 4 Model B Rev 1.4 OpenHAB version = 3.3.0 stable HABApp version = 0.31.2 Python version = 3.7.3

Is there anything I can do? Thank you.

spacemanspiff2007 commented 2 years ago

It's a new event that was introduced last minute into openHAB. Unfortunately the only way to fix this issue is to revert back to openHAB 3.2.

If you are feeling adventurous you can try the beta which fixes this issue but introduces other breaking changes. You find the beta thread in the openHAB forums under "apps & services" -> "3rd party"

lorenzodeveloper commented 2 years ago

Hi! Thank you for the quick feedback!

A tip for the ones experiencing the same problem

I tried to revert to OH 3.2.0 but it has not gone so well (don't know why, but openhab things stored in jsondb managed to disappear after downgrading, recommended to do always a backup before reverting/upgrading). So I decided to install again 3.3.0 and upgrade habapp to the beta version. At first it didn't work because some dependencies required Python>=3.8, so consider to upgrade python if you, like me had Python 3.7.3. Then I updated habapp to the beta version, changed the "listen_event" / "run_every" calls, updated the configuration file both logging and config yaml files and now everything is working like a charm :)

The only thing that now is popping up in the log, but seems to not affect the normal functioning of habapp is an error related to

  BufferEventFile:
    class: logging.handlers.MemoryHandler
    capacity: 10
    formatter: HABApp_format
    target: EventFile
    level: DEBUG

in logging.yml file.

Here is the thread mentioned by @spacemanspiff2007 -> https://community.openhab.org/t/habapp-1-0-beta-test/136952

Hope it helps. Thank you again!

spacemanspiff2007 commented 1 year ago

Fixed with 1.0