I do not mean this in any way to disrespect Sebastian, who has put a lot of time and effort into HABapp, but scripted automation with Jython can do everything HABapp can do and a LOT more. This is due to HABApp being limited by its use of the REST API to communicate with OH, which is also what is used by the UIs. Scripted automation, which can be used with several scripting languages, uses the automation API for creating rules, but it also has full access to not only all of the OH classes, interfaces, and services, but any Java or Python2 libraries that youâd like to use. The Jython interpreter is based on Python 2.7, but when it comes to writing automation, this is not much of a limitation. Jython3 is also being developed and graal-python will be integrated.
HABApp is written in pure Python which means you can do anything you can do in python.
Itâs possibly to import any library from pypi and use it together with your rule.
What initially started as an abstraction of the openhab connection has become a general purpose rule engine.
The focus of HABApp is to quickly create error free rules and to achieve this it provides full type hinting, auto complete and checks when used with an IDE and abstracts certain functionality:
want to use the timestamp when it was the last time an item was changed
SwitchItem.get_item('MySwitch').last_change
want to run something on weekends at 8
self.run_on_weekends(time(hour=8), my_func)
want to run something every two hours but only between 8 and 16 oâclock
As Scott pointed out, itâs not possible to do everything with HABApp, because unfortunately the REST-API is in some aspects quite buggy and incomplete e.g. the maintainers donât expose an âactionsâ endpoint.
For me itâs not a problem because I can always link an item to a channel and then use the item to interact with the device instead of the action. But itâs still a valid point.
While there might not be much difference and limitation for you, I wouldnât have spent hundreds of hours developing HABApp if this were true (for me). Python 2.7 was released 2010 and many aspects of the syntax have been deprecated since.
To answer your initial question:
I guess it comes down to your personal preference! I could never go back to using jsr223 and for Scott itâs sufficient. But I guess weâre both biased so you have to try them out yourself.
Have you thought about contributing an actions endpoint to the REST API?
I do see the value of Pyhon 3.x and it would be fun to see if I could do something like hook up TensorFlow into my home automation some day. Right now Iâm only at the beginning.
There really is no limitation at all, since you can use executeCommandLine in scripted automation, using any scripting language, to call Python3 scripts. I do not have empirical evidence to support this, but because HABapp interacts with OH through the REST API, I expect that you will find that scripted automation is significantly faster, which is a very important factor for automation. It all comes down to a personal choice though⊠but both can be used simultaneously!
I just switched over to HABApp only two weeks ago and already have migrated all my automation I previously had in openhab. Python 2.7 would have been a major limitation for me. I like the modern python 3 approach in HABApp, the error handling capabilities, the ability to use every library from the python universe via pip. @5iver Regarding the use of execute Commandline there is a fundamental difference. While HABApp has instances of rules and therefore can have internal state a simple CLI would be stateless. Prior knowing HABApp I even created for more complex automation tasks python solutions that had a rest interface and communicated with those from openhab with the HTTP binding.
At the end it really is about personal preference and I wonât say the one is better than the other. Communicating via a rest interface is for me no disadvantage as it is the default interface in a services world. Regarding speed you might be right and it would depend on the task you wonât to accomplish. For me the roundtrip times are absolutely sufficient.
Just my 2 cents, additionally to what was said already, as I am using a mix of both systems:
cool in HABapp:
I really like to be able to debug in HABapp via Intellij. Makes it much faster to develop for me.
HABapp has some nice helpers for larger installations, eg to automatically add specific channels / items to a certain type of sensor
HABapp can be run / debugged on a different machine in addition to the main instance on the OH server. This allows adding new rules in a development mode without disturbing the old ones
HABapp never had problems with the startup sequence (where there was always problems for me with JSR223, only solved by adding a large delay or restarting OH)
Keeps REST development on track as its (probably) most demanding user
The new OH3 internal scripting does not require any additional installation / updating of anything
An Editor in the UI does not need any IDE installations / deployment of scripts and can potentially also check / help / inform about dynamic fields like item names etc which is hard (but possible, see VSC sitemap plugin) in HABapp IDEs
Internal should mean less moving parts, eg reusing of OSGI livecycle, and less resource usage
Can probably use new features / entities immediately, does not have to wait on REST updates
Might allow interaction with UI-built automation elements (eg Blocky rules)
Visibility by core devs can result in good quality
I definitly want to try habapp, but at the moment have problems to install it on my system and i am at the very first beginning with python environments. Maybe someon is able to give me some hints to do it in a god / right / professional way.
My Problem: I am running a Debian 11 VM on a Synology Rackstation. This works so far very well. Python 3.8.6 is installed and i found the information that the venv needs to be installed prior any other tasks. Checked and Done.
Now starts the problem. As a standard user i change to â/optâ and try âpython3 -m venv habappâ. Then i get a no permissions error what i am able to understand, because â/optâ belongs to root and my user is not root.
If i add âsudoâ in front of the command the venv is created. Activation then works without âsudoâ. With âsudoâ it does not work.
Next step is to update pip and this does not work. As user i get a permissions error, with sudo the command doesn not work.
So i think there should be a ârightâ way to start a vens in â/optâ on a debian sytsem, but i canât find it until now.
Canât you use the docker image on your Rackstation? Then you only have to mount the folder into the container and everything else is done for you.
The folder /opt/ is only a suggestion, because it works out of the box with openhabian.
You can use any folder you like. Iâd create a suitable one and set the permissions correctly.
Make sure your used user (e.g. openhab) has read/write access. I use the conf folder from openhab and just created a subfolder HABApp.
The hint to openhabian did the trick. openhabian changes the ownership of the /opt folder from root to openhab. and then installatione worked as decribed.
Now i start to configure habapp. rule into oh conf folder, logs to the /var/log/⊠folder and so on.