Turning off Synology NAS

I would like to turn off my Synology NAS together with all my lights when I go to bed.
Is this somehow possible to to so with HA?

I would think off script where I connect via ssh and run shutdown command.

Can you give an example? I have not used SSH via HA yet.
I have read somewhere that there might be some increased security issues when using SSH to control Synology.

Don’t know how the ssh security looks form Synology perspective (enable SSH means vulnerability) but for sure, it can make security issue.

Here is the shell command integration: https://www.home-assistant.io/integrations/shell_command/

Once you are able to fire an ssh command to shutdown the Synology you will be able to integrate this.

I will take a look and try it out.
Thanks

Have you managed to shutdown your Synology NAS via the SSH yet?

No I haven´t made it yet. I think the first step is to make some RSA keys.
If you have a solution I am very interested.

Have a look here: Power on / off NAS by using WOL and SSHPASS

Solved with this:

switch:
  - platform: wake_on_lan
    name: "NAME_NAS"
    mac: 00-AA-BB-CC-DD-EE
    host: 192.168.1.2
    turn_off:
      service: synology_dsm.shutdown

Of course, you need first to integrate the Synology NAS in Home Assistant: Menu: Configuration -> Integrations . Search for “Synology DSM”, fill in the configuration form with your username and password, and then click Submit .
MAC and host addresses above are examples, you will need yours.

Wake on lan service also needs to be in configuration.yaml of home assistant.

# Example configuration.yaml entry
wake_on_lan:
4 Likes

Thanks but I am afraid that this integration is not available with the version of HA I am on. 0.103.6.
However I got it working by using sshpass.

sems to be the only topic to update this. The service will soon be deprecated, we are supposed to use the button the integration provides these days:

switch:
## https://www.home-assistant.io/components/switch.wake_on_lan/
  - platform: wake_on_lan
    name: (Wake) Synology Nas
    mac: !secret synology_mac
    host: !secret synology_host
    turn_off:
      service: button.press
      target:
        entity_id: button.synology_shutdown

works beautifully and can be integrated in scripts easily now, no more fiddling about. plain and simple.

3 Likes

Hi,
for two nas, it’s good like that ?

  - platform: wake_on_lan
    name: (Wake) Synology Nas
    mac: !secret synology_mac
    host: !secret synology_host
    turn_off:
      service: button.press
      target:
        entity_id: button.synology_shutdown
      data:
        serial: 1511MINXXXXXX

not sure what you are doing here, but the seems not the way to toggle 2 nas devices.

  - platform: wake_on_lan
    name: (Wake) Synology Nas 1
    etc....
  - platform: wake_on_lan
    name: (Wake) Synology Nas 2
    etc....

Just create a dedicated switch for each individual device.
Also, the button should simply be listed in the devices entities, so not sure you need the extra serial data there.

Sorry, I didn’t put the full code.

  - platform: wake_on_lan
    name: (Wake) Synology Nas 1
    mac: !secret synology_mac1
    host: !secret synology_host1
    turn_off:
      service: button.press
      target:
        entity_id: button.synology1_shutdown
      #data:
        #serial: 1511MINXXXXXX
  - platform: wake_on_lan
    name: (Wake) Synology Nas 2
    mac: !secret synology_mac2
    host: !secret synology_host2
    turn_off:
      service: button.press
      target:
        entity_id: button.synology2_shutdown
      #data:  
        #serial: 1611MINXXXXXX

Ok, I remove the serial and I test.
thanks for the information.

yep, that would be it :wink:

Found this thread after searching through a bunch of other (non-working) solutions.

This did the trick! Thanks, Marius!