HABApp 0.18.0

Good news everyone!

I just released HABApp Version 0.18.0 which contains lots of bug fixes and of course some nice new features. Most notably is the improved handling for the item watchers which is much more convenient.

def __init__(self):

    item = Item.get_item('my_item')

    # This will only listen to events with 30sec - no more filtering in func needed
    watcher = item.watch_update(30)
    watcher.listen_event(self.const_30_secs)

    # This will only listen to events with 60sec - no more filtering in func needed
    watcher = item.watch_change(60)
    watcher.listen_event(cb)

    # To listen to all ItemNoChangeEvent/ItemNoUpdateEvent independent of the timeout time use
    # item.listen_event(self.item_constant, watcher.EVENT)

def const_30_secs(self, event: ItemNoUpdateEvent):
    pass

def const_60_secs(self, event: ItemNoChangeEvent):
    pass

Changes and Bugfixes:

  • Fixed a bug where the item watchers would not work after deleting and immediately adding an item again (e.g. *.items file change)
  • BaseWatch has now a function which listens exactly to this event
  • ItemTimes.add_watch accepts a timedelta, too
  • If a file depends on another file that doesn’t exist and that file gets added the depending file will be loaded correctly (fixes #186)
  • A file with duplicate rule names will no longer break the file load
  • Item registry: renamed set_item to add_item which also raises an exception if the item already exists

Small improvements

  • EventBusListener can filter on event properties
  • creating/canceling an item watch gets now logged

As always:

  • Updated requirements
  • added some tests and documentation
3 Likes

Good news everyone!

HABApp 0.18.1 is out.

Changes:


All items can use timedelta in watch_change and watch_update which makes it very convenient for longer times

my_number = NumberItem.get_item('MyNumberItem')
watcher = my_number.watch_change(timedelta(minutes=3))

Sometimes thing parameters (e.g. z-wave dimmers) depend from each other.
An example would be a z-wave dimmer that has a parameter for step interval, step duration and the device poll time. It is now possible to reference parameters and do mathematical operators with them.That way changeing one parameters automatically updates the others.

thing config:
  5: 8
  6: '$5 / 2'       # Use value from parameter 5 and divide it by two.
  7: 'int($5 / 2)'  # it is possible to use normal python datatypes

MqttPairItem:
An item that consolidates a topic that reports states from a device and a topic that is used to write to a device.

from HABApp.mqtt.items import MqttPairItem

# MqttPairItem works out of the box with zigbee2mqtt
mqtt = MqttPairItem.get_create_item("zigbee2mqtt/my_bulb/brightness")
mqtt.publish("255")  # <-- will use the write topic

Changelog:

  • items can use timedelta in watch_change and watch_update
  • Added possibility to specify references in thing config
  • MqttItem does no longer inherit from Item
  • Added MqttPairItem:
    An item that consolidates a topic that reports states from a device and a topic that is used to write to a device.
  • Updated documentation (big thanks to @yfaway)
  • Removed skipping of set_value and post_value in docs

Edit:
Also if you are in Volgograd HABApp uses now the correct timezone after the timezone switch on 27. :smile:

2 Likes