Getting started with habapp failing

I am trying to get habapp working and not having any luck.
system: Raspberry Pi, running buster, openhab 3.1 and python 3.7.3

I am troubleshooting my problem as though it is an authentication issue but I am out of ideas. I have a username and password in my /etc/openhab/habapp/comfig.yml file. Habapp is running.

root@zippy:/home/chris# service habapp status
● habapp.service - HABApp
   Loaded: loaded (/etc/systemd/system/habapp.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2021-09-29 13:28:11 PDT; 2s ago
     Docs: https://habapp.readthedocs.io
 Main PID: 6896 (habapp)
    Tasks: 1 (limit: 2059)
   CGroup: /system.slice/habapp.service
           └─6896 /opt/habapp/bin/python3 /opt/habapp/bin/habapp -c /etc/openhab/habapp

Sep 29 13:28:11 zippy systemd[1]: Started HABApp.

My /var/log/openhab/HABapp.log is

root@zippy:/home/chris# cat /var/log/openhab/HABApp.log
[2021-09-29 13:28:15,308] [                   HABApp]     INFO | HABApp Version 0.30.3
[2021-09-29 13:28:15,315] [   HABApp.mqtt.connection]     INFO | MQTT disabled
[2021-09-29 13:28:15,317] [     HABApp.openhab.thing]     INFO | Config folder does not exist - textual thing config disabled!
[2021-09-29 13:28:15,318] [    HABApp.RuleParameters]     INFO | Parameter files disabled: Folder /etc/openhab/habapp/params does not exist!
[2021-09-29 13:28:20,513] [HABApp.openhab.connection]  WARNING | Status 403 for GET http://localhost:8080/rest/uuid/
[2021-09-29 13:28:20,515] [HABApp.openhab.connection]     INFO | ... offline!
[2021-09-29 13:28:26,568] [HABApp.openhab.connection]  WARNING | Status 403 for GET http://localhost:8080/rest/uuid/
[2021-09-29 13:28:26,569] [HABApp.openhab.connection]     INFO | ... offline!
[2021-09-29 13:28:33,611] [HABApp.openhab.connection]  WARNING | Status 403 for GET http://localhost:8080/rest/uuid/
[2021-09-29 13:28:33,612] [HABApp.openhab.connection]     INFO | ... offline!
[2021-09-29 13:28:42,638] [HABApp.openhab.connection]  WARNING | Status 403 for GET http://localhost:8080/rest/uuid/
[2021-09-29 13:28:42,639] [HABApp.openhab.connection]     INFO | ... offline!
[2021-09-29 13:28:55,667] [HABApp.openhab.connection]  WARNING | Status 403 for GET http://localhost:8080/rest/uuid/
[2021-09-29 13:28:55,669] [HABApp.openhab.connection]     INFO | ... offline!
[2021-09-29 13:29:16,698] [HABApp.openhab.connection]  WARNING | Status 403 for GET http://localhost:8080/rest/uuid/

Allow Basic Authentication is turned on, though I have tried switch off.
I tried purging my openhab installation and starting over, but no matter what I do, I can’t get this resolved. The documentation for this app is so good, I am sure I am just missing something. Please help.
Thanks,
Chris

The UUID should work even without authentication so this looks really strange.
When you replace localhost with the IP of the device does it work in your browser?

Can you check if “implicit user role” is enabled (should be) under api-security in the openhab settings?

Thanks for your response. I tried replacing the local host with the IP, but same results. That lead me to look more into API Security on my openhab installations. There are parameters missing under the advanced settings. I will look into that more.

Thanks
Chris

Hm - strange. Does the API-Explorer in your installation work?

Yes, the explorer works, like I think it should. However if i browse on my laptop to http://zippy:8080/rest/uuid/ (my openhab server) I get

error	
message	"Authentication required"
http-code	401

This is with “basic authentication” turned off and" Implicit user role for unauthenticated requests" off. The cache setting is missing.

Can you enable the “implicit user role”? Are you on 3.1 release or on a earlier milestone?

I enabled “implicit user role” got the same authentication required. Openhab is at 3.1 stable release.

It seeks like basic authentication mode is not changing.

Are you sure?

If the cache setting is missing it seems you are running an earlier version.
Have you checked “advanced settings” so you see all options?

That’s how 3.1.0 - Release Build should look like.

No, I thought it was 3.1. I checked help and about and it is openHAB 3.0.2. Darn, I am sorry. I will upgrade and check again and get back to you.

Things are looking better with the update to openhab 3.1. I had mistakenly thought my test instance of openhab was at the same level as my production instance.

Now I have “Basic Authentication” and “Implicit User Role” enabled. My logs are looking better, but there still seems to be a problem with connecting to the “rest/things”, but it is a warning and maybe not an issue.

root@zippy:/home/chris# cat /var/log/openhab/HABApp.log 
[2021-09-30 13:47:13,226] [                   HABApp]     INFO | HABApp Version 0.30.3
[2021-09-30 13:47:13,233] [   HABApp.mqtt.connection]     INFO | Connecting to 192.168.92.208:8883
[2021-09-30 13:47:13,237] [     HABApp.openhab.thing]     INFO | Config folder does not exist - textual thing config disabled!
[2021-09-30 13:47:13,238] [    HABApp.RuleParameters]     INFO | Parameter files disabled: Folder /etc/openhab/habapp/params does not exist!
[2021-09-30 13:47:13,707] [HABApp.openhab.connection]     INFO | Connected to OpenHAB instance f91f5793-29c0-4821-aa32-88e452bd22f1
[2021-09-30 13:47:13,708] [HABApp.openhab.connection]     INFO | OpenHAB version 3.1.0 (Release Build)
[2021-09-30 13:47:13,853] [     HABApp.openhab.items]     INFO | Updated 10 Items
[2021-09-30 13:47:13,875] [HABApp.openhab.connection]  WARNING | Disconnected! Expected success but got status 401 for /rest/things/
[2021-09-30 13:47:15,213] [HABApp.openhab.connection]     INFO | Connected to OpenHAB instance f91f5793-29c0-4821-aa32-88e452bd22f1
[2021-09-30 13:47:15,214] [HABApp.openhab.connection]     INFO | OpenHAB version 3.1.0 (Release Build)
[2021-09-30 13:47:15,326] [     HABApp.openhab.items]     INFO | Updated 10 Items
[2021-09-30 13:47:15,348] [HABApp.openhab.connection]  WARNING | Disconnected! Expected success but got status 401 for /rest/things/
[2021-09-30 13:47:17,694] [HABApp.openhab.connection]     INFO | Connected to OpenHAB instance f91f5793-29c0-4821-aa32-88e452bd22f1
[2021-09-30 13:47:17,695] [HABApp.openhab.connection]     INFO | OpenHAB version 3.1.0 (Release Build)
[2021-09-30 13:47:17,807] [     HABApp.openhab.items]     INFO | Updated 10 Items
[2021-09-30 13:47:17,835] [HABApp.openhab.connection]  WARNING | Disconnected! Expected success but got status 401 for /rest/things/
[2021-09-30 13:47:18,922] [              HABApp.Rule]  WARNING | /opt/habapp/lib/python3.7/site-packages/HABApp/rule/rule.py:245: DeprecationWarning:self.run_soon is deprecated. Please use self.run.soon
[2021-09-30 13:47:18,931] [             HABApp.Rules]     INFO | Added rule "MyFirstRule" from rules/easy2.py
[2021-09-30 13:47:19,021] [             HABApp.Rules]     INFO | Added rule "MyRule" from rules/sched.py
[2021-09-30 13:47:22,240] [HABApp.openhab.connection]     INFO | Connected to OpenHAB instance f91f5793-29c0-4821-aa32-88e452bd22f1
[2021-09-30 13:47:22,241] [HABApp.openhab.connection]     INFO | OpenHAB version 3.1.0 (Release Build)
[2021-09-30 13:47:22,355] [     HABApp.openhab.items]     INFO | Updated 10 Items
[2021-09-30 13:47:22,380] [HABApp.openhab.connection]  WARNING | Disconnected! Expected success but got status 401 for /rest/things/
[2021-09-30 13:47:30,710] [HABApp.openhab.connection]     INFO | Connected to OpenHAB instance f91f5793-29c0-4821-aa32-88e452bd22f1
[2021-09-30 13:47:30,711] [HABApp.openhab.connection]     INFO | OpenHAB version 3.1.0 (Release Build)
[2021-09-30 13:47:30,845] [     HABApp.openhab.items]     INFO | Updated 10 Items
[2021-09-30 13:47:30,868] [HABApp.openhab.connection]  WARNING | Disconnected! Expected success but got status 401 for /rest/things/

It does look like habapp is working, but I am pretty much a novice at Python3. Test rules that I copied from examples are running.

Thanks,
Chris

It is! It’s still 401 unauthorized. Maybe you have a typo in your openhab user/password?

I am pretty sure it isn’t a typo. To verify, I edited my config.yml file with a new username and password. I had tried it before with the username and password values at ‘’. That gave 401 errors. Then I added the new credentials with the karaf console. For good measure, I changed the cache expiration time to 0. Errors went from 401 errors to 403.

[2021-09-30 20:48:14,798] [            HABApp.Worker]    ERROR | 
[2021-09-30 20:48:14,798] [            HABApp.Worker]    ERROR | UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 37: invalid start byte
[2021-09-30 20:48:14,812] [HABApp.openhab.connection]  WARNING | Status 404 for PUT http://localhost:8080/rest/items/HABApp_Ping/state/ NULL
[2021-09-30 20:48:15,117] [             HABApp.Rules]  WARNING | Found no instances of HABApp.Rule in /etc/openhab/habapp/rules/._easy2.py
[2021-09-30 20:48:15,132] [              HABApp.Rule]  WARNING | /opt/habapp/lib/python3.7/site-packages/HABApp/rule/rule.py:245: DeprecationWarning:self.run_soon is deprecated. Please use self.run.soon
[2021-09-30 20:48:15,138] [             HABApp.Rules]     INFO | Added rule "MyFirstRule" from rules/easy2.py
[2021-09-30 20:48:15,176] [             HABApp.Rules]     INFO | Added rule "MyHolidayRule" from rules/holiday.py
[2021-09-30 20:48:15,237] [             HABApp.Rules]     INFO | Added rule "MyRule" from rules/sched.py
[2021-09-30 20:48:16,397] [HABApp.openhab.connection]  WARNING | Disconnected! Expected success but got status 403 for /rest/things/
[2021-09-30 20:49:22,911] [HABApp.openhab.connection]     INFO | Connected to OpenHAB instance f91f5793-29c0-4821-aa32-88e452bd22f1
[2021-09-30 20:49:22,913] [HABApp.openhab.connection]     INFO | OpenHAB version 3.1.0 (Release Build)
[2021-09-30 20:49:28,121] [     HABApp.openhab.items]     INFO | Updated 10 Items
[2021-09-30 20:49:31,187] [HABApp.openhab.connection]  WARNING | Status 404 for PUT http://localhost:8080/rest/items/HABApp_Ping/state/ NULL
[2021-09-30 20:49:33,215] [HABApp.openhab.connection]  WARNING | Disconnected! Expected success but got status 403 for /rest/things/

I noticed a new status 404 warning that I had not noticed before.

I am running on very low sleep for the past few days, and could have messed something up. Probably about time to give it up for the evening.

Thanks
Chris

Don’t do that - 6h is good!

It’s the openhab ping you configured in your config.yml.


You can always check if the auth settings are correct by manually executing the get command in the browser:
http://user:password@YOUR_OPENHAB_IP:8080/rest/things

I suggest you make that work first before trying anything else.
It’s still an auth issue - even if it’s not clear atm why.

Thanks for the response. The syntax for the url address is a great help. I will troubleshoot going down that path.

I changed the user to and an administrator, and now habapp seems to be working.

Thanks,
Chris

1 Like