Hi! I am so sorry you are going thru this.
I honor your sentiment that you don't want to separate your son from his dad. But that's not your choice to make. It needs to be his dad who prioritizes his son over his substances - not you. And right now, you need to prioritize your son's safety over his time at his dad's house.
Please know that my answer really wouldn't be any different if your son had found a bottle of aspirin or the drain cleaner or a lighter or a sharp knife or a bucket of water. Toddlers get into everything even when they are well watched. Your son should never be in an unsafe environment; especially one you KNOW to be unsafe.
How is your relationship with his dad? If it's decent, I would insist that your Ex childproof his home completely and to your satisfaction. I would buy him a lockbox to use for his medications and whatever else. And I would help him do it and inspect his place before you leave your son there. (And if it's still unsafe, I would take some surreptitious pics with your cell phone and make sure that you stay with your son while he is there. An then not let him go back and use the pics to show your ex "why")
And if your ex balks to childproofing, I would welcome him to see your son at your home or the library or another safe place (paternal grandparents?)
FWIW, my own baby is 15.5 and when he was wee, his pediatricians strongly advise ALL of their patient's families to NEVER have codeine products in the home. To the point of asking families to request pain killer alternatives for THEMSELVES whenever possible. Why? Because an OD on coedeine KILLS. People lose the reflex to breathe and by the time someone notices a child has gotten into the pills or whatever...it's too late.
I am sorry if I am being harsh, I don't mean to sound unfriendly...but I also realize that YOU know your child is at risk, and that's why you found us.
{{{hugs}}}