HabApp 1.0.6 and OpenHab 3.4 latest snapshot Errors In Log

Hi,
Having reverted to older versions until recently I decided to upgrade OpenHab and HabApp to latest versions:
OpenHab: 3.4.0 Build 3178 (I was running latest-ish stable release 3.3.something)
HabApp: 1.0.6 (I was running 1.0.something)

Since then I’ve been getting loads of these in the habapp.log file and some of my HabApp scripts no longer function correctly:

[2022-11-17 16:40:33,125] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-11-17 16:40:33,126] [                   HABApp]    ERROR | Traceback (most recent call last):
[2022-11-17 16:40:33,126] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31, in on_sse_event
[2022-11-17 16:40:33,126] [                   HABApp]    ERROR |     event = get_event(event_dict)
[2022-11-17 16:40:33,126] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31, in get_event
[2022-11-17 16:40:33,127] [                   HABApp]    ERROR |     topic: str = _in_dict['topic']
[2022-11-17 16:40:33,127] [                   HABApp]    ERROR | KeyError: 'topic'
[2022-11-17 16:40:43,091] [                   HABApp]    ERROR | Error 'topic' in on_sse_event:
[2022-11-17 16:40:43,092] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31 in on_sse_event
[2022-11-17 16:40:43,093] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-11-17 16:40:43,095] [                   HABApp]    ERROR |      28 | def on_sse_event(event_dict: dict):
[2022-11-17 16:40:43,096] [                   HABApp]    ERROR |      29 |     try:
[2022-11-17 16:40:43,096] [                   HABApp]    ERROR |      30 |         # Lookup corresponding OpenHAB event
[2022-11-17 16:40:43,097] [                   HABApp]    ERROR | -->  31 |         event = get_event(event_dict)
[2022-11-17 16:40:43,098] [                   HABApp]    ERROR |      33 |         # Update item in registry BEFORE posting to the event bus
[2022-11-17 16:40:43,099] [                   HABApp]    ERROR |      34 |         # so the items have the correct state when we process the event in a rule
[2022-11-17 16:40:43,099] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-11-17 16:40:43,100] [                   HABApp]    ERROR |      (ItemAddedEvent, ItemUpdatedEvent) = (<class 'HABApp.openhab.events.item_events.ItemAddedEvent'>, <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>)
[2022-11-17 16:40:43,100] [                   HABApp]    ERROR |      (ThingStatusInfoEvent, ThingUpdatedEvent) = (<class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>, <class 'HABApp.openhab.events.thing_events.ThingUpdate>[2022-11-17 16:40:43,100] [                   HABApp]    ERROR |      e = KeyError('topic')
[2022-11-17 16:40:43,101] [                   HABApp]    ERROR |      event_dict = {'type': 'ALIVE', 'interval': 10}
[2022-11-17 16:40:43,101] [                   HABApp]    ERROR |      log = <Logger HABApp.openhab.connection (INFO)>
[2022-11-17 16:40:43,102] [                   HABApp]    ERROR |      TOPIC_ITEMS = 'openHAB.Items'
[2022-11-17 16:40:43,102] [                   HABApp]    ERROR |      TOPIC_THINGS = 'openHAB.Things'
[2022-11-17 16:40:43,102] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-11-17 16:40:43,103] [                   HABApp]    ERROR |
[2022-11-17 16:40:43,103] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31 in get_event
[2022-11-17 16:40:43,104] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-11-17 16:40:43,104] [                   HABApp]    ERROR |      29 | def get_event(_in_dict: dict) -> OpenhabEvent:
[2022-11-17 16:40:43,104] [                   HABApp]    ERROR |      30 |     event_type: str = _in_dict['type']
[2022-11-17 16:40:43,105] [                   HABApp]    ERROR | -->  31 |     topic: str = _in_dict['topic']
[2022-11-17 16:40:43,105] [                   HABApp]    ERROR |      33 |     # Workaround for None values in the payload str
[2022-11-17 16:40:43,106] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-11-17 16:40:43,106] [                   HABApp]    ERROR |      _events = {'ItemStateEvent': <class 'HABApp.openhab.events.item_events.ItemStateEvent'>, 'ItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.ItemStateC>[2022-11-17 16:40:43,106] [                   HABApp]    ERROR |      _in_dict = {'type': 'ALIVE', 'interval': 10}
[2022-11-17 16:40:43,107] [                   HABApp]    ERROR |      _in_dict['type'] = 'ALIVE'
[2022-11-17 16:40:43,107] [                   HABApp]    ERROR |      event_type = 'ALIVE'
[2022-11-17 16:40:43,107] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-11-17 16:40:43,108] [                   HABApp]    ERROR |
[2022-11-17 16:40:43,108] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-11-17 16:40:43,108] [                   HABApp]    ERROR | Traceback (most recent call last):
[2022-11-17 16:40:43,109] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31, in on_sse_event
[2022-11-17 16:40:43,109] [                   HABApp]    ERROR |     event = get_event(event_dict)
[2022-11-17 16:40:43,109] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31, in get_event
[2022-11-17 16:40:43,109] [                   HABApp]    ERROR |     topic: str = _in_dict['topic']
[2022-11-17 16:40:43,110] [                   HABApp]    ERROR | KeyError: 'topic'

Has anyone else had this issue and what is the solution?
I’m presuming something has changed in one of the latest snapshots that HabApp doesn’t like or there’s some other dependency that needs upgrading.

Thanks,
Richie

I’ve reverted back to OpenHab 3.3.0 and HabApp 1.0.5 to resolve the issue (HabApp 1.0.6 still didn’t play right with OpenHab 3.3.0)

I’ll look into upgrading OpenHab to 3.4.0 and leave HabApp on 1.0.5 tomorrow

Thanks,
Richie

Are you sure you’ve installed the latest version?
There was a fix in 1.0.5 that supports the new alive event introduced in OH3.4.
So 1.0.6 should work, too. If you still get the error this is most likely a bug!

Hi,
Yes, positive it was 1.0.6.
I’m wondering if there have been other changes to functionality that i need to factor in around my code.
I’ll try and do some more digging into it later today if i get chance.

Thanks,
Richie

No - just use the latest version. There should be no errors.

Hi,
I’ve updated Openhab and HabApp to the latest versions again.

HabApp:

  _   _    _    ____    _
 | | | |  / \  | __ )  / \   _ __  _ __
 | |_| | / _ \ |  _ \ / _ \ | '_ \| '_ \
 |  _  |/ ___ \| |_) / ___ \| |_) | |_) |
 |_| |_/_/   \_|____/_/   \_| .__/| .__/
                            |_|   |_|
                                        1.0.6
usage: habapp [-h] [-c CONFIG] [-wos WAIT_OS_UPTIME] [-b] [-di]

OpenHab:

openHAB 3.4.0
Build #3178

I fixed an error in one rule and everything seems to be working. However, the HABApp.log file is filling up with loads of these:

[2022-11-18 20:50:16,567] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-11-18 20:50:16,568] [                   HABApp]    ERROR | Traceback (most recent call last):
[2022-11-18 20:50:16,568] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31, in on_sse_event
[2022-11-18 20:50:16,569] [                   HABApp]    ERROR |     event = get_event(event_dict)
[2022-11-18 20:50:16,569] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31, in get_event
[2022-11-18 20:50:16,569] [                   HABApp]    ERROR |     topic: str = _in_dict['topic']
[2022-11-18 20:50:16,570] [                   HABApp]    ERROR | KeyError: 'topic'
[2022-11-18 20:50:26,551] [                   HABApp]    ERROR | Error 'topic' in on_sse_event:
[2022-11-18 20:50:26,552] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31 in on_sse_event
[2022-11-18 20:50:26,553] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-11-18 20:50:26,553] [                   HABApp]    ERROR |      28 | def on_sse_event(event_dict: dict):
[2022-11-18 20:50:26,554] [                   HABApp]    ERROR |      29 |     try:
[2022-11-18 20:50:26,554] [                   HABApp]    ERROR |      30 |         # Lookup corresponding OpenHAB event
[2022-11-18 20:50:26,555] [                   HABApp]    ERROR | -->  31 |         event = get_event(event_dict)
[2022-11-18 20:50:26,556] [                   HABApp]    ERROR |      33 |         # Update item in registry BEFORE posting to the event bus
[2022-11-18 20:50:26,556] [                   HABApp]    ERROR |      34 |         # so the items have the correct state when we process the event in a rule
[2022-11-18 20:50:26,556] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-11-18 20:50:26,557] [                   HABApp]    ERROR |      (ItemAddedEvent, ItemUpdatedEvent) = (<class 'HABApp.openhab.events.item_events.ItemAddedEvent'>, <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>)
[2022-11-18 20:50:26,557] [                   HABApp]    ERROR |      (ThingStatusInfoEvent, ThingUpdatedEvent) = (<class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>, <class 'HABApp.openhab.events.thing_events.ThingUpdate>[2022-11-18 20:50:26,557] [                   HABApp]    ERROR |      e = KeyError('topic')
[2022-11-18 20:50:26,558] [                   HABApp]    ERROR |      event_dict = {'type': 'ALIVE', 'interval': 10}
[2022-11-18 20:50:26,558] [                   HABApp]    ERROR |      log = <Logger HABApp.openhab.connection (INFO)>
[2022-11-18 20:50:26,558] [                   HABApp]    ERROR |      TOPIC_ITEMS = 'openHAB.Items'
[2022-11-18 20:50:26,559] [                   HABApp]    ERROR |      TOPIC_THINGS = 'openHAB.Things'
[2022-11-18 20:50:26,559] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-11-18 20:50:26,559] [                   HABApp]    ERROR |
[2022-11-18 20:50:26,560] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31 in get_event
[2022-11-18 20:50:26,560] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-11-18 20:50:26,561] [                   HABApp]    ERROR |      29 | def get_event(_in_dict: dict) -> OpenhabEvent:
[2022-11-18 20:50:26,561] [                   HABApp]    ERROR |      30 |     event_type: str = _in_dict['type']
[2022-11-18 20:50:26,561] [                   HABApp]    ERROR | -->  31 |     topic: str = _in_dict['topic']
[2022-11-18 20:50:26,562] [                   HABApp]    ERROR |      33 |     # Workaround for None values in the payload str
[2022-11-18 20:50:26,562] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-11-18 20:50:26,563] [                   HABApp]    ERROR |      _events = {'ItemStateEvent': <class 'HABApp.openhab.events.item_events.ItemStateEvent'>, 'ItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.ItemStateC>[2022-11-18 20:50:26,563] [                   HABApp]    ERROR |      _in_dict = {'type': 'ALIVE', 'interval': 10}
[2022-11-18 20:50:26,564] [                   HABApp]    ERROR |      _in_dict['type'] = 'ALIVE'
[2022-11-18 20:50:26,564] [                   HABApp]    ERROR |      event_type = 'ALIVE'
[2022-11-18 20:50:26,564] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-11-18 20:50:26,565] [                   HABApp]    ERROR |
[2022-11-18 20:50:26,565] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-11-18 20:50:26,565] [                   HABApp]    ERROR | Traceback (most recent call last):
[2022-11-18 20:50:26,566] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31, in on_sse_event
[2022-11-18 20:50:26,566] [                   HABApp]    ERROR |     event = get_event(event_dict)
[2022-11-18 20:50:26,567] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31, in get_event
[2022-11-18 20:50:26,567] [                   HABApp]    ERROR |     topic: str = _in_dict['topic']
[2022-11-18 20:50:26,567] [                   HABApp]    ERROR | KeyError: 'topic'

Any ideas what’s causing them?

This also seems very similar to an issue I had earlier in the year: HABApp - Easy automation with openHAB - Apps & Services / 3rd Party - openHAB Community

Thanks,
Richie

Are you sure the old HABApp instance is properly shut down?
I just double checked and the code is there in 1.0.6

Hi,
Should I have uninstalled HabApp first and then reinstalled?
I just did an upgrade.
I’ll try uninstall, then install and see if that makes a difference.

Update: it didn’t make a difference :frowning:

Thanks,
Richie

Hi,
I’ve done some more digging and found I also have version 1.0.3 running that I must have manually installed and created a service for it.
I just need to sort that out and get 1.0.6 installed

Update: I’ve edited the service file for my HabApp to point to the new version’s location and everything seems to be working - without those errors in the HabApp.log file :slight_smile:

Thanks for your guidance so far,
Richie