I completely agree with you about it being the challenge for this generation.
In my classroom I used to have to teach low-functioning children how to do tasks and to increase their attention span. I am not saying your child has a intellectual problem, but that the way to increase attention span might work for this as well.
We used a three token system. When the child earned three tokens they bought time for their chosen activity (freetime). Each token represented a work task, in the beginning -- very short tasks of less than a minute each. (If, the child did the work of course.) The three tokens never changed but the length of the tasks did -- gradually over time. So in the beginning of the school year a child might work for 4 minutes and then play for 15, but at the end of the year, they'd be working for an hour and earning the same 15 minutes.
At five, tokens might not be your preference, but the core of the idea still works. He earns time by accomplishing the other things you want. You subtly increase the accomplishments and decrease the earned device time. That might work best by not actually decreasing the set time earned on the device. The earned time is always the same amount -- whatever you decide -- but the 'work' time is longer and longer.
At five he understands choices and consequences. I suggest that you tell him that every time he asks or bugs you for the device, he adds a task to the 'work' side. Be careful though -- if the 'carrot' gets too small, he won't do the things you want. (Do not reduce the earned time.)
As for TV and so on at dinner -- if you as a family watch TV or Youtube over dinner and you are thinking this isn't great -- make dinner time device free for all of you. It's really only 15-20 minutes. The only excepts are emergencies... and parents cannot 'cheat'. Talk about your day. This is a great time to talk about family matters. (Finances, goals and so on.)
Model the behaviour you want. If Mum or Dad is always on the computer, phone or whatever -- then you cannot blame the child for copying you. You also model earning time. You do your chores and contributions and you earn free time to spend as you choose. Use language that shows your son that you also have stuff to do before you can play. Don't complain. We all have things we have to do to keep our homes and family working. You do not want to teach resentment or make looking after family look like a chore.
I also suggest that you do homework as a family. I resented being sent to my room, so we all sit at the dining room table and work for the time it takes to get homework done. Reading a book is fine. It's quiet time but your child can ask questions and you can comment on the book you are reading or the sketch you are drawing.
Your motto becomes: "This is what we all do to make our family work."