HABApp 1.0

After lots of work (probably 200-300 hours or more) I am proud to announce

HABApp 1.0.0.

This is a huge release which major internal refactoring.
This introduces the following breaking changes:

  • openHAB >= 3.3 and Python >= 3.8.
  • self.listen_event now requires an instance of EventFilter.


  • Startup issues are gone with a new and improved connection mechanism. Big thanks to @j-n-k who did all the work on the openhab side. HABApp now only works with OH3.3!
  • New configuration library: More settings can be configured in the configuration file. Config values are also described in the docs. Also better error messages (hopefully)
  • Improved event log performance (BufferEventFile no longer needed and should be removed)
  • Improved openhab performance (added some buffers)
  • Improved mqtt performance
  • Better tracebacks in case of error (imho :see_no_evil: )
  • EventFilters can be logically combined (“and”, “or”) so rules trigger only once
  • Label, Groups and Metadata is part of the OpenhabItem and can easily be accessed
  • Added possibility to run arbitrary user code before the HABApp configuration is loaded
  • Fixed setup issues
  • Fixed some known bugs and introduced new ones :wink:
  • Docker file changed to a multi stage build. Mount points changed to /habapp.

Migration to new version

self.listen_event now requires an instance of EventFilter.


from HABApp.core.events import ValueUpdateEvent
self.my_sensor = Item.get_item('my_sensor')
self.my_sensor.listen_event(self.movement, ValueUpdateEvent)


from HABApp.core.events import ValueUpdateEvent, ValueUpdateEventFilter
self.my_sensor = Item.get_item('my_sensor')
self.my_sensor.listen_event(self.movement, ValueUpdateEventFilter())   # <-- Instance of EventFilter
  ValueUpdateEvent -> ValueUpdateEventFilter()
  ValueChangeEvent -> ValueChangeEventFilter()

  ItemStateEvent        -> ItemStateEventFilter()
  ItemStateChangedEvent -> ItemStateChangedEventFilter()
  ItemCommandEvent      -> ItemCommandEventFilter()

  MqttValueUpdateEvent -> MqttValueUpdateEventFilter()
  MqttValueChangeEvent -> MqttValueChangeEventFilter()

Migration to new docker image

  • change the mount point of the config from /config to /habapp/config
  • The new image doesn’t run as root. You can set USER_ID and GROUP_ID to the user you want habapp to run with. It’s necessary to modify the permissions of the mounted fold

If you have issues with the new version you can ask for help here.


HABApp 1.0.3


  • OpenHAB Thing can now be enabled/disabled with thing.set_enabled()
  • ClientID for MQTT should now be unique for every HABApp installation
  • Reworked MultiModeItem, now a default value is possible when no mode is active
  • Added some type hints and updated documentation
1 Like

I realise I wasn’t much help with the beta testing - bit caught up - but the new version is great. Thank you!

(This is now solved - I had a time.sleep command which, thanks to a bug, was sleeping for several hours. That seems to have locked everything up!)

Having said that, have a weird problem - if I change a habapp rules file it always used to reload the rules file and restart the rules. It now doesn’t - it ignores the change. If I stop and restart habapp then the rules files are reloaded and the change picked up.

Is there a new setting I’ve missed?

No - this most likely looks like a bug. Rules should get reloaded as usual.
Could you open an issue on github or a new thread here so we can search for errors?

sure - I’ll open a github issue. Um, embarrassingly I won’t, because I now can’t reproduce the bug…


Hello all,

I tried to add a new user in the openhab

openhab:users add rrr rrr user

and in my config

    user: 'rrr'
    password: 'rrr'

But it’s not possible to start habapp

Status 403 for GET http://localhost:8081/rest/systeminfo

But if i set

openhab:users add rrr rrr administrator

than Habapp is running.

Is there anything wrong with the configuration?

I think it just needs admin rights for the endpoints?

Is there a way to use the API token? @Spaceman_Spiff


Hi Sebastian, one quick request…

I get warnings like this:

 HABApp.Rule]  WARNING | /usr/lib/python3.8/json/decoder.py:353: ResourceWarning:unclosed <ssl.SSLSocke
t fd=17, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('', 40028), raddr=('', 443)>

presumably because one of my rules files is calling a library which leaves a port open. But I have lots and lots of rules files, so hard to work out where the problem is. Would it be possible for the warning to identify the rules file causing the problem?


Unfortunately not. The warning gets emitted when the object gets garbage collected or the connection was closed. It’s a whole different place. What you can try is to try and open the IP and see if you can pin the rule that way (seems to be apple).
Maybe you can use this to close the connection?

I do my first steps with HABApp and try to start a rule regularly but failed…any help please

import HABApp
from HABApp.openhab.events import ItemStateEventFilter, ItemStateEvent
from HABApp.openhab.items import OpenhabItem

class ExampleOpenhabToMQTTRule(HABApp.Rule):
    """This Rule mirrors all updates from OpenHAB to MQTT"""

    def __init__(self):


    def process_update(self):
        #assert isinstance(event, ItemStateEvent)

        #print(f'/openhab/{event.name} <- {event.value}')
        self.mqtt.publish(f'/openhab/{event.name}', str(event.value))


I am absolutely not an expert but it is not clear what’s the aim of the rule. Do you want to send to a mqtt broker all openhab events received by habapp? but then why do you trigger that rule every minute? you probably want to trigger the rule when the event is received, but then a varaible containing the event should be declared somewhere.
in any case I guess you have to tell to habapp what is the ip address of the broker, what topic and what payload to publish.
You probably need to create a new thread seeking for help.


it’s just an example. I just want to have a sample how to creat a rule which is triggered every minute.

You are accessing the variable event which is not defined and thus does not exist.
If you look at the HABApp log it’ll show the appropriate error message.

Like this

class ExampleOpenhabToMQTTRule(HABApp.Rule):
    """This Rule mirrors all updates from OpenHAB to MQTT"""

    def __init__(self):


    def process_update(self):
        #assert isinstance(event, ItemStateEvent)

        #print(f'/openhab/{event.name} <- {event.value}')
        self.mqtt.publish(f'/openhab', str('ee'))


You tell me - what does the HABApp.log say?

Nothing…that’s the strange thing

If the log is empty HABApp is probably not running. You should at least see that the rule is loaded.

1 Like