Thanks, this totally works!
If anyone wants to copy my setup:
I use Homeassistant on a Raspy with a wake on lan switch (see documentation for homeassistant wake on lan https://www.home-assistant.io/integrations/wake_on_lan/)
I use the turn_off feature of wake on lan to call the script.
Here is my script to sleep the server via ssh:
"ssh -i /config/ssh_keys/id_YOUR_PRIVTE_KEYFILE -o 'StrictHostKeyChecking=no'
[email protected] /usr/local/emhttp/plugins/dynamix.s3.sleep/scripts/s3_sleep -S"
bare in mind that you have to follow another guide to configure the ssh_key first, or HA can't connect to the server via ssh