HABApp - Easy automation with openHAB

What kind of problems are you experiencing?
I was under the impression that it should work on ARM, too.

Nice! :slight_smile:

Seems it (0.6.9) still isn’t out on pypi? Ref https://pypi.org/project/HABApp/#history

Yea - I made the release but forgot to push it so pypi. Sorry again, will do it this evening.

1 Like
pi@raspberrypi:~ $ sudo docker run spacemanspiff2007/habapp
standard_init_linux.go:211: exec user process caused "exec format error"

I’ve previously seen this error when the image isn’t ARM compatible.

Hm - I can’t seem to figure out how to create a build for multiple architectures with the dockerhub autobuild.
Could you build the image yourself on the pi? It should work out of the box without changes to the dockerfile.
Otherwise you still could use a venv since python >= 3.6 is available for the pi and it’s really easy to setup.

I’ve downloaded the Dockerfile and run a docker build but not quite sure what to do next as the documentation doesn’t give an example of how to run the container. I get the following stacktrace when trying to run it:

pi@raspberrypi:~/HABApp $ sudo docker build . -t habapp
Sending build context to Docker daemon  2.751MB
Step 1/8 : FROM python:3.7-alpine
 ---> 9947ecfb1df0
Step 2/8 : VOLUME [ "/config"]
 ---> Using cache
 ---> 397939c7f65b
Step 3/8 : RUN apk add --no-cache     tzdata     musl-dev     gcc
 ---> Using cache
 ---> a9678cdc69ae
Step 4/8 : RUN mkdir -p /usr/src/app
 ---> Using cache
 ---> f5814d5d1c84
Step 5/8 : WORKDIR /usr/src/app
 ---> Using cache
 ---> eda43ad91b7f
Step 6/8 : COPY . .
 ---> Using cache
 ---> 44fb94b980cc
Step 7/8 : RUN pip3 install .
 ---> Using cache
 ---> 3db569e6ae5b
Step 8/8 : CMD [ "python", "-m", "HABApp", "--config", "/config" ]
 ---> Using cache
 ---> 1a41b3eae8eb
Successfully built 1a41b3eae8eb
Successfully tagged habapp:latest
pi@raspberrypi:~/HABApp $ sudo docker run habapp
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/local/lib/python3.7/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/local/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/src/app/HABApp/__init__.py", line 3, in <module>
    import HABApp.config
  File "/usr/src/app/HABApp/config/__init__.py", line 1, in <module>
    from .config import Config, InvalidConfigException
  File "/usr/src/app/HABApp/config/config.py", line 17, in <module>
    from HABApp.runtime import FileEventTarget
  File "/usr/src/app/HABApp/runtime/__init__.py", line 3, in <module>
    from .runtime import Runtime
  File "/usr/src/app/HABApp/runtime/runtime.py", line 5, in <module>
    import HABApp.rule_manager
  File "/usr/src/app/HABApp/rule_manager/__init__.py", line 3, in <module>
    from .rule_parameters import RuleParameters
  File "/usr/src/app/HABApp/rule_manager/rule_parameters.py", line 15, in <module>
    _yml_setup = ruamel.yaml.YAML()
AttributeError: module 'ruamel.yaml' has no attribute 'YAML'

Strange - it seems the installation (of the python package) did not go through properly.
Could you try:

sudo docker build  --no-cache --pull . -t habapp

Just to make sure that this is not a cache error

Hm, I wonder if I’m seeing an error that used to occur in OH a while back, when I edit a rule and save it via SMB/CIFS the file is added multiple times. Here’s an example where I save a test.py script that only outputs “test1”.

HABapp.log

[2019-08-07 19:52:07,268] [ HABApp.Rules] INFO | Added rule “MyOpenhabTestRule” from test.py
[2019-08-07 19:52:07,277] [ HABApp.Rules] INFO | Added rule “MyOpenhabTestRule” from test.py
[2019-08-07 19:52:07,282] [ HABApp.Rules] INFO | Added rule “MyOpenhabTestRule” from test.py
[2019-08-07 19:52:07,292] [ HABApp.Rules] INFO | Added rule “MyOpenhabTestRule” from test.py

log.debug():

[2019-08-07 19:52:07,266] [ MyRule] DEBUG | Test1
[2019-08-07 19:52:07,275] [ MyRule] DEBUG | Test1
[2019-08-07 19:52:07,281] [ MyRule] DEBUG | Test1
[2019-08-07 19:52:07,291] [ MyRule] DEBUG | Test1

If I edit the file localy on my server via shell/bash with nano/vim or whatever, the file is added only once. Seems to be something with the “file has changed” trigger in the OS or samba (linux)


Could you post the complete log (set to level DEBUG)?
File loading should actually be serialized.

[2019-08-08 09:39:37,996] [             HABApp.Rules]    DEBUG | Removing file: /etc/openhab2/rules/test.py
[2019-08-08 09:39:37,998] [             HABApp.Rules]    DEBUG | File /etc/openhab2/rules/test.py successfully unloaded!
[2019-08-08 09:39:37,999] [             HABApp.Rules]    DEBUG | Loading file: /etc/openhab2/rules/test.py
[2019-08-08 09:39:38,005] [             HABApp.Rules]     INFO | Added rule "MyOpenhabTestRule" from test.py
[2019-08-08 09:39:38,006] [             HABApp.Rules]    DEBUG | File /etc/openhab2/rules/test.py successfully loaded!
[2019-08-08 09:39:38,101] [             HABApp.Rules]    DEBUG | Removing file: /etc/openhab2/rules/test.py
[2019-08-08 09:39:38,103] [             HABApp.Rules]    DEBUG | File /etc/openhab2/rules/test.py successfully unloaded!
[2019-08-08 09:39:38,104] [             HABApp.Rules]    DEBUG | Loading file: /etc/openhab2/rules/test.py
[2019-08-08 09:39:38,109] [             HABApp.Rules]     INFO | Added rule "MyOpenhabTestRule" from test.py
[2019-08-08 09:39:38,110] [             HABApp.Rules]    DEBUG | File /etc/openhab2/rules/test.py successfully loaded!
[2019-08-08 09:39:38,157] [             HABApp.Rules]    DEBUG | Removing file: /etc/openhab2/rules/test.py
[2019-08-08 09:39:38,159] [             HABApp.Rules]    DEBUG | File /etc/openhab2/rules/test.py successfully unloaded!
[2019-08-08 09:39:38,160] [             HABApp.Rules]    DEBUG | Loading file: /etc/openhab2/rules/test.py
[2019-08-08 09:39:38,165] [             HABApp.Rules]     INFO | Added rule "MyOpenhabTestRule" from test.py
[2019-08-08 09:39:38,166] [             HABApp.Rules]    DEBUG | File /etc/openhab2/rules/test.py successfully loaded!
[2019-08-08 09:39:38,258] [             HABApp.Rules]    DEBUG | Removing file: /etc/openhab2/rules/test.py
[2019-08-08 09:39:38,260] [             HABApp.Rules]    DEBUG | File /etc/openhab2/rules/test.py successfully unloaded!
[2019-08-08 09:39:38,262] [             HABApp.Rules]    DEBUG | Loading file: /etc/openhab2/rules/test.py
[2019-08-08 09:39:38,267] [             HABApp.Rules]     INFO | Added rule "MyOpenhabTestRule" from test.py
[2019-08-08 09:39:38,267] [             HABApp.Rules]    DEBUG | File /etc/openhab2/rules/test.py successfully loaded!

Okay, so the file gets unloaded properly. This is a minor annoyance, I’ll see if I can create a timeout after which the fill will be loaded.
Hint:
You should not do much processing in the __init__ anyway but ruther shedule it with run_in or run_soon.

The docker image from Docker Hub also does not work anymore. Same error as Daniel posted.
I have just upgraded the container to use the latest image from Docker hub.
Now it dies immediately after starting it with the above error.

I tried again - same error. I’m at the extent of my knowledge on trying to fix it/get it worked unfortunately.

@danielwalters86, @c_wick:
What is the verbose output of docker build?
I can’t wrap my head around it atm because I added a docker test build to travis and it builds and starts fine.

Hello! Could you write a short guide, how to install Habapp both ways on armhf, because it is not that straight forward as it looks.

The easiest way would be through virtual environment.
I have written a step by step guide here. It should work pretty straightforward.

Edit:
I installed it on an openhabian image on the pi4 and it pretty much worked.
There is an error message on a vanilla image when trying to create the virtual environment but it even says install the following package so the error is gone.
There should be no way how armhf makes it more difficult

@Spaceman_Spiff
Where do I see the verbose output of a docker build on a Synology NAS?
It used to run it in a Docker container on the Synology NAS without any issues in previous releases.

Strange - I suspect that the ruamel.yaml gets installed with a very old version.
I pined the newest version in the requirements file.
@danielwalters86: Could you try to build the image on the pie again with the latest dev-branch?

Version 0.7.0

  • Added possibility to set/remove Metadata
  • Specified minimum version for pypi packages
  • removed functions which have been deprecated since 0.3.0
  • added documentation & tests

@c_wick: Maybe with explicit version numbers your problems are gone? Could you check again?

:+1:

It is working again now with 0.7.0 as a Docker Container on my Synology NAS.

1 Like