HABApp 26

Good news everyone! I’ve just release a major new version:

HABApp 26.09.0

This is a huge release which changes lots of HABApp internals.
It fixes some bugs and is the groundwork for further new and exciting features.


Changelog:

  • Reworked many internals
  • Breaking: Requires at least Python 3.12
  • Breaking: Rule.get_items() is not a staticmethod anymore → must always be self.get_items()
  • Fixed a bug with the scheduler and sun azimuth
  • Breaking: MqttPublishOptions(...) needs to be replaced with self.mqtt.publish_options(...) in rules
  • Instead of HABApp.Parameter use HABApp.parameters.Parameter
  • Fixed an issue where a Rule was not properly unloaded

Thank you for providing valuable feedback during the HABApp Beta
@bastler @Dominik_Bernhardt

If you experience any issues with the new version please use this thread to ask for help.

I installed iHABApp 26.09.0 yesterday in the evening and can report that everything works for me :grinning_face:

Great job Sebastian, thank you very much for your efford :+1:

Good news everyone! I’ve just release a new version with a small fix

HABApp 26.10.0

It fixes an issue with a dependency package (whenever).
Thank you @Dominik_Bernhardt for the report.

Thanks for new release.

It seems last_change and last_update been renamed to last_state_change and last_state_update ? or was this a change in an earlier release and I’m slow on my updates :sweat_smile:

I’ not sure what you mean exactly?
On the item it’s still last_change and last_update.
HABApp 26.9.0 introduced last_state_update and last_state_change on the ItemStateChangedEvent / ItemStateUpdatedEvent that is received from openhab.

Hm:

Code (“BS_Kj_TvStue_Tak” is a Switch item):

last_movement = self.oh.get_item("BS_Kj_TvStue_Tak").last_change

Output:

[2026-10-06 10:15:14,643] [ HABApp.Worker] ERROR | Error in create_rules: ‘ItemResp’ object has no attribute ‘last_change’

What you are doing:
Sending a request to the openHAB API, waiting for the response and then access the last_change field of this response. It does not exist in the API response that why you see this error.

What you probably wanted to do:
Get the openHAB item of HABApp and access the last_change field

OpenhabItem.get_item('BS_Kj_TvStue_Tak').last_change
# or if you know the item type, in this case e.g. StringItem
StringItem.get_item('BS_Kj_TvStue_Tak').last_change

The last one comes from the cache in HABApp and thus has virtually no overhead.

Is the difference clear?

I think so, but I am a little worried of the term “cache”, does that mean at any point there could be a desync in itemstate between habapp and openhab (I’m not thinking milliseconds, but say seconds)?

The reason I ask is I do some reading and writing of metadata on items to control certain energy values/states. And I need to be certain the actual value of given metadata or item state is the current one. There’s no “realtime” updating but the items need to be somewhat synchronized to make sense.

I’ve been using “from HABApp.openhab.interface_sync import get_item” to retrieve item states from OH (or at least so I thought) but maybe I’ve been doing this all wrong? My scope and code has changed through the years and I’ve been picking up things as I learn of new features etc.

Noticed something, when using the get_rule function it now returns a “list” item so I have to reference it by index:

adax = self.get_rule('AdaxControlRules')
z = adax.get_heater_info("X_HEATER") # OLD WAY

Now I have to use:

z = adax[0].get_heater_info("X_HEATER")

is this intentional? :thinking:

HABApp subscribes to the openHAB event bus and automatically updates the items and the item states. So the HABApp internal items always carry the correct item state and item configuration. It’s just a few instants behind openHAB.
In my rules I never use the interface_sync directly - everything “just works”.

Just edit your item and take a look at the HABApp events log. If you see am ItemUpdatedEvent HABApp has already updated the internal item configuration.

Not wrong but unnecessarily slow and complicated. I’d like to improve the docs to make it more clear. Can you hint me to a part where I should add or improve this?

Yes- you probably have two files with the same rule name.
Then HABApp returns a list of rules. It’s on my backlog to enforce rule name uniqueness across all rules but I’ve not yet implemented it.
If the rule name is unique you get the rule directly.

Indeed you found the error. I made a backup directory (with all the rules files) inside the rules directory after updating and didn’t think Habapp would load them, which it did of course, silly mistake. Thanks for helping and sorry for the inconvenience :see_no_evil_monkey: