Dementia poses a legal wrinkle, in that in many jurisdictions, assisted suicide requires consent at the time of the procedure. In many states in the US, especially in the south, assisted suicide is a boogeyman that runs against prevalent religious beliefs. In this case, someone with diminished capacity may be seen as unable to give consent, which could land the assistant in legal trouble.
This is why I like the idea of automation that acts on objective measures, with fail safes in place. Likewise, if after "doing the deed", the system erases itself and the firmware on the pill dispenser is glitched out, then the whole thing can look like an accident. A letter can be sent ahead of time to the family attorney, only to be opened under suspicion of foul play, which can clear up any potential investigatory wrinkles if law enforcement gets involved.
There's also an interesting bit of case law and state statutes that deals with "drug cocktails", which when combined, will lead to death. A physician can prescribe these in certain places without getting in trouble if certain criteria have been met.
Either way, where this is legal, it requires that the person be of the capacity to consent, which someone with dementia cannot do.