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