HABApp - Easy automation with openHAB

Just doing some basic debugging and part of this issue is that the on_sse_event doesn’t always seem to have “topic” in it:

[2022-06-18 20:46:39,441] [HABApp.openhab.connection]  WARNING | RR_TEST: {'type': 'ALIVE'}
[2022-06-18 20:46:39,666] [                   HABApp]    ERROR | Error 'topic' in on_sse_event:
[2022-06-18 20:46:39,666] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 26, in on_sse_event
[2022-06-18 20:46:39,666] [                   HABApp]    ERROR |     22   def on_sse_event(event_dict: dict):
[2022-06-18 20:46:39,667] [                   HABApp]    ERROR |     23       try:
[2022-06-18 20:46:39,667] [                   HABApp]    ERROR |     24           # Lookup corresponding OpenHAB event
[2022-06-18 20:46:39,667] [                   HABApp]    ERROR |     25           log_warning(log, f'RR_TEST: {event_dict}')
[2022-06-18 20:46:39,667] [                   HABApp]    ERROR | --> 26           event = get_event(event_dict)
[2022-06-18 20:46:39,668] [                   HABApp]    ERROR |     27
[2022-06-18 20:46:39,668] [                   HABApp]    ERROR |     ..................................................
[2022-06-18 20:46:39,668] [                   HABApp]    ERROR |      event_dict = {'type': 'ALIVE'}
[2022-06-18 20:46:39,668] [                   HABApp]    ERROR |      log = <Logger HABApp.openhab.connection (INFO)>
[2022-06-18 20:46:39,669] [                   HABApp]    ERROR |     ..................................................
[2022-06-18 20:46:39,669] [                   HABApp]    ERROR |
[2022-06-18 20:46:39,670] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 29, in get_event
[2022-06-18 20:46:39,670] [                   HABApp]    ERROR |     27   def get_event(_in_dict: dict) -> OpenhabEvent:
[2022-06-18 20:46:39,671] [                   HABApp]    ERROR |     28       event_type: str = _in_dict['type']
[2022-06-18 20:46:39,671] [                   HABApp]    ERROR | --> 29       topic: str = _in_dict['topic']
[2022-06-18 20:46:39,671] [                   HABApp]    ERROR |     30
[2022-06-18 20:46:39,671] [                   HABApp]    ERROR |     ..................................................
[2022-06-18 20:46:39,672] [                   HABApp]    ERROR |      _in_dict = {'type': 'ALIVE'}
[2022-06-18 20:46:39,672] [                   HABApp]    ERROR |      OpenhabEvent = <class 'HABApp.openhab.events.base_event.OpenhabEvent'>
[2022-06-18 20:46:39,672] [                   HABApp]    ERROR |      event_type = 'ALIVE'
[2022-06-18 20:46:39,672] [                   HABApp]    ERROR |     ..................................................
[2022-06-18 20:46:39,673] [                   HABApp]    ERROR |
[2022-06-18 20:46:39,673] [                   HABApp]    ERROR | KeyError: 'topic'

Could something in OpenHab have changed recently?

Thanks,
Richie

Ok, so further investigation seems to indicate this (in map_events.py) no longer works correctly:

def get_event(_in_dict: dict) -> OpenhabEvent:
    event_type: str = _in_dict['type']
    topic: str = _in_dict['topic']

So an “event_type” still gets treated as a topic (I think).
My limited Python knowledge is stuck on any further testing/solution :frowning:

Thanks,
Richie

If I understand the postings before yours correctly some changes are needed in HABApp in order to be able to work with OH 3.3.

Currently you should continue with OH 3.2

Hi,
I’ve been running with 3.3 for a while now and it’s only one of the recent builds that has caused this.
I’m still digging into it and now get the following errors (whilst “playing” around with the HabApp code):

[2022-06-18 22:06:39,506] [                   HABApp]    ERROR | Error Unknown Event: ALIVE for {'type': 'ALIVE'} in on_sse_event:
[2022-06-18 22:06:39,507] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 52, in get_event
[2022-06-18 22:06:39,507] [                   HABApp]    ERROR |     30   def get_event(_in_dict: dict):
[2022-06-18 22:06:39,508] [                   HABApp]    ERROR |  (...)
[2022-06-18 22:06:39,509] [                   HABApp]    ERROR |     48
[2022-06-18 22:06:39,509] [                   HABApp]    ERROR |     49
[2022-06-18 22:06:39,510] [                   HABApp]    ERROR |     50       # Find event from implemented events
[2022-06-18 22:06:39,510] [                   HABApp]    ERROR |     51       try:
[2022-06-18 22:06:39,510] [                   HABApp]    ERROR | --> 52           return __event_lookup[event_type].from_dict(topic, payload)
[2022-06-18 22:06:39,511] [                   HABApp]    ERROR |     53       except KeyError:
[2022-06-18 22:06:39,511] [                   HABApp]    ERROR |     ..................................................
[2022-06-18 22:06:39,511] [                   HABApp]    ERROR |      _in_dict = {'type': 'ALIVE'}
[2022-06-18 22:06:39,512] [                   HABApp]    ERROR |      __event_lookup = {'ItemStateEvent': <class 'HABApp.openhab.events.item_events.ItemStateEvent'>,
[2022-06-18 22:06:39,512] [                   HABApp]    ERROR |                        'ItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.ItemStateChangedEvent'>,
[2022-06-18 22:06:39,512] [                   HABApp]    ERROR |                        'ItemCommandEvent': <class 'HABApp.openhab.events.item_events.ItemCommandEvent'>,
[2022-06-18 22:06:39,513] [                   HABApp]    ERROR |                        'ItemAddedEvent': <class 'HABApp.openhab.events.item_events.ItemAddedEvent'>,
[2022-06-18 22:06:39,513] [                   HABApp]    ERROR |                        'ItemUpdatedEvent': <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>,
[2022-06-18 22:06:39,513] [                   HABApp]    ERROR |                        'ItemRemovedEvent': <class 'HABApp.openhab.events.item_events.ItemRemovedEvent'>,
[2022-06-18 22:06:39,513] [                   HABApp]    ERROR |                        'ItemStatePredictedEvent': <class 'HABApp.openhab.events.item_events.ItemStatePredictedEvent'>,
[2022-06-18 22:06:39,514] [                   HABApp]    ERROR |                        'GroupItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.GroupItemStateChangedEvent'>,
[2022-06-18 22:06:39,514] [                   HABApp]    ERROR |                        'ChannelTriggeredEvent': <class 'HABApp.openhab.events.channel_events.ChannelTriggeredEvent'>,
[2022-06-18 22:06:39,514] [                   HABApp]    ERROR |                        'ThingStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>,
[2022-06-18 22:06:39,515] [                   HABApp]    ERROR |                        'ThingStatusInfoChangedEv...: <class 'HABApp.openhab.events.thing_events.ThingStatusInfoChangedEvent'>,
[2022-06-18 22:06:39,515] [                   HABApp]    ERROR |                        'ThingFirmwareStatusInfoE...: <class 'HABApp.openhab.events.thing_events.ThingFirmwareStatusInfoEvent'>,
[2022-06-18 22:06:39,515] [                   HABApp]    ERROR |                        'ConfigStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingConfigStatusInfoEvent'>,
[2022-06-18 22:06:39,515] [                   HABApp]    ERROR |                        'FirmwareStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingFirmwareStatusInfoEvent'>}
[2022-06-18 22:06:39,516] [                   HABApp]    ERROR |      event_type = 'ALIVE'
[2022-06-18 22:06:39,516] [                   HABApp]    ERROR |     ..................................................
[2022-06-18 22:06:39,516] [                   HABApp]    ERROR |
[2022-06-18 22:06:39,517] [                   HABApp]    ERROR | KeyError: 'ALIVE'
[2022-06-18 22:06:39,517] [                   HABApp]    ERROR |
[2022-06-18 22:06:39,517] [                   HABApp]    ERROR | While handling the above exception, another exception occurred:
[2022-06-18 22:06:39,517] [                   HABApp]    ERROR |
[2022-06-18 22:06:39,518] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 25, in on_sse_event
[2022-06-18 22:06:39,518] [                   HABApp]    ERROR |     22   def on_sse_event(event_dict: dict):
[2022-06-18 22:06:39,518] [                   HABApp]    ERROR |     23       try:
[2022-06-18 22:06:39,519] [                   HABApp]    ERROR |     24           # Lookup corresponding OpenHAB event
[2022-06-18 22:06:39,519] [                   HABApp]    ERROR | --> 25           event = get_event(event_dict)
[2022-06-18 22:06:39,519] [                   HABApp]    ERROR |     26
[2022-06-18 22:06:39,520] [                   HABApp]    ERROR |     ..................................................
[2022-06-18 22:06:39,520] [                   HABApp]    ERROR |      event_dict = {'type': 'ALIVE'}
[2022-06-18 22:06:39,520] [                   HABApp]    ERROR |     ..................................................
[2022-06-18 22:06:39,521] [                   HABApp]    ERROR |
[2022-06-18 22:06:39,521] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 54, in get_event
[2022-06-18 22:06:39,521] [                   HABApp]    ERROR |     30   def get_event(_in_dict: dict):
[2022-06-18 22:06:39,522] [                   HABApp]    ERROR |  (...)
[2022-06-18 22:06:39,522] [                   HABApp]    ERROR |     50       # Find event from implemented events
[2022-06-18 22:06:39,522] [                   HABApp]    ERROR |     51       try:
[2022-06-18 22:06:39,523] [                   HABApp]    ERROR |     52           return __event_lookup[event_type].from_dict(topic, payload)
[2022-06-18 22:06:39,523] [                   HABApp]    ERROR |     53       except KeyError:
[2022-06-18 22:06:39,523] [                   HABApp]    ERROR | --> 54           raise ValueError(f'Unknown Event: {event_type:s} for {_in_dict}')
[2022-06-18 22:06:39,524] [                   HABApp]    ERROR |     ..................................................
[2022-06-18 22:06:39,524] [                   HABApp]    ERROR |      _in_dict = {'type': 'ALIVE'}
[2022-06-18 22:06:39,524] [                   HABApp]    ERROR |      __event_lookup = {'ItemStateEvent': <class 'HABApp.openhab.events.item_events.ItemStateEvent'>,
[2022-06-18 22:06:39,525] [                   HABApp]    ERROR |                        'ItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.ItemStateChangedEvent'>,
[2022-06-18 22:06:39,525] [                   HABApp]    ERROR |                        'ItemCommandEvent': <class 'HABApp.openhab.events.item_events.ItemCommandEvent'>,
[2022-06-18 22:06:39,525] [                   HABApp]    ERROR |                        'ItemAddedEvent': <class 'HABApp.openhab.events.item_events.ItemAddedEvent'>,
[2022-06-18 22:06:39,525] [                   HABApp]    ERROR |                        'ItemUpdatedEvent': <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>,
[2022-06-18 22:06:39,526] [                   HABApp]    ERROR |                        'ItemRemovedEvent': <class 'HABApp.openhab.events.item_events.ItemRemovedEvent'>,
[2022-06-18 22:06:39,526] [                   HABApp]    ERROR |                        'ItemStatePredictedEvent': <class 'HABApp.openhab.events.item_events.ItemStatePredictedEvent'>,
[2022-06-18 22:06:39,526] [                   HABApp]    ERROR |                        'GroupItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.GroupItemStateChangedEvent'>,
[2022-06-18 22:06:39,527] [                   HABApp]    ERROR |                        'ChannelTriggeredEvent': <class 'HABApp.openhab.events.channel_events.ChannelTriggeredEvent'>,
[2022-06-18 22:06:39,527] [                   HABApp]    ERROR |                        'ThingStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>,
[2022-06-18 22:06:39,527] [                   HABApp]    ERROR |                        'ThingStatusInfoChangedEv...: <class 'HABApp.openhab.events.thing_events.ThingStatusInfoChangedEvent'>,
[2022-06-18 22:06:39,527] [                   HABApp]    ERROR |                        'ThingFirmwareStatusInfoE...: <class 'HABApp.openhab.events.thing_events.ThingFirmwareStatusInfoEvent'>,
[2022-06-18 22:06:39,528] [                   HABApp]    ERROR |                        'ConfigStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingConfigStatusInfoEvent'>,
[2022-06-18 22:06:39,528] [                   HABApp]    ERROR |                        'FirmwareStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingFirmwareStatusInfoEvent'>}
[2022-06-18 22:06:39,528] [                   HABApp]    ERROR |      event_type = 'ALIVE'
[2022-06-18 22:06:39,529] [                   HABApp]    ERROR |     ..................................................
[2022-06-18 22:06:39,529] [                   HABApp]    ERROR |
[2022-06-18 22:06:39,530] [                   HABApp]    ERROR | ValueError: Unknown Event: ALIVE for {'type': 'ALIVE'}

Has there possibly been a new ‘ALIVE’ event type added in OpenHab over the last few days/weeks?

Thanks,
Richie

1 Like

Howdy! I’m trying to understand the limitations of the ItemNoChangeEvent.
I have two different rules that each have watchers on the same openhab switch item, but for different purposes – and it seems they only worked one at a time (whichever rule was reloaded last) so I looked into the documentation and discovered:

self.no_change_group.add_no_change_watcher(item, fn, delay, alias="NCW_FloorLamp_GameRoomSwitch")

One of my rules was indeed using EventListenerGroup so this worked nicely, and it seems to have solved the problem!

But, how do I use alias with the regular item.watch_change(secs)? Neither watch_change() nor listen_event() have an alias parameter.

I would like to make sure to always use alias from now on so that this doesn’t come back to bite me. Am I understanding things correctly? Is this a real limitation of ItemNoChangeEvent that requires manually aliasing to prevent them stepping on each other, or is something else going on?

have you figured anything out about this yet? Or how to edit the source code to override? M5 broke one of my bindings and I’d like to go up to M7 instead of back to M4…

1 Like

just to add that I’m also stuck. openHAB without habapp is now unthinkable for me…

2 Likes

Same here. My favorite tool for rules.

1 Like

Yes - there was a recent change in openHAB 3.3 which causes this issue.
I’ll provide a fix in the next couple of weeks, in the meantime is it possible for you to just go back to 3.2?

I use multiple ItemNoChangeEvent of the same item. I think there is something else going on. Could you open another thread and tag it with HABApp so we can get to the bottom of this?

2 Likes

That is great news - thank you!

1 Like

Could someone with docker knowledge head over to the beta thread and verify that the new docker image works as expected?

Using Visual Studio Code with remote SSH and python extensin with Habapp

I am trying to use VSC on my windows laptop remotely connected to my raspberry pi v4 (but i would also like to use my pi 3b).
I always get the error

Import "HABApp.core.events" could not be resolvedPylancereportMissingImports

It may be obvious but I am unable to find the right setting of python or pylance extension
(python.venvFolders?)

Can someone point me in the right direction?
Thank you
EDIT: I figured out myself, and I post here the solution.
The point is to set in VSC the “version” of the python interpreter, as explained at this link.

Then, in order to have also files contained in the habapp/lib directory the pylint setting

"python.analysis.extraPaths": [ "/srv/openhab-conf/habapp/lib"]

should be set

Good news everyone! HABApp 1.0 is out!

1 Like

hello,
i have installed openhabian on a rpi4b an work on oh3.4.0.m3 with installed habapp 1.0.4
i suddenly realize lots of errors in the habapp.log that appear continuosly:

[2022-10-18 11:01:14,802] [                   HABApp]     INFO | HABApp Version 1.0.4
[2022-10-18 11:01:14,802] [            HABApp.Config]     WARN | Replaced class for handler "HABApp_default" with HABApp.config.logging.MidnightRotatingFileHandler
[2022-10-18 11:01:14,802] [            HABApp.Config]     WARN | Replaced class for handler "My_HABApp_default" with HABApp.config.logging.MidnightRotatingFileHandler
[2022-10-18 11:01:14,866] [   HABApp.mqtt.connection]     INFO | MQTT disabled
[2022-10-18 11:01:14,992] [HABApp.openhab.connection]     INFO | Connected to OpenHAB version 3.4.0.M3 (Milestone Build)
[2022-10-18 11:01:15,933] [     HABApp.openhab.items]     INFO | Updated 584 Items
[2022-10-18 11:01:16,241] [     HABApp.openhab.items]     INFO | Updated 257 Things
[2022-10-18 11:01:16,877] [          HABApp.EventBus]     INFO |              iSl_pac: <ItemStateEvent name: iSl_pac, value: 8560>
[2022-10-18 11:01:16,882] [          HABApp.EventBus]     INFO |              iSl_pac: <ItemStateChangedEvent name: iSl_pac, value: 8560, old_value: 8527>
[2022-10-18 11:01:16,885] [          HABApp.EventBus]     INFO |         iSl_yieldday: <ItemStateEvent name: iSl_yieldday, value: 11571>
[2022-10-18 11:01:16,887] [          HABApp.EventBus]     INFO |    solarlog:meter:pv: <ThingStatusInfoEvent name: solarlog:meter:pv, status: ONLINE, detail: None>
[2022-10-18 11:01:16,888] [          HABApp.EventBus]     INFO |         iSl_yieldday: <ItemStateChangedEvent name: iSl_yieldday, value: 11571, old_value: 11500>
[2022-10-18 11:01:23,654] [                   HABApp]    ERROR | Error 'topic' in on_sse_event:
[2022-10-18 11:01:23,654] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31 in on_sse_event
[2022-10-18 11:01:23,654] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-10-18 11:01:23,654] [                   HABApp]    ERROR |      28 | def on_sse_event(event_dict: dict):
[2022-10-18 11:01:23,654] [                   HABApp]    ERROR |      29 |     try:
[2022-10-18 11:01:23,655] [                   HABApp]    ERROR |      30 |         # Lookup corresponding OpenHAB event
[2022-10-18 11:01:23,655] [                   HABApp]    ERROR | -->  31 |         event = get_event(event_dict)
[2022-10-18 11:01:23,655] [                   HABApp]    ERROR |      33 |         # Update item in registry BEFORE posting to the event bus
[2022-10-18 11:01:23,655] [                   HABApp]    ERROR |      34 |         # so the items have the correct state when we process the event in a rule
[2022-10-18 11:01:23,655] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:23,655] [                   HABApp]    ERROR |      (ItemAddedEvent, ItemUpdatedEvent) = (<class 'HABApp.openhab.events.item_events.ItemAddedEvent'>, <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>)
[2022-10-18 11:01:23,655] [                   HABApp]    ERROR |      (ThingStatusInfoEvent, ThingUpdatedEvent) = (<class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>, <class 'HABApp.openhab.events.thing_events.ThingUpdatedEvent'>)
[2022-10-18 11:01:23,656] [                   HABApp]    ERROR |      e = KeyError('topic')
[2022-10-18 11:01:23,656] [                   HABApp]    ERROR |      event_dict = {'type': 'ALIVE', 'interval': 10}
[2022-10-18 11:01:23,656] [                   HABApp]    ERROR |      log = <Logger HABApp.openhab.connection (INFO)>
[2022-10-18 11:01:23,656] [                   HABApp]    ERROR |      TOPIC_ITEMS = 'openHAB.Items'
[2022-10-18 11:01:23,656] [                   HABApp]    ERROR |      TOPIC_THINGS = 'openHAB.Things'
[2022-10-18 11:01:23,656] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:23,656] [                   HABApp]    ERROR | 
[2022-10-18 11:01:23,657] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31 in get_event
[2022-10-18 11:01:23,657] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-10-18 11:01:23,657] [                   HABApp]    ERROR |      29 | def get_event(_in_dict: dict) -> OpenhabEvent:
[2022-10-18 11:01:23,657] [                   HABApp]    ERROR |      30 |     event_type: str = _in_dict['type']
[2022-10-18 11:01:23,657] [                   HABApp]    ERROR | -->  31 |     topic: str = _in_dict['topic']
[2022-10-18 11:01:23,657] [                   HABApp]    ERROR |      33 |     # Workaround for None values in the payload str
[2022-10-18 11:01:23,658] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:23,658] [                   HABApp]    ERROR |      _events = {'ItemStateEvent': <class 'HABApp.openhab.events.item_events.ItemStateEvent'>, 'ItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.ItemStateChangedEvent'>, 'ItemCommandEvent': <class 'HABApp.openhab.events.item_events.ItemCommandEvent'>, 'ItemAddedEvent': <class 'HABApp.openhab.events.item_events.ItemAddedEvent'>, 'ItemUpdatedEvent': <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>, 'ItemRemovedEvent': <class 'HABApp.openhab.events.item_events.ItemRemovedEvent'>, 'ItemStatePredictedEvent': <class 'HABApp.openhab.events.item_events.ItemStatePredictedEvent'>, 'GroupItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.GroupItemStateChangedEvent'>, 'ChannelTriggeredEvent': <class 'HABApp.openhab.events.channel_events.ChannelTriggeredEvent'>, 'ChannelDescriptionChangedEvent': <class 'HABApp.openhab.events.channel_events.ChannelDescriptionChangedEvent'>, 'ThingAddedEvent': <class 'HABApp.openhab.events.thing_events.ThingAddedEvent'>, 'ThingRemovedEvent': <class 'HABApp.openhab.events.thing_events.ThingRemovedEvent'>, 'ThingUpdatedEvent': <class 'HABApp.openhab.events.thing_events.ThingUpdatedEvent'>, 'ThingStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>, 'ThingStatusInfoChangedEvent': <class 'HABApp.openhab.events.thing_events.ThingStatusInfoChangedEvent'>, 'ThingFirmwareStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingFirmwareStatusInfoEvent'>, 'FirmwareStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingFirmwareStatusInfoEvent'>}
[2022-10-18 11:01:23,658] [                   HABApp]    ERROR |      _in_dict = {'type': 'ALIVE', 'interval': 10}
[2022-10-18 11:01:23,658] [                   HABApp]    ERROR |      _in_dict['type'] = 'ALIVE'
[2022-10-18 11:01:23,658] [                   HABApp]    ERROR |      event_type = 'ALIVE'
[2022-10-18 11:01:23,658] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:23,659] [                   HABApp]    ERROR | 
[2022-10-18 11:01:23,659] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-10-18 11:01:23,659] [                   HABApp]    ERROR | Traceback (most recent call last):
[2022-10-18 11:01:23,659] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31, in on_sse_event
[2022-10-18 11:01:23,659] [                   HABApp]    ERROR |     event = get_event(event_dict)
[2022-10-18 11:01:23,659] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31, in get_event
[2022-10-18 11:01:23,659] [                   HABApp]    ERROR |     topic: str = _in_dict['topic']
[2022-10-18 11:01:23,660] [                   HABApp]    ERROR | KeyError: 'topic'
[2022-10-18 11:01:23,660] [          HABApp.EventBus]     INFO |        HABApp.Errors: <HABAppException func_name: on_sse_event, exception: 'topic'>
[2022-10-18 11:01:33,536] [                   HABApp]    ERROR | Error 'topic' in on_sse_event:
[2022-10-18 11:01:33,536] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31 in on_sse_event
[2022-10-18 11:01:33,536] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-10-18 11:01:33,537] [                   HABApp]    ERROR |      28 | def on_sse_event(event_dict: dict):
[2022-10-18 11:01:33,537] [                   HABApp]    ERROR |      29 |     try:
[2022-10-18 11:01:33,537] [                   HABApp]    ERROR |      30 |         # Lookup corresponding OpenHAB event
[2022-10-18 11:01:33,537] [                   HABApp]    ERROR | -->  31 |         event = get_event(event_dict)
[2022-10-18 11:01:33,537] [                   HABApp]    ERROR |      33 |         # Update item in registry BEFORE posting to the event bus
[2022-10-18 11:01:33,537] [                   HABApp]    ERROR |      34 |         # so the items have the correct state when we process the event in a rule
[2022-10-18 11:01:33,538] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:33,538] [                   HABApp]    ERROR |      (ItemAddedEvent, ItemUpdatedEvent) = (<class 'HABApp.openhab.events.item_events.ItemAddedEvent'>, <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>)
[2022-10-18 11:01:33,538] [                   HABApp]    ERROR |      (ThingStatusInfoEvent, ThingUpdatedEvent) = (<class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>, <class 'HABApp.openhab.events.thing_events.ThingUpdatedEvent'>)
[2022-10-18 11:01:33,538] [                   HABApp]    ERROR |      e = KeyError('topic')
[2022-10-18 11:01:33,538] [                   HABApp]    ERROR |      event_dict = {'type': 'ALIVE', 'interval': 10}
[2022-10-18 11:01:33,538] [                   HABApp]    ERROR |      log = <Logger HABApp.openhab.connection (INFO)>
[2022-10-18 11:01:33,538] [                   HABApp]    ERROR |      TOPIC_ITEMS = 'openHAB.Items'
[2022-10-18 11:01:33,538] [                   HABApp]    ERROR |      TOPIC_THINGS = 'openHAB.Things'
[2022-10-18 11:01:33,539] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:33,539] [                   HABApp]    ERROR | 
[2022-10-18 11:01:33,539] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31 in get_event
[2022-10-18 11:01:33,539] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-10-18 11:01:33,539] [                   HABApp]    ERROR |      29 | def get_event(_in_dict: dict) -> OpenhabEvent:
[2022-10-18 11:01:33,539] [                   HABApp]    ERROR |      30 |     event_type: str = _in_dict['type']
[2022-10-18 11:01:33,539] [                   HABApp]    ERROR | -->  31 |     topic: str = _in_dict['topic']
[2022-10-18 11:01:33,539] [                   HABApp]    ERROR |      33 |     # Workaround for None values in the payload str
[2022-10-18 11:01:33,540] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:33,540] [                   HABApp]    ERROR |      _events = {'ItemStateEvent': <class 'HABApp.openhab.events.item_events.ItemStateEvent'>, 'ItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.ItemStateChangedEvent'>, 'ItemCommandEvent': <class 'HABApp.openhab.events.item_events.ItemCommandEvent'>, 'ItemAddedEvent': <class 'HABApp.openhab.events.item_events.ItemAddedEvent'>, 'ItemUpdatedEvent': <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>, 'ItemRemovedEvent': <class 'HABApp.openhab.events.item_events.ItemRemovedEvent'>, 'ItemStatePredictedEvent': <class 'HABApp.openhab.events.item_events.ItemStatePredictedEvent'>, 'GroupItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.GroupItemStateChangedEvent'>, 'ChannelTriggeredEvent': <class 'HABApp.openhab.events.channel_events.ChannelTriggeredEvent'>, 'ChannelDescriptionChangedEvent': <class 'HABApp.openhab.events.channel_events.ChannelDescriptionChangedEvent'>, 'ThingAddedEvent': <class 'HABApp.openhab.events.thing_events.ThingAddedEvent'>, 'ThingRemovedEvent': <class 'HABApp.openhab.events.thing_events.ThingRemovedEvent'>, 'ThingUpdatedEvent': <class 'HABApp.openhab.events.thing_events.ThingUpdatedEvent'>, 'ThingStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>, 'ThingStatusInfoChangedEvent': <class 'HABApp.openhab.events.thing_events.ThingStatusInfoChangedEvent'>, 'ThingFirmwareStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingFirmwareStatusInfoEvent'>, 'FirmwareStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingFirmwareStatusInfoEvent'>}
[2022-10-18 11:01:33,540] [                   HABApp]    ERROR |      _in_dict = {'type': 'ALIVE', 'interval': 10}
[2022-10-18 11:01:33,540] [                   HABApp]    ERROR |      _in_dict['type'] = 'ALIVE'
[2022-10-18 11:01:33,540] [                   HABApp]    ERROR |      event_type = 'ALIVE'
[2022-10-18 11:01:33,540] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:33,540] [                   HABApp]    ERROR | 
[2022-10-18 11:01:33,541] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-10-18 11:01:33,541] [                   HABApp]    ERROR | Traceback (most recent call last):
[2022-10-18 11:01:33,541] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31, in on_sse_event
[2022-10-18 11:01:33,541] [                   HABApp]    ERROR |     event = get_event(event_dict)
[2022-10-18 11:01:33,541] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31, in get_event
[2022-10-18 11:01:33,541] [                   HABApp]    ERROR |     topic: str = _in_dict['topic']
[2022-10-18 11:01:33,541] [                   HABApp]    ERROR | KeyError: 'topic'
[2022-10-18 11:01:33,541] [          HABApp.EventBus]     INFO |        HABApp.Errors: <HABAppException func_name: on_sse_event, exception: 'topic'>
[2022-10-18 11:01:43,535] [                   HABApp]    ERROR | Error 'topic' in on_sse_event:
[2022-10-18 11:01:43,535] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31 in on_sse_event
[2022-10-18 11:01:43,535] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-10-18 11:01:43,536] [                   HABApp]    ERROR |      28 | def on_sse_event(event_dict: dict):
[2022-10-18 11:01:43,536] [                   HABApp]    ERROR |      29 |     try:
[2022-10-18 11:01:43,536] [                   HABApp]    ERROR |      30 |         # Lookup corresponding OpenHAB event
[2022-10-18 11:01:43,536] [                   HABApp]    ERROR | -->  31 |         event = get_event(event_dict)
[2022-10-18 11:01:43,537] [                   HABApp]    ERROR |      33 |         # Update item in registry BEFORE posting to the event bus
[2022-10-18 11:01:43,537] [                   HABApp]    ERROR |      34 |         # so the items have the correct state when we process the event in a rule
[2022-10-18 11:01:43,537] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:43,537] [                   HABApp]    ERROR |      (ItemAddedEvent, ItemUpdatedEvent) = (<class 'HABApp.openhab.events.item_events.ItemAddedEvent'>, <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>)
[2022-10-18 11:01:43,537] [                   HABApp]    ERROR |      (ThingStatusInfoEvent, ThingUpdatedEvent) = (<class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>, <class 'HABApp.openhab.events.thing_events.ThingUpdatedEvent'>)
[2022-10-18 11:01:43,538] [                   HABApp]    ERROR |      e = KeyError('topic')
[2022-10-18 11:01:43,538] [                   HABApp]    ERROR |      event_dict = {'type': 'ALIVE', 'interval': 10}
[2022-10-18 11:01:43,538] [                   HABApp]    ERROR |      log = <Logger HABApp.openhab.connection (INFO)>
[2022-10-18 11:01:43,538] [                   HABApp]    ERROR |      TOPIC_ITEMS = 'openHAB.Items'
[2022-10-18 11:01:43,538] [                   HABApp]    ERROR |      TOPIC_THINGS = 'openHAB.Things'
[2022-10-18 11:01:43,538] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:43,539] [                   HABApp]    ERROR | 
[2022-10-18 11:01:43,539] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31 in get_event
[2022-10-18 11:01:43,539] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-10-18 11:01:43,539] [                   HABApp]    ERROR |      29 | def get_event(_in_dict: dict) -> OpenhabEvent:
[2022-10-18 11:01:43,539] [                   HABApp]    ERROR |      30 |     event_type: str = _in_dict['type']
[2022-10-18 11:01:43,539] [                   HABApp]    ERROR | -->  31 |     topic: str = _in_dict['topic']
[2022-10-18 11:01:43,539] [                   HABApp]    ERROR |      33 |     # Workaround for None values in the payload str
[2022-10-18 11:01:43,540] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:43,540] [                   HABApp]    ERROR |      _events = {'ItemStateEvent': <class 'HABApp.openhab.events.item_events.ItemStateEvent'>, 'ItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.ItemStateChangedEvent'>, 'ItemCommandEvent': <class 'HABApp.openhab.events.item_events.ItemCommandEvent'>, 'ItemAddedEvent': <class 'HABApp.openhab.events.item_events.ItemAddedEvent'>, 'ItemUpdatedEvent': <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>, 'ItemRemovedEvent': <class 'HABApp.openhab.events.item_events.ItemRemovedEvent'>, 'ItemStatePredictedEvent': <class 'HABApp.openhab.events.item_events.ItemStatePredictedEvent'>, 'GroupItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.GroupItemStateChangedEvent'>, 'ChannelTriggeredEvent': <class 'HABApp.openhab.events.channel_events.ChannelTriggeredEvent'>, 'ChannelDescriptionChangedEvent': <class 'HABApp.openhab.events.channel_events.ChannelDescriptionChangedEvent'>, 'ThingAddedEvent': <class 'HABApp.openhab.events.thing_events.ThingAddedEvent'>, 'ThingRemovedEvent': <class 'HABApp.openhab.events.thing_events.ThingRemovedEvent'>, 'ThingUpdatedEvent': <class 'HABApp.openhab.events.thing_events.ThingUpdatedEvent'>, 'ThingStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>, 'ThingStatusInfoChangedEvent': <class 'HABApp.openhab.events.thing_events.ThingStatusInfoChangedEvent'>, 'ThingFirmwareStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingFirmwareStatusInfoEvent'>, 'FirmwareStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingFirmwareStatusInfoEvent'>}
[2022-10-18 11:01:43,540] [                   HABApp]    ERROR |      _in_dict = {'type': 'ALIVE', 'interval': 10}
[2022-10-18 11:01:43,540] [                   HABApp]    ERROR |      _in_dict['type'] = 'ALIVE'
[2022-10-18 11:01:43,540] [                   HABApp]    ERROR |      event_type = 'ALIVE'
[2022-10-18 11:01:43,540] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:43,541] [                   HABApp]    ERROR | 
[2022-10-18 11:01:43,541] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-10-18 11:01:43,541] [                   HABApp]    ERROR | Traceback (most recent call last):
[2022-10-18 11:01:43,541] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31, in on_sse_event
[2022-10-18 11:01:43,541] [                   HABApp]    ERROR |     event = get_event(event_dict)
[2022-10-18 11:01:43,541] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31, in get_event
[2022-10-18 11:01:43,541] [                   HABApp]    ERROR |     topic: str = _in_dict['topic']
[2022-10-18 11:01:43,542] [                   HABApp]    ERROR | KeyError: 'topic'
[2022-10-18 11:01:43,542] [          HABApp.EventBus]     INFO |        HABApp.Errors: <HABAppException func_name: on_sse_event, exception: 'topic'>
[2022-10-18 11:01:46,946] [          HABApp.EventBus]     INFO |              iSl_pac: <ItemStateEvent name: iSl_pac, value: 8576>
[2022-10-18 11:01:46,951] [          HABApp.EventBus]     INFO |         iSl_yieldday: <ItemStateEvent name: iSl_yieldday, value: 11642>
[2022-10-18 11:01:46,953] [          HABApp.EventBus]     INFO |              iSl_pac: <ItemStateChangedEvent name: iSl_pac, value: 8576, old_value: 8560>
[2022-10-18 11:01:46,955] [          HABApp.EventBus]     INFO |    solarlog:meter:pv: <ThingStatusInfoEvent name: solarlog:meter:pv, status: ONLINE, detail: None>
[2022-10-18 11:01:46,956] [          HABApp.EventBus]     INFO |         iSl_yieldday: <ItemStateChangedEvent name: iSl_yieldday, value: 11642, old_value: 11571>
[2022-10-18 11:01:53,535] [                   HABApp]    ERROR | Error 'topic' in on_sse_event:
[2022-10-18 11:01:53,536] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31 in on_sse_event
[2022-10-18 11:01:53,536] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-10-18 11:01:53,536] [                   HABApp]    ERROR |      28 | def on_sse_event(event_dict: dict):
[2022-10-18 11:01:53,536] [                   HABApp]    ERROR |      29 |     try:
[2022-10-18 11:01:53,537] [                   HABApp]    ERROR |      30 |         # Lookup corresponding OpenHAB event
[2022-10-18 11:01:53,537] [                   HABApp]    ERROR | -->  31 |         event = get_event(event_dict)
[2022-10-18 11:01:53,537] [                   HABApp]    ERROR |      33 |         # Update item in registry BEFORE posting to the event bus
[2022-10-18 11:01:53,537] [                   HABApp]    ERROR |      34 |         # so the items have the correct state when we process the event in a rule
[2022-10-18 11:01:53,538] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:53,538] [                   HABApp]    ERROR |      (ItemAddedEvent, ItemUpdatedEvent) = (<class 'HABApp.openhab.events.item_events.ItemAddedEvent'>, <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>)
[2022-10-18 11:01:53,538] [                   HABApp]    ERROR |      (ThingStatusInfoEvent, ThingUpdatedEvent) = (<class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>, <class 'HABApp.openhab.events.thing_events.ThingUpdatedEvent'>)
[2022-10-18 11:01:53,538] [                   HABApp]    ERROR |      e = KeyError('topic')
[2022-10-18 11:01:53,539] [                   HABApp]    ERROR |      event_dict = {'type': 'ALIVE', 'interval': 10}
[2022-10-18 11:01:53,539] [                   HABApp]    ERROR |      log = <Logger HABApp.openhab.connection (INFO)>
[2022-10-18 11:01:53,539] [                   HABApp]    ERROR |      TOPIC_ITEMS = 'openHAB.Items'
[2022-10-18 11:01:53,539] [                   HABApp]    ERROR |      TOPIC_THINGS = 'openHAB.Things'
[2022-10-18 11:01:53,539] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:53,540] [                   HABApp]    ERROR | 
[2022-10-18 11:01:53,540] [                   HABApp]    ERROR | File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31 in get_event
[2022-10-18 11:01:53,540] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-10-18 11:01:53,540] [                   HABApp]    ERROR |      29 | def get_event(_in_dict: dict) -> OpenhabEvent:
[2022-10-18 11:01:53,541] [                   HABApp]    ERROR |      30 |     event_type: str = _in_dict['type']
[2022-10-18 11:01:53,541] [                   HABApp]    ERROR | -->  31 |     topic: str = _in_dict['topic']
[2022-10-18 11:01:53,541] [                   HABApp]    ERROR |      33 |     # Workaround for None values in the payload str
[2022-10-18 11:01:53,541] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:53,542] [                   HABApp]    ERROR |      _events = {'ItemStateEvent': <class 'HABApp.openhab.events.item_events.ItemStateEvent'>, 'ItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.ItemStateChangedEvent'>, 'ItemCommandEvent': <class 'HABApp.openhab.events.item_events.ItemCommandEvent'>, 'ItemAddedEvent': <class 'HABApp.openhab.events.item_events.ItemAddedEvent'>, 'ItemUpdatedEvent': <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>, 'ItemRemovedEvent': <class 'HABApp.openhab.events.item_events.ItemRemovedEvent'>, 'ItemStatePredictedEvent': <class 'HABApp.openhab.events.item_events.ItemStatePredictedEvent'>, 'GroupItemStateChangedEvent': <class 'HABApp.openhab.events.item_events.GroupItemStateChangedEvent'>, 'ChannelTriggeredEvent': <class 'HABApp.openhab.events.channel_events.ChannelTriggeredEvent'>, 'ChannelDescriptionChangedEvent': <class 'HABApp.openhab.events.channel_events.ChannelDescriptionChangedEvent'>, 'ThingAddedEvent': <class 'HABApp.openhab.events.thing_events.ThingAddedEvent'>, 'ThingRemovedEvent': <class 'HABApp.openhab.events.thing_events.ThingRemovedEvent'>, 'ThingUpdatedEvent': <class 'HABApp.openhab.events.thing_events.ThingUpdatedEvent'>, 'ThingStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>, 'ThingStatusInfoChangedEvent': <class 'HABApp.openhab.events.thing_events.ThingStatusInfoChangedEvent'>, 'ThingFirmwareStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingFirmwareStatusInfoEvent'>, 'FirmwareStatusInfoEvent': <class 'HABApp.openhab.events.thing_events.ThingFirmwareStatusInfoEvent'>}
[2022-10-18 11:01:53,542] [                   HABApp]    ERROR |      _in_dict = {'type': 'ALIVE', 'interval': 10}
[2022-10-18 11:01:53,542] [                   HABApp]    ERROR |      _in_dict['type'] = 'ALIVE'
[2022-10-18 11:01:53,542] [                   HABApp]    ERROR |      event_type = 'ALIVE'
[2022-10-18 11:01:53,543] [                   HABApp]    ERROR |    ------------------------------------------------------------
[2022-10-18 11:01:53,543] [                   HABApp]    ERROR | 
[2022-10-18 11:01:53,543] [                   HABApp]    ERROR | --------------------------------------------------------------------------------
[2022-10-18 11:01:53,543] [                   HABApp]    ERROR | Traceback (most recent call last):
[2022-10-18 11:01:53,544] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31, in on_sse_event
[2022-10-18 11:01:53,544] [                   HABApp]    ERROR |     event = get_event(event_dict)
[2022-10-18 11:01:53,544] [                   HABApp]    ERROR |   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 31, in get_event
[2022-10-18 11:01:53,544] [                   HABApp]    ERROR |     topic: str = _in_dict['topic']
[2022-10-18 11:01:53,544] [                   HABApp]    ERROR | KeyError: 'topic'

i tried without success:

  • uninstalled habapp, deleted folder /opt/habapp and installed again
  • disabled my mqtt-things and 1wire-things
  • removed all rule files from habapp folder /rules and /lib

sorry i am lost with this error messages and would be glad if somebody could help me to eliminate them. thanks in advance

It’s a modified event type that came with 3.4.0 M3. Downgrading to 3.4 M2 will solve the issue.
The fix is already available in the dev branch. If you want to try it out you can install the dev branch.
Installation instruction can be found here. I’ll release the dev branch in the next 5 to 10 days.

1 Like

this did the trick, thank you very much!

9 posts were split to a new topic: Dynamically create HABApp Rules with auto discovery

What would be the best way to get the dates of the (oldest/…/newest) min and max values?

And I (as in google) could not find any documentation for return type OpenhabPersistenceData as it seems there is also a .from_dict() method?

If there is only one maximum you can do this:

max_value = -999_999
max_time = None
min_value = 999_999
min_time = None

for timestamp, value in returned_obj.data.items():
    if value > max_value:
        max_value = value
        max_time = timestamp
    if value < min_value:
        min_value = value
        min_time = timestamp

Ah, I see, thx. This is even nicer than list comprehension and sorting. Takes only one pass.
Why I was asking was that in my OH1 xtext based rule I had

Min = (TempIn.minimumSince(now.minusHours(hoursBack), dataStore).state as DecimalType)

So I wondered, if there was something similar in HABApp.