spacemanspiff2007 / HABApp

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

change of parameter in thing causes ValueError #330

Closed UrsusS closed 1 year ago

UrsusS commented 1 year ago

changing a parameter of a thing via UI causes an error:


2022-10-08 22:04:00.780 [ERROR] [HABApp                              ] - Error Unknown Event: ConfigStatusInfoEvent for {'topic': 'openhab/things/zwave:device:gehirn:node29/config/status', 'payload': '{"configStatusMessages":[{"parameterName":"config_11_2","type":"PENDING"}]}', 'type': 'ConfigStatusInfoEvent'} in on_sse_event:
2022-10-08 22:04:00.780 [ERROR] [HABApp                              ] - File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31 in on_sse_event
2022-10-08 22:04:00.781 [ERROR] [HABApp                              ] - --------------------------------------------------------------------------------
2022-10-08 22:04:00.782 [ERROR] [HABApp                              ] -      28 | def on_sse_event(event_dict: dict):
2022-10-08 22:04:00.782 [ERROR] [HABApp                              ] -      29 |     try:
2022-10-08 22:04:00.783 [ERROR] [HABApp                              ] -      30 |         # Lookup corresponding OpenHAB event
2022-10-08 22:04:00.783 [ERROR] [HABApp                              ] - -->  31 |         event = get_event(event_dict)
2022-10-08 22:04:00.784 [ERROR] [HABApp                              ] -      33 |         # Update item in registry BEFORE posting to the event bus
2022-10-08 22:04:00.784 [ERROR] [HABApp                              ] -      34 |         # so the items have the correct state when we process the event in a rule
2022-10-08 22:04:00.785 [ERROR] [HABApp                              ] -    ------------------------------------------------------------
2022-10-08 22:04:00.785 [ERROR] [HABApp                              ] -      (ItemAddedEvent, ItemUpdatedEvent) = (<class 'HABApp.openhab.events.item_events.ItemAddedEvent'>, <class 'HABApp.openhab.events.item_events.ItemUpdatedEvent'>)
2022-10-08 22:04:00.785 [ERROR] [HABApp                              ] -      (ThingStatusInfoEvent, ThingUpdatedEvent) = (<class 'HABApp.openhab.events.thing_events.ThingStatusInfoEvent'>, <class 'HABApp.openhab.events.thing_events.ThingUpdatedEvent'>)
2022-10-08 22:04:00.786 [ERROR] [HABApp                              ] -      e = ValueError('Unknown Event: ConfigStatusInfoEvent for {\'topic\': \'openhab/things/zwave:device:gehirn:node29/config/status\', \'payload\': \'{"configStatusMessages":[{"parameterName":"config_11_2","type":"PENDING"}]}\', \'type\': \'ConfigStatusInfoEvent\'}')
2022-10-08 22:04:00.786 [ERROR] [HABApp                              ] -      event_dict = {'topic': 'openhab/things/zwave:device:gehirn:node29/config/status', 'payload': '{"configStatusMessages":[{"parameterName":"config_11_2","type":"PENDING"}]}', 'type': 'ConfigStatusInfoEvent'}
2022-10-08 22:04:00.787 [ERROR] [HABApp                              ] -      log = <Logger HABApp.openhab.connection (INFO)>
2022-10-08 22:04:00.787 [ERROR] [HABApp                              ] -      TOPIC_ITEMS = 'openHAB.Items'
2022-10-08 22:04:00.787 [ERROR] [HABApp                              ] -      TOPIC_THINGS = 'openHAB.Things'
2022-10-08 22:04:00.788 [ERROR] [HABApp                              ] -    ------------------------------------------------------------
2022-10-08 22:04:00.788 [ERROR] [HABApp                              ] - 
2022-10-08 22:04:00.789 [ERROR] [HABApp                              ] - File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 43 in get_event
2022-10-08 22:04:00.789 [ERROR] [HABApp                              ] - --------------------------------------------------------------------------------
2022-10-08 22:04:00.789 [ERROR] [HABApp                              ] -      29 | def get_event(_in_dict: dict) -> OpenhabEvent:
2022-10-08 22:04:00.790 [ERROR] [HABApp                              ] -       (...)
2022-10-08 22:04:00.790 [ERROR] [HABApp                              ] -      40 |     try:
2022-10-08 22:04:00.791 [ERROR] [HABApp                              ] -      41 |         return _events[event_type].from_dict(topic, payload)
2022-10-08 22:04:00.791 [ERROR] [HABApp                              ] -      42 |     except KeyError:
2022-10-08 22:04:00.791 [ERROR] [HABApp                              ] - -->  43 |         raise ValueError(f'Unknown Event: {event_type:s} for {_in_dict}')
2022-10-08 22:04:00.792 [ERROR] [HABApp                              ] -    ------------------------------------------------------------
2022-10-08 22:04:00.792 [ERROR] [HABApp                              ] -      _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-08 22:04:00.793 [ERROR] [HABApp                              ] -      _in_dict = {'topic': 'openhab/things/zwave:device:gehirn:node29/config/status', 'payload': '{"configStatusMessages":[{"parameterName":"config_11_2","type":"PENDING"}]}', 'type': 'ConfigStatusInfoEvent'}
2022-10-08 22:04:00.793 [ERROR] [HABApp                              ] -      _in_dict['payload'] = '{"configStatusMessages":[{"parameterName":"config_11_2","type":"PENDING"}]}'
2022-10-08 22:04:00.793 [ERROR] [HABApp                              ] -      _in_dict['topic'] = 'openhab/things/zwave:device:gehirn:node29/config/status'
2022-10-08 22:04:00.794 [ERROR] [HABApp                              ] -      _in_dict['type'] = 'ConfigStatusInfoEvent'
2022-10-08 22:04:00.794 [ERROR] [HABApp                              ] -      event_type = 'ConfigStatusInfoEvent'
2022-10-08 22:04:00.795 [ERROR] [HABApp                              ] -      p_str = '{"configStatusMessages":[{"parameterName":"config_11_2","type":"PENDING"}]}'
2022-10-08 22:04:00.795 [ERROR] [HABApp                              ] -      payload = {'configStatusMessages': [{'parameterName': 'config_11_2', 'type': 'PENDING'}]}
2022-10-08 22:04:00.795 [ERROR] [HABApp                              ] -      topic = 'openhab/things/zwave:device:gehirn:node29/config/status'
2022-10-08 22:04:00.796 [ERROR] [HABApp                              ] -      '"NONE"' in p_str = False
2022-10-08 22:04:00.796 [ERROR] [HABApp                              ] -    ------------------------------------------------------------
2022-10-08 22:04:00.796 [ERROR] [HABApp                              ] - 
2022-10-08 22:04:00.797 [ERROR] [HABApp                              ] - --------------------------------------------------------------------------------
2022-10-08 22:04:00.797 [ERROR] [HABApp                              ] - Traceback (most recent call last):
2022-10-08 22:04:00.798 [ERROR] [HABApp                              ] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 41, in get_event
2022-10-08 22:04:00.798 [ERROR] [HABApp                              ] -     return _events[event_type].from_dict(topic, payload)
2022-10-08 22:04:00.798 [ERROR] [HABApp                              ] - KeyError: 'ConfigStatusInfoEvent'
2022-10-08 22:04:00.799 [ERROR] [HABApp                              ] - 
2022-10-08 22:04:00.799 [ERROR] [HABApp                              ] - During handling of the above exception, another exception occurred:
2022-10-08 22:04:00.799 [ERROR] [HABApp                              ] - 
2022-10-08 22:04:00.800 [ERROR] [HABApp                              ] - Traceback (most recent call last):
2022-10-08 22:04:00.800 [ERROR] [HABApp                              ] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/sse_handler.py", line 31, in on_sse_event
2022-10-08 22:04:00.801 [ERROR] [HABApp                              ] -     event = get_event(event_dict)
2022-10-08 22:04:00.801 [ERROR] [HABApp                              ] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/map_events.py", line 43, in get_event
2022-10-08 22:04:00.801 [ERROR] [HABApp                              ] -     raise ValueError(f'Unknown Event: {event_type:s} for {_in_dict}')
2022-10-08 22:04:00.802 [ERROR] [HABApp                              ] - ValueError: Unknown Event: ConfigStatusInfoEvent for {'topic': 'openhab/things/zwave:device:gehirn:node29/config/status', 'payload': '{"configStatusMessages":[{"parameterName":"config_11_2","type":"PENDING"}]}', 'type': 'ConfigStatusInfoEvent'}
spacemanspiff2007 commented 1 year ago

Which HABApp Version and openHAB version are you running? I tried reproducing the issue by changing the configuration of an Astro Thing but that generates a ThingStatusInfoEvent. Can you reproduce the issue and if so what are the steps?

UrsusS commented 1 year ago

HABApp 1.0.4 OpenHAB 3.4.0.M2

For me it is simple to reproduce: In the UI go to Things / / Thing / change a numeric configuration parameter / press save

[2022-10-13 18:16:59,097] [          HABApp.EventBus]     INFO |        HABApp.Errors: <HABAppException func_name: on_sse_event, exception: Unknown Event: ConfigStatusInfoEvent for {'topic': 'openhab/things/zwave:device:gehirn:node31/config/status', 'payload': '{"configStatusMessages":[{"parameterName":"config_11_2","type":"PENDING"}]}', 'type': 'ConfigStatusInfoEvent'}>
[2022-10-13 18:20:24,284] [          HABApp.EventBus]     INFO |        HABApp.Errors: <HABAppException func_name: on_sse_event, exception: Unknown Event: ConfigStatusInfoEvent for {'topic': 'openhab/things/zwave:device:gehirn:node31/config/status', 'payload': '{"configStatusMessages":[{"parameterName":"config_12_2","type":"PENDING"}]}', 'type': 'ConfigStatusInfoEvent'}>
[2022-10-13 18:20:28,808] [          HABApp.EventBus]     INFO |        HABApp.Errors: <HABAppException func_name: on_sse_event, exception: Unknown Event: ConfigStatusInfoEvent for {'topic': 'openhab/things/zwave:device:gehirn:node31/config/status', 'payload': '{"configStatusMessages":[{"parameterName":"config_12_2","type":"PENDING"}]}', 'type': 'ConfigStatusInfoEvent'}>
spacemanspiff2007 commented 1 year ago

Under /things/{thingUID}/config/status it shows the pending parameter

spacemanspiff2007 commented 1 year ago

1.0.5 provides a fix