Hello,
This is an advanced blueprint for that.
I believe you can get inspiration from that and setup your automation.