HabApp - Memory Errors

Hi all,

Just got HabApp going on a RPI4 4gb running 3.1M3 and I’m getting these errors in the log. I haven’t gotten around to trying to install the missing requests module:

[2021-04-06 20:24:00,297] [                   HABApp]     INFO | HABApp Version 0.20.1
[2021-04-06 20:24:00,300] [   HABApp.mqtt.connection]     INFO | Connecting to localhost:1883
[2021-04-06 20:24:00,301] [     HABApp.openhab.thing]     INFO | Config folder does not exist - textual thing config disabled!
[2021-04-06 20:24:00,301] [    HABApp.RuleParameters]     INFO | Parameter files disabled: Folder /etc/openhab/habapp/params does not exist!
[2021-04-06 20:24:00,308] [   HABApp.mqtt.connection]     INFO | Connection Accepted.
[2021-04-06 20:24:00,419] [HABApp.openhab.connection]     INFO | Connected to OpenHAB instance 9d09eeb9-3a33-4067-a483-ac5b81602575
[2021-04-06 20:24:00,420] [HABApp.openhab.connection]     INFO | OpenHAB version 3.1.0.M3 (Milestone Build)
[2021-04-06 20:24:01,310] [   HABApp.mqtt.connection]    ERROR | Disconnect: Out of memory. (1)
[2021-04-06 20:24:02,302] [     HABApp.openhab.items]     INFO | Updated 1591 Items
[2021-04-06 20:24:02,314] [   HABApp.mqtt.connection]     INFO | Connection Accepted.
[2021-04-06 20:24:02,953] [     HABApp.openhab.items]     INFO | Updated 239 Things
[2021-04-06 20:24:03,316] [   HABApp.mqtt.connection]    ERROR | Disconnect: Out of memory. (1)
[2021-04-06 20:24:04,321] [   HABApp.mqtt.connection]     INFO | Connection Accepted.
[2021-04-06 20:24:05,326] [   HABApp.mqtt.connection]    ERROR | Disconnect: Out of memory. (1)
[2021-04-06 20:24:05,532] [             HABApp.Rules]     INFO | Added rule "Telemetry_Weather" from telemetry-dailymetrics.py
[2021-04-06 20:24:06,330] [   HABApp.mqtt.connection]     INFO | Connection Accepted.
[2021-04-06 20:24:06,888] [             HABApp.Rules]    ERROR | Error "No module named 'requests'" in load:
[2021-04-06 20:24:06,889] [             HABApp.Rules]    ERROR | Could not load /etc/openhab/habapp/rules/test.py!
[2021-04-06 20:24:06,889] [             HABApp.Rules]    ERROR | File "/opt/habapp/lib/python3.7/site-packages/HABApp/rule_manager/rule_file.py", line 79, in load
[2021-04-06 20:24:06,889] [             HABApp.Rules]    ERROR |     self.create_rules(created_rules)

Any tips on where to look?

If I remove the MQTT connection info from the config.yaml file, it seems to work. At least no errors…

Not 100% sure I need the MQTT connection?

I am tagging @Spaceman_Spiff for you, He is the developer.

If you want to do stuff with MQTT then I guess you need it. :wink:

Can you check if you have already connected to the MQTT broker with the same client id e.g. from another machine?
Duplicate client ids sometimes results in rather strange error messages

1 Like

Shame on me. I didn’t pay much attention to the MQTT settings expecting that I wouldn’t want to interact with MQTT directly, and it looks like it was trying to establish a TLS connection. If I restore the default settings, turn off tis_insecure and change the port to 1883, even without picking a host, the error appears to go away.

So, is the use case for MQTT to be able to connect to a broker (either the one that OpenHAB uses primarily or another one) and do some processing of MQTT events that are not directly linked to OpenHAB items?

Yes, exactly.
The mqtt handling through openhab items quickly gets annoying if you have very much topics to process.
You can abstract all the logic in habapp and just create proxy items in openhab for interaction/showing information.
Additionally you can directly connect any smart home system that supports mqtt so you are not bound to openhab.

Cool - I’m still getting the hang of it, but think it’ll be much more forgiving for me than DSL. I need to get my IDE working better when I have some time but think I’ll really enjoy using it. Also I think I saw that you can tag scripts to appear in the MainUI somehow, which would be helpful.

If you use PyCharm you just have to install HABApp in your python environment (of pycharm) and then you’ll have full syntax highlighting and static error checks!

That’s only possible for openhab rules, not HABApp rules.

1 Like

Thanks. Has anyone got it running on a Mac? I’m still a bit mystified on brew, venv and ensuring an IDE can point to the right items… will go google now, but didn’t see it in the docs.

One other option might be to use Docker. Just a thought,

Yeah, I thought about that, and I do have a docker server running, and on the Mac, but I’m still a novice there too. I’m not 100% sure how to point the IDE at a docker container to get those benefits, or even if it is possible. Will look at this weekend (so much to do!).

If it’s your only python project you don’t need the venv.


If you use PyCharm it’s:
File → Settings → Project: YouProjectName → Python Interpreter
Then click on the small + button on the right side and search for HABApp.
Select it and click “Install Package”.
Then you should have type hints and auto complete for your rules.

1 Like