def test_process_position(self): """Test process / reading telegrams from telegram queue. Test if position is processed correctly.""" xknx = XKNX() cover = Cover( xknx, "TestCover", group_address_long="1/2/1", group_address_short="1/2/2", group_address_position="1/2/3", group_address_position_state="1/2/4", ) # initial position process - position is unknown so this is the new state - not moving telegram = Telegram(GroupAddress("1/2/3"), payload=DPTArray(213)) self.loop.run_until_complete(cover.process(telegram)) self.assertEqual(cover.current_position(), 84) self.assertFalse(cover.is_traveling()) # state telegram updates current position - we are not moving so this is new state - not moving telegram = Telegram(GroupAddress("1/2/4"), payload=DPTArray(42)) self.loop.run_until_complete(cover.process(telegram)) self.assertEqual(cover.current_position(), 16) self.assertFalse(cover.is_traveling()) self.assertEqual(cover.travelcalculator.travel_to_position, 16) # new position - movement starts telegram = Telegram(GroupAddress("1/2/3"), payload=DPTArray(255)) self.loop.run_until_complete(cover.process(telegram)) self.assertEqual(cover.current_position(), 16) self.assertTrue(cover.is_closing()) self.assertEqual(cover.travelcalculator.travel_to_position, 100) # new state while moving - movement goes on; travelcalculator updated telegram = Telegram(GroupAddress("1/2/4"), payload=DPTArray(213)) self.loop.run_until_complete(cover.process(telegram)) self.assertEqual(cover.current_position(), 84) self.assertTrue(cover.is_closing()) self.assertEqual(cover.travelcalculator.travel_to_position, 100)
def test_process(self): """Test process / reading telegrams from telegram queue. Test if position is processed correctly.""" xknx = XKNX(loop=self.loop) cover = Cover(xknx, 'TestCover', group_address_long='1/2/1', group_address_short='1/2/2', group_address_position='1/2/3', group_address_position_state='1/2/4') telegram = Telegram(GroupAddress('1/2/4'), payload=DPTArray(42)) self.loop.run_until_complete(asyncio.Task(cover.process(telegram))) self.assertEqual(cover.current_position(), 84)
async def test_process_position(self): """Test process / reading telegrams from telegram queue. Test if position is processed correctly.""" xknx = XKNX() cover = Cover( xknx, "TestCoverProcessPosition", group_address_long="1/2/1", group_address_short="1/2/2", group_address_position="1/2/3", group_address_position_state="1/2/4", ) # initial position process - position is unknown so this is the new state - not moving telegram = Telegram(GroupAddress("1/2/3"), payload=GroupValueWrite(DPTArray(213))) await cover.process(telegram) assert cover.current_position() == 84 assert not cover.is_traveling() # state telegram updates current position - we are not moving so this is new state - not moving telegram = Telegram(GroupAddress("1/2/4"), payload=GroupValueWrite(DPTArray(42))) await cover.process(telegram) assert cover.current_position() == 16 assert not cover.is_traveling() assert cover.travelcalculator._travel_to_position == 16 # new position - movement starts telegram = Telegram(GroupAddress("1/2/3"), payload=GroupValueWrite(DPTArray(255))) await cover.process(telegram) assert cover.current_position() == 16 assert cover.is_closing() assert cover.travelcalculator._travel_to_position == 100 # new state while moving - movement goes on; travelcalculator updated telegram = Telegram(GroupAddress("1/2/4"), payload=GroupValueWrite(DPTArray(213))) await cover.process(telegram) assert cover.current_position() == 84 assert cover.is_closing() assert cover.travelcalculator._travel_to_position == 100 await cover.stop() # clean up tasks
def test_process(self): """Test process / reading telegrams from telegram queue. Test if position is processed correctly.""" xknx = XKNX(loop=self.loop) cover = Cover( xknx, 'TestCover', group_address_long='1/2/1', group_address_short='1/2/2', group_address_position='1/2/3', group_address_position_state='1/2/4') telegram = Telegram(GroupAddress('1/2/4'), payload=DPTArray(42)) self.loop.run_until_complete(asyncio.Task(cover.process(telegram))) self.assertEqual(cover.current_position(), 84)
async def controle_store_async(d_o, adr_store, name_site): """Connect to KNX/IP bus, switch on light, wait 2 seconds and switch of off again.""" xknx = XKNX() await xknx.start() cover = Cover(xknx, 'Store_' + name_site, group_address_position=adr_store, travel_time_down=50, travel_time_up=60, invert_position=True, invert_angle=False) await cover.set_position(d_o) print(cover.current_position()) await xknx.stop()