Power on could be from an other device with Wake-on-LAN or within the BIOS.
Spinning down is a pain. It doesn't work for me anymore since TrueNAS removed S.M.A.R.T settings.
Shutdown is the easiest: A cronjob
I write about my journey in this blog post: https://www.crazy-memorys.ch/IfixedIT/?p=476