If you have to ask the internet how to wire this stuff up; DON'T.
This an area common only to industrial electrical engineering. Knowing how to run a branch circuit and how to program a raspberry pie DOES NOT qualify you to install these type of things.
I gave up on electrical questions. I either don't know the answer (because it's professionals talking shop) or I'd have to begin my answer with a warning (just like that one does) so, no thanks, I'll pass.
I had posted a rather lengthy and somewhat embarrassing postrather lengthy and somewhat embarrassing post that explains my position on this further.