Thank you all for the time and advises!
It seems I have it working now, as it is with unmounting the drive.
I’ll have in mind the other way of stopping the mediacenter and samba too, if I find it necessary.
(I think I’ll abstain from this for the moment because, in the case I am playing a video and it tries to unmount, it will simply not happen. I am not sure other way around - what will happen if I am using it and in this moment cron tries to kill the mediacenter and samba. Probably will stop what I am doing, instead of refuse to get killed.)
Meanwhile, maybe someone would find our discussion here useful.
An update - it seems it is not at all a problem with OSMC.
The drive won’t sleep even if unmounted.
hd-idle does not help neither.
It some WD bug.
On to more research and experiments.
OK, what I found by now is that the only thing that works is hdparm -y
All other modificators of hdparm I’ve tried to use have no effect…
I want simply to put the drive to sleep at, let’s say, midnight.
What worries me is what will happen, if the drive is busy at midnight and the hdparm command is sent.
True, I just found it in response to AdrP’s question.
Also from reading through the thread stopping kodi & samba, as yourself & fzinken have suggested should stop any activity on the HDD. So the script should work then or as you suggest spin down then unmount.
Careful. My reading of that script is that it issues a spindown when there has been no disk activity in the last measured time period. It’s just providing the same function as the WD Green disk firmware should have provided. It won’t prevent it from starting up again.
But… it might provide the basis for you to create a cron task. If disk is unmounted then exit, else check for activity. If activity, then exit, else spindown and then unmount.