Beispiel #1
0
    def change_item(self):
        with OpenhabTmpItem(None, 'Number') as tmpitem:
            NumberItem.get_item(tmpitem.name)

            create_item('String', tmpitem.name)
            EventWaiter(tmpitem.name, ItemUpdatedEvent(tmpitem.name, 'String'), 2, False)
            StringItem.get_item(tmpitem.name)

            create_item('DateTime', tmpitem.name)
            EventWaiter(tmpitem.name, ItemUpdatedEvent(tmpitem.name, 'DateTime'), 2, False)
            DatetimeItem.get_item(tmpitem.name)
Beispiel #2
0
    def change_item(self):
        with OpenhabTmpItem('Number') as tmpitem:
            NumberItem.get_item(tmpitem.name)

            with EventWaiter(tmpitem.name, ItemUpdatedEvent, 2) as e:
                create_item('String', tmpitem.name)
                e.wait_for_event(type='String', name=tmpitem.name)
            StringItem.get_item(tmpitem.name)

            with EventWaiter(tmpitem.name, ItemUpdatedEvent, 2) as e:
                create_item('DateTime', tmpitem.name)
                e.wait_for_event(type='DateTime', name=tmpitem.name)
            DatetimeItem.get_item(tmpitem.name)
Beispiel #3
0
    def __init__(self):
        super().__init__()

        # get items
        test_contact = ContactItem.get_item('TestContact')
        test_date_time = DatetimeItem.get_item('TestDateTime')
        test_switch = SwitchItem.get_item('TestSwitch')

        # Trigger on item updates
        test_contact.listen_event(self.item_state_update, ItemStateEvent)
        test_date_time.listen_event(self.item_state_update, ValueUpdateEvent)

        # Trigger on item changes
        test_contact.listen_event(self.item_state_change, ItemStateChangedEvent)
        test_date_time.listen_event(self.item_state_change, ValueChangeEvent)

        # Trigger on item commands
        test_switch.listen_event(self.item_command, ItemCommandEvent)