Good news everyone - I released a new version today.
The main feature is the possibility to specify metadata when using textual thing configuration.
Now it is possible to do anything with the textual configuration which is possible through the UI and/or items file.
- type: Number
name: '{thing_label, :(.+)$}_Temperature'
label: '{thing_label, :(.+)$} Temperature [%d %%]'
icon: battery
metadata:
autoupdate: 'false'
homekit: 'TemperatureSensor'
0.15.3
Added possibility to set metadata when using textual thing configuration
Fixed a race condition which resulted in item.watch... not working properly
added multiline support for the log_functions
Shutdown should not hang any more if no items exist on the oh side
Fixes for z-wave config entries with bitmasks and without bitmask (#168)
Thank you for your development of this! It appears it will be quite handy.
I have HABApp up and running in a Docker container, along with the rest of my install. I have a specific use case where I need a rule to SSH into another box and run a command. Since my openHAB2 install is in a container, the exec binding can no longer handle this for me.
I was hoping to use ssh2-python to be able to do this, but I am not sure how to add Python modules into HABApp for use. Iâve reviewed the documentation and either I am missing this, or perhaps this isnât something thatâs meant to be done easily.
@Spaceman_Spiff what about adding a mount point for external libs and putting it in PYTHONPATH permanently?
I donât have the command handy, but pip cam be told where to install to and to get all requirements and put them in that same folder.
Alternatively there might be a way to add a list of packages to install as an environment variable in the docker compose file that would get installed either before launching HABApp or by HABApp.
I can test these methods when I have time, hopefully next weekend at the latest.
For user specific libraries there already is the option to specify a lib folder in the config. Everything that is copied there can be loaded in a rule.
This could be a solution, similar to the âsleepâ arg that can be passed to delay startup.
But it would have to be a good solution so we donât upgrade to incompatible versions of used libraries.
Nonetheless I firmly believe that everything that is required to run should be in the container and extending the dockerfile seems like the most elegant solution to me and ensures that all file versions are properly build and match the environment.
Maybe if I provide a docker compose and a sample dockerfile in the docs it shouldnât be too hard.
I had tried the prior before posting - and admittedly
Iâm still a Docker novice, but I ran into build errors with missing cmake and skbuild that I couldnât figure out how to get past. Does this work for you?
Are you running your container on arm? It seems builds for arm are not included.
Maybe you can use paramiko (pure python so it doesnât depent on c libs) as an alternative?
Otherwise try these lines
RUN apk add cmake cmake-doc extra-cmake-modules extra-cmake-modules-doc
RUN python -m pip install ssh2-python
No, I am on Intel x64 (RancherOS on ESXi to be exact). Paramiko follows a similar path of build dependency errors. Iâm sure the issue is my Docker knowledge, but Google hasnât helped me troubleshoot why I canât get either package into this Docker image. I even tried taking your Dockerfile for building and adding the libraries there via pip before the HABApp install, and it fails to build.
Using either a Dockerfile that simply extends the habapp image or adding these into the appropriate locations in the Dockerfile for the image build that youâve published, I get the same error:
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-i8knhx1r/ssh2-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-i8knhx1r/ssh2-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-7zivw8wc
cwd: /tmp/pip-install-i8knhx1r/ssh2-python/
Complete output (13 lines):
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "/tmp/pip-install-i8knhx1r/ssh2-python/src/CMakeFiles/CMakeOutput.log".
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-i8knhx1r/ssh2-python/setup.py", line 34, in <module>
build_ssh2()
File "/tmp/pip-install-i8knhx1r/ssh2-python/_setup_libssh2.py", line 24, in build_ssh2
shell=True, env=os.environ)
File "/usr/local/lib/python3.7/subprocess.py", line 363, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'cmake ../libssh2 -DBUILD_SHARED_LIBS=ON -DENABLE_ZLIB_COMPRESSION=ON -DENABLE_CRYPT_NONE=ON -DENABLE_MAC_NONE=ON -DCRYPTO_BACKEND=OpenSSL' returned non-zero exit status 1.
----------------------------------------
ERROR: Failed building wheel for ssh2-python
Based on my research the issue is that something like g++ isnât installed, but I see that it actually is installed as one of the original dependencies in the image build.
When installing paramiko, I get a build error that boils down to: c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
This does seem to work. Hereâs my complete Dockerfile in case anyone else needs it:
FROM python:3.8.6-buster
VOLUME [ "/config"]
# Install required dependencies
RUN apt install -y \
# Support for Timezones
tzdata \
# ujson won't compile without these libs
g++
# Always use latest versions
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . .
RUN python -m pip install ssh2-python
# Install
RUN pip3 install git+https://github.com/spacemanspiff2007/HABApp.git
CMD [ "python", "-m", "HABApp", "--config", "/config" ]
First of all thanks for this wounderfull piece of software. Iâm using OpenHAB since almost 5 years and this was always the missing piece.
I have a question how you deal with items created from HABApp or other scripting. I like the idea of automatically create items based on things or any other custom auto discovery. However I have no good idea so far how to do cleanup. The generated items will remain in the openhab item registry for every (or until manual deletion)
Any thoughts? Is anyone creating items from HABApp?
Thank you for your kind words - they really mean a lot to me!
If you use the textual thing configuration from HABApp there is already a cleanup built in.
Imho it should be flexible enough to cater to all your use cases, if not then maybe we can build something that does. Have you tried it out already?
I tried creating items from rules in the beginning, but I really like the possibility to look in the items file and quickly see what kind of items are existing and also structure them in a certain way.
If they are just in the database I always have to fire up the UI and search for the item (and not find it because I renamed it with my last change). Also I think itâs nice to have a differentiation between items and item logic.
I am providing the api endpoint because I think of HABApp as the python reference implementation for openhab, but dealing with items is really messy and has lots of quirks.
So while it will work, I am definately not recommending it (at least not without trying everything out on a test instance first).