spacemanspiff2007 / HABApp

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

Thing: provide more information #348

Closed UrsusS closed 1 year ago

UrsusS commented 1 year ago

I'm checking my network and zwave devices regularly for some health conditions. If these conditions are not met, I inform the user about e.g. the detailed device status and the location of the device.

Unfortunately the the thing item is not providing all information, which is available via the REST-interface (defined in OpenhabThingDefinition). I'm missing:

In older OH versions was no usefull information in the status description, but that has changed (with 3.3 ?) Here some examples of these status descriptions I've collected:

Also the data available via the Thing item seems to be static, while the information available via the REST-interface contains also information which changes frequently. An example is "zwave_lastwakeup", which I use for monitoring the health state of the zwave devices.

spacemanspiff2007 commented 1 year ago

Also the data available via the Thing item seems to be static

You can already make HABApp update the thing through the topic filter in the config.yml. Just set it to openhab/things/*instead of openhab/things/*/added,openhab/things/*/removed,openhab/things/*/status,openhab/things/*/statuschanged

Here some examples of these status descriptions I've collected:

Could you post a a RestAPI response which shows one of those?

UrsusS commented 1 year ago

I have a new issue which could be related to the changes of the topic filter.

2022-12-30 18:30:47.753 [ERROR] [HABApp.openhab.connection] - SSE request Error: Chunk too big
2022-12-30 18:30:47.757 [ERROR] [HABApp.openhab.connection] - Traceback (most recent call last):
2022-12-30 18:30:47.760 [ERROR] [HABApp.openhab.connection] -   File "/opt/habapp/lib/python3.9/site-packages/HABApp/openhab/connection_handler/http_connection.py", line 228, in start_sse_event_listener
2022-12-30 18:30:47.763 [ERROR] [HABApp.openhab.connection] -     async for event in event_source:
2022-12-30 18:30:47.764 [ERROR] [HABApp.openhab.connection] -   File "/opt/habapp/lib/python3.9/site-packages/aiohttp_sse_client/client.py", line 157, in __anext__
2022-12-30 18:30:47.766 [ERROR] [HABApp.openhab.connection] -     async for line_in_bytes in self._response.content:
2022-12-30 18:30:47.767 [ERROR] [HABApp.openhab.connection] -   File "/opt/habapp/lib/python3.9/site-packages/aiohttp/streams.py", line 35, in __anext__
2022-12-30 18:30:47.767 [ERROR] [HABApp.openhab.connection] -     rv = await self.read_func()
2022-12-30 18:30:47.768 [ERROR] [HABApp.openhab.connection] -   File "/opt/habapp/lib/python3.9/site-packages/aiohttp/streams.py", line 311, in readline
2022-12-30 18:30:47.769 [ERROR] [HABApp.openhab.connection] -     return await self.readuntil()
2022-12-30 18:30:47.770 [ERROR] [HABApp.openhab.connection] -   File "/opt/habapp/lib/python3.9/site-packages/aiohttp/streams.py", line 337, in readuntil
2022-12-30 18:30:47.771 [ERROR] [HABApp.openhab.connection] -     raise ValueError("Chunk too big")
2022-12-30 18:30:47.772 [ERROR] [HABApp.openhab.connection] - ValueError: Chunk too big
2022-12-30 18:30:47.772 [WARN ] [HABApp.openhab.connection] - Disconnected! Uncaught error in process_sse_events: Chunk too big
2022-12-30 18:31:20.017 [INFO ] [HABApp.openhab.connection] - Connected to OpenHAB version 3.4.0 (Release Build)
2022-12-30 18:31:21.506 [INFO ] [HABApp.openhab.items] - Updated 810 Items
2022-12-30 18:31:21.936 [INFO ] [HABApp.openhab.items] - Updated 20 Things

I have two servers, where one is my test machine, connected to the main machine with the remote openhab binding. When I import a new/modified item file to my main machine, I get these errors on my test machine.

spacemanspiff2007 commented 1 year ago

Here some examples of these status descriptions I've collected:

Could you post a a RestAPI response which shows one of those? It's available through Developer Tools -> Api Explorer -> things -> /things/{thingUID}

UrsusS commented 1 year ago

I had answered by mail, but it did not come through...

Here is one example of a thing with status description.

{
  "channels": [],
  "statusInfo": {
    "status": "OFFLINE",
    "statusDetail": "COMMUNICATION_ERROR",
    "description": "Node is not communicating with controller"
  },
  "editable": true,
  "label": "Z-Wave Node 049",
  "bridgeUID": "zwave:serial_zstick:gehirn",
  "configuration": {
    "action_heal": false,
    "binding_pollperiod": 7200,
    "node_id": 49
  },
  "properties": {
    "zwave_class_basic": "BASIC_TYPE_ROUTING_SLAVE",
    "zwave_class_generic": "GENERIC_TYPE_METER",
    "zwave_frequent": "false",
    "zwave_neighbours": "",
    "zwave_listening": "true",
    "zwave_version": "0.0",
    "zwave_nodeid": "49",
    "zwave_lastheal": "2022-11-25T14:08:55Z",
    "zwave_routing": "true",
    "zwave_beaming": "true",
    "zwave_secure": "false",
    "zwave_class_specific": "SPECIFIC_TYPE_WHOLE_HOME_METER_SIMPLE"
  },
  "UID": "zwave:device:gehirn:node49",
  "thingTypeUID": "zwave:device"
}
spacemanspiff2007 commented 1 year ago

Created https://github.com/openhab/openhab-core/issues/3309

spacemanspiff2007 commented 1 year ago

@UrsusS Could you set the HABApp.EventBus logger to debug in the logging.yml and get the raw event from openHAB that contains the description information?

UrsusS commented 1 year ago

Here is one:

[2023-04-23 10:37:02,494] [  HABApp.EventBus.openhab]    DEBUG | {"topic":"openhab/things/fsinternetradio:radio:RadioWiGa/status","payload":"{\"status\":\"OFFLINE\",\"statusDetail\":\"COMMUNICATION_ERROR\",\"description\":\"java.util.concurrent.ExecutionException: java.net.NoRouteToHostException: Keine Route zum Zielrechner\"}","type":"ThingStatusInfoEvent"}
[2023-04-23 10:37:02,495] [          HABApp.EventBus]     INFO | fsinternetradio:radio:RadioWiGa: <ThingStatusInfoEvent name: fsinternetradio:radio:RadioWiGa, status: OFFLINE, detail: COMMUNICATION_ERROR>
spacemanspiff2007 commented 1 year ago

@UrsusS Could you also provide a ThingStatusInfoChangedEvent?

UrsusS commented 1 year ago

Here it is:

[2023-05-19 05:22:52,797] [  HABApp.EventBus.openhab]    DEBUG | {"topic":"openhab/things/fsinternetradio:radio:TunerWoZi/statuschanged","payload":"[{\"status\":\"OFFLINE\",\"statusDetail\":\"COMMUNICATION_ERROR\",\"description\":\"java.util.concurrent.ExecutionException: java.net.NoRouteToHostException: Keine Route zum Zielrechner\"},{\"status\":\"OFFLINE\",\"statusDetail\":\"COMMUNICATION_ERROR\",\"description\":\"java.util.concurrent.TimeoutException: Total timeout 5000 ms elapsed\"}]","type":"ThingStatusInfoChangedEvent"}
[2023-05-19 05:22:52,797] [          HABApp.EventBus]     INFO | fsinternetradio:radio:TunerWoZi: <ThingStatusInfoChangedEvent name: fsinternetradio:radio:TunerWoZi, status: OFFLINE, detail: COMMUNICATION_ERROR, old_status: OFFLINE, old_detail: COMMUNICATION_ERROR>
spacemanspiff2007 commented 1 year ago

Thanks for your help! The description will be part of the next release. If you are eager you can try out the dev branch.

UrsusS commented 1 year ago

That's great, thanks a lot. What is the recommended way to install the dev version? I used to use the offical branch.

spacemanspiff2007 commented 1 year ago

See docs. Be aware that there might be breaking changes

UrsusS commented 1 year ago

I've now installed the dev version and I get some warnings and one error. Should I worry about them? When I remember right I had installed HABApp with openhabina-config.

Ok, now I have tried several times to install HABApp and with every try he uninstalled a package. Finally he could install it and it started up.

(habapp) openhabian@gehirn:/opt/habapp $ python3 -m pip install git+https://github.com/spacemanspiff2007/HABApp.git@Develop
WARNING: Ignoring invalid distribution -abapp (/opt/habapp/lib/python3.9/site-packages)
WARNING: Ignoring invalid distribution -abapp (/opt/habapp/lib/python3.9/site-packages)
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting git+https://github.com/spacemanspiff2007/HABApp.git@Develop
  Cloning https://github.com/spacemanspiff2007/HABApp.git (to revision Develop) to /tmp/pip-req-build-3jq62fot
  Running command git clone --filter=blob:none --quiet https://github.com/spacemanspiff2007/HABApp.git /tmp/pip-req-build-3jq62fot
  Running command git checkout -b Develop --track origin/Develop
  Zu neuem Branch 'Develop' gewechselt
  Branch 'Develop' folgt nun Remote-Branch 'Develop' von 'origin'.
  Resolved https://github.com/spacemanspiff2007/HABApp.git to commit adef5246bb5c1cdc569c1356c0bc6964db2b57d1
  Preparing metadata (setup.py) ... done
Collecting aiohttp==3.8.4
  Downloading https://www.piwheels.org/simple/aiohttp/aiohttp-3.8.4-cp39-cp39-linux_armv7l.whl (926 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 926.6/926.6 kB 3.0 MB/s eta 0:00:00
Collecting pydantic==1.10.8
  Downloading https://www.piwheels.org/simple/pydantic/pydantic-1.10.8-cp39-cp39-linux_armv7l.whl (3.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 3.5 MB/s eta 0:00:00
Requirement already satisfied: pendulum==2.1.2 in ./lib/python3.9/site-packages (from HABApp==1.1.0.dev2) (2.1.2)
Collecting bidict==0.22.1
  Downloading https://www.piwheels.org/simple/bidict/bidict-0.22.1-py3-none-any.whl (35 kB)
Collecting watchdog==3.0.0
  Downloading watchdog-3.0.0-py3-none-manylinux2014_armv7l.whl (82 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 82.0/82.0 kB 539.4 kB/s eta 0:00:00
Requirement already satisfied: ujson==5.7.0 in ./lib/python3.9/site-packages (from HABApp==1.1.0.dev2) (5.7.0)
Requirement already satisfied: paho-mqtt==1.6.1 in ./lib/python3.9/site-packages (from HABApp==1.1.0.dev2) (1.6.1)
Requirement already satisfied: immutables==0.19 in ./lib/python3.9/site-packages (from HABApp==1.1.0.dev2) (0.19)
Requirement already satisfied: eascheduler==0.1.8 in ./lib/python3.9/site-packages (from HABApp==1.1.0.dev2) (0.1.8)
Requirement already satisfied: easyconfig==0.2.8 in ./lib/python3.9/site-packages (from HABApp==1.1.0.dev2) (0.2.8)
Requirement already satisfied: stack_data==0.6.2 in ./lib/python3.9/site-packages (from HABApp==1.1.0.dev2) (0.6.2)
Requirement already satisfied: colorama==0.4.6 in ./lib/python3.9/site-packages (from HABApp==1.1.0.dev2) (0.4.6)
Requirement already satisfied: voluptuous==0.13.1 in ./lib/python3.9/site-packages (from HABApp==1.1.0.dev2) (0.13.1)
Collecting typing-extensions==4.6.1
  Downloading https://www.piwheels.org/simple/typing-extensions/typing_extensions-4.6.1-py3-none-any.whl (31 kB)
Requirement already satisfied: aiohttp-sse-client==0.2.1 in ./lib/python3.9/site-packages (from HABApp==1.1.0.dev2) (0.2.1)
Requirement already satisfied: multidict<7.0,>=4.5 in ./lib/python3.9/site-packages (from aiohttp==3.8.4->HABApp==1.1.0.dev2) (6.0.2)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in ./lib/python3.9/site-packages (from aiohttp==3.8.4->HABApp==1.1.0.dev2) (2.1.1)
Requirement already satisfied: aiosignal>=1.1.2 in ./lib/python3.9/site-packages (from aiohttp==3.8.4->HABApp==1.1.0.dev2) (1.2.0)
Requirement already satisfied: yarl<2.0,>=1.0 in ./lib/python3.9/site-packages (from aiohttp==3.8.4->HABApp==1.1.0.dev2) (1.8.1)
Requirement already satisfied: frozenlist>=1.1.1 in ./lib/python3.9/site-packages (from aiohttp==3.8.4->HABApp==1.1.0.dev2) (1.3.1)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in ./lib/python3.9/site-packages (from aiohttp==3.8.4->HABApp==1.1.0.dev2) (4.0.2)
Requirement already satisfied: attrs>=17.3.0 in ./lib/python3.9/site-packages (from aiohttp==3.8.4->HABApp==1.1.0.dev2) (22.1.0)
Requirement already satisfied: astral==3.2 in ./lib/python3.9/site-packages (from eascheduler==0.1.8->HABApp==1.1.0.dev2) (3.2)
Requirement already satisfied: ruamel.yaml<0.18,>=0.17 in ./lib/python3.9/site-packages (from easyconfig==0.2.8->HABApp==1.1.0.dev2) (0.17.21)
Requirement already satisfied: python-dateutil<3.0,>=2.6 in ./lib/python3.9/site-packages (from pendulum==2.1.2->HABApp==1.1.0.dev2) (2.8.2)
Requirement already satisfied: pytzdata>=2020.1 in ./lib/python3.9/site-packages (from pendulum==2.1.2->HABApp==1.1.0.dev2) (2020.1)
Requirement already satisfied: executing>=1.2.0 in ./lib/python3.9/site-packages (from stack_data==0.6.2->HABApp==1.1.0.dev2) (1.2.0)
Requirement already satisfied: pure-eval in ./lib/python3.9/site-packages (from stack_data==0.6.2->HABApp==1.1.0.dev2) (0.2.2)
Requirement already satisfied: asttokens>=2.1.0 in ./lib/python3.9/site-packages (from stack_data==0.6.2->HABApp==1.1.0.dev2) (2.2.1)
Requirement already satisfied: six in ./lib/python3.9/site-packages (from asttokens>=2.1.0->stack_data==0.6.2->HABApp==1.1.0.dev2) (1.16.0)
Requirement already satisfied: ruamel.yaml.clib>=0.2.6 in ./lib/python3.9/site-packages (from ruamel.yaml<0.18,>=0.17->easyconfig==0.2.8->HABApp==1.1.0.dev2) (0.2.6)
Requirement already satisfied: idna>=2.0 in ./lib/python3.9/site-packages (from yarl<2.0,>=1.0->aiohttp==3.8.4->HABApp==1.1.0.dev2) (3.3)
WARNING: Ignoring invalid distribution -abapp (/opt/habapp/lib/python3.9/site-packages)
Installing collected packages: watchdog, typing-extensions, bidict, pydantic, aiohttp, HABApp
  Attempting uninstall: watchdog
    WARNING: Ignoring invalid distribution -abapp (/opt/habapp/lib/python3.9/site-packages)
    Found existing installation: watchdog 2.2.1
    Uninstalling watchdog-2.2.1:
      Successfully uninstalled watchdog-2.2.1
ERROR: Could not install packages due to an OSError: [Errno 13] Keine Berechtigung: 'LICENSE'
Check the permissions.

WARNING: Ignoring invalid distribution -abapp (/opt/habapp/lib/python3.9/site-packages)
WARNING: Ignoring invalid distribution -abapp (/opt/habapp/lib/python3.9/site-packages)
WARNING: Ignoring invalid distribution -abapp (/opt/habapp/lib/python3.9/site-packages)

[notice] A new release of pip is available: 23.0 -> 23.1.2
[notice] To update, run: pip install --upgrade pip
spacemanspiff2007 commented 1 year ago

Fixed in 1.1.0

UrsusS commented 11 months ago

Thanks a lot, it works like a charm!