This is a really huge release which brings many improvements (and probably new bugs ).
Most notably is the new scheduler with a new countdown option which simplifies many rules!
Example of a rule that will turn the light on and off based on two movement sensors:
There is no need to cancel and reschedule - just call the reset() function and the countdown will start again.
Attention
No more support for python 3.6!
Migration of rules is needed!
Changelog
Switched to Apache2.0 License
Fix DateTime string parsing for OH 3.1 (#214)
State of Groupitem gets set correctly
About ~50% performance increase for async calls in rules
Significantly less CPU usage when no functions are running
Completely reworked the file handling (loading and dependency resolution)
Completely reworked the Scheduler!
Has now subsecond accuracity (finally!)
Has a new .coundown() job which can simplify many rules.
It is made for rules that do something after a certain period of time (e.g. switch a light off after movement)
Added hsb_to_rgb, rgb_to_hsb functions which can be used in rules
Better error message if configured foldes overlap with HABApp folders
Renamed HABAppError to HABAppException
Some Doc improvements
Migration of rules:
Search for self.run_ and replace with self.run.
Search for self.run.in and replace with self.run.at
Search for .get_next_call() and replace with .get_next_run() (But make sure itās a scheduled job)
Search for HABAppError and replace with HABAppException
Search for self.run_on_sun('sunrise' and replace with self.run.on_sunrise(
Search for self.run_on_sun('sunset' and replace with self.run.on_sunset(
Excited to try, but experiencing difficulty upgrading per the instructions, apparently related to pendulum. Had tried a system update through openhabian-configā¦ trying to figure out how to determine installed version nowā¦in case it actually worked (I donāt think it did).
(habapp) openhabian@pi-openhab3:/opt/habapp $ sudo python3 -m pip install --upgrade habapp
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting habapp
Using cached https://files.pythonhosted.org/packages/1b/ea/3b08de44fc6a9e66dfa753b64dde66f7a1efae68de781854d2ffe6178171/HABApp-0.30.0-py3-none-any.whl
Collecting stackprinter==0.2.5 (from habapp)
Using cached https://files.pythonhosted.org/packages/f3/f5/ff972ffa3b54afce3f48d36bf749e3048ee22473afa4489dd6c5c1be402a/stackprinter-0.2.5-py3-none-any.whl
Collecting pendulum==2.1.2 (from habapp)
Using cached https://files.pythonhosted.org/packages/db/15/6e89ae7cde7907118769ed3d2481566d05b5fd362724025198bb95faf599/pendulum-2.1.2.tar.gz
Installing build dependencies ... done
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.7/tokenize.py", line 447, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-t4wzuhgr/pendulum/setup.py'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-t4wzuhgr/pendulum/
Have you executed it in your venv? I got a similar error but after I upgraded pip it was gone.
Or maybe it was because I installed an older version of pendulum first. Could you try that?
other than deleting the habapp folder in /opt, what else would I need to do to allow for a successful reinstallation from your docs or openhabian-config?
Great, thanks for the fix above. I might try to clear everything out again and try again, because of the below situation, but I donāt think it will fix it?
I know this is not really a HABapp question, but Iām finding the service runs different than the command line in the venv. Running the below command from the command line I see all my logging settings in frontail, but not if I run the service, also shown below:
Permissions on the log files looked consistent, but I should have thought to apply that option. It should be step 1 in many troubleshooting situationsā¦
Thereās either a bug/limitation importing lib modules or Iām making a silly mistake.
Iāve a file habapp_utils.py in my lib folder which I import into my rules with āimport habapp_utilsā and āfrom habapp_utils import *ā. This works fine, however any changes I make into habapp_utils.py arenāt reflected when I run my rules unless I first restart habapp.
Is it intentional, a bug, or am I doing something dumb?
As far as i understand. HabApp reconises your change, but the already loaded rules do not. There is a specific dependency option. With this option you could say reload my rule if file xyz changes.
@Dibbler42 While file properties are really nice they donāt apply here
@dan12345
Itās a library folder that gets imported on startup.
Currently there is no proper method in python to dynamically reload libraries, thatās why changes to the libraries donāt get picked up during runtime.
And to be fair most of the time this is not necessary:
HABApp can build rules dynamically based on parameter files and reload the rule files on parameter change (see the link from Thomas).
As a third option you can create HABApp internal items and use these to transfer data between rules/files.
Overlaying states and a device driver/logic model can be created with the MultiModeIItem
With these mechanisms creating libraries in the original sense of library is not necessary any more.
And when it makes sense itās so static that restarts donāt matter
Itās interesting how different people have different approaches. I like building a big library with all the utility functions, and then having short simple rules files. But restarting when the library changes isnāt a hardship!
I used to try that too, but I changed that to create a rule class that does exactly one thing and Iām rather creating multiple instances of the rule than try working with a big library.
For example I now have six rules per rollershutter and they are combined through the multimode item.
If you like you can create a thread and Iāll have a look at your things and give you an example how I would have done it. If not and youāre happy restarting HABApp thatās fine with me, too!
Whatever suits you the best!