Running OpenHAB stable and HABapp 0.31.3 Dev:
Could anyone help with understanding how to subscribe to events, in this case AstroSunPositionElevation
? Habapp is connecting to the API and getting some events but we don’t see all of them updating.
from HABApp import Rule
from HABApp.core.events import ValueUpdateEvent, ValueChangeEvent
from HABApp.openhab.events import ItemStateChangedEvent,ItemStateChangedEventFilter
from HABApp.openhab.items import NumberItem, OpenhabItem
class MyRule(Rule):
def __init__(self):
super().__init__()
# Get the item or create it if it does not exist
self.my_item = OpenhabItem.get_item('AstroSunPositionElevation')
print(self.my_item)
self.my_item.listen_event(self.item_changed, ItemStateChangedEventFilter())
def item_changed(self, event: ItemStateChangedEvent):
print("GOT EVENT")
print(f'{event.name} changed from "{event.old_value}" to "{event.value}"')
print(f'Last change of {self.my_item.name}: {self.my_item.last_change}')
MyRule()
We’ve tried all the examples in the documentation it seems like it’s not possible to listen to the event (Astro binding set with 10s updates so we should be seeing changes). Any ideas on what we could be doing wrong? We would expect to at least be seeing the print statements.
The first print statement is working… but always printing the same value.