async def main_loop(loop, password, user, ip):  # pylint: disable=invalid-name
    """Main loop."""
    async with aiohttp.ClientSession(loop=loop) as session:
        VAR['sma'] = pysma.SMA(session, ip, password=password, group=user)
        await VAR['sma'].new_session()
        if VAR['sma'].sma_sid is None:
            _LOGGER.info("No session ID")
            return

        _LOGGER.info("NEW SID: %s", VAR['sma'].sma_sid)

        VAR['running'] = True
        cnt = 5
        sensors = pysma.Sensors()
        while VAR.get('running'):
            await VAR['sma'].read(sensors)
            print_table(sensors)
            cnt -= 1
            if cnt == 0:
                break
            await asyncio.sleep(2)

        await VAR['sma'].close_session()
Main loop.