Turn On and Off your IX4-300D using Homekit and Homebridge

In this guide, I will setup Homebridge to check the power status of the Lenovo IX-400D NAS, Send a Wake-on-LAN command to turn it on, or send the shutdown command over ssh to turn it back off. This will give you full control of your NAS on your iPhone, iPad, or Mac

Requirements
Setup SSHPass

SSHPass is required to provide a password for the shutdown ssh command. To install SSHPass, open your Homebridge dashboard, click the docker icon in the top-right icon, and select “Settings”

Then paste the following line at the end of the file:

apk add --update --no-cache openssh sshpass

Save and restart the container using the same menu. When restarted, login and open the terminal from the same menu, verify if sshpass is installed by typing

sshpass --version

Setup Homebridge plugin

On your Homebridge dashboard navigate to the plugins page. Search for the “A Wake on Lan plugin for Homebridge” (homebridge-wol vx.x.x) plugin and click install.

Then open your configuration and copy over following lines of code in your “accessories” category and change the settings to your IX4-300D

{
"accessory": "NetworkDevice",
"name": "NAS",
"mac": "00:d0:b8:24:75:f9",
"ip": "192.168.1.5",
"pingInterval": 20,
"wakeGraceTime": 100,
"shutdownGraceTime": 150,
"shutdownCommand": "sshpass -p 'soho+pwd' ssh -oStrictHostKeyChecking=no root@192.168.1.5 shutdown -h now"
}

Info:

  • “accessory” – this should be “NetworkDevice” as it tells Homebridge what plugin to use
  • “name” – This is the name of the button as it will show up in Homekit
  • “mac” – the mac address of your server. This depends on your dual network setup (single/bonded)
  • ‘ip’ – the IP of your NAS, I recommend setting a static IP in your router’s DHCP if you haven’t already
  • “pingInterval” – the interval between checks/pings if the NAS is online/offline
  • “wakeGraceTime” – after sending the Wake-On-Lan command, this is the time it takes your server to turn on
  • “shutdowngracetime” – This is the time it takes your server to turn off, add some extra margin here
  • “shutdownCommand” – This is the command required to turn off your server over ssh
sshpass -p 'soho+PASSWORD' ssh -oStrictHostKeyChecking=no root@(SERVER IP) shutdown -h now

Then save your config and reboot the Homebridge container. After your raspberry pi has restarted and the WebUI has come available, check your Homekit, your Server should now appear along with your other smart devices. To test if everything is working, open the log window from the top right (WebUI) and click the button in homekit. A successful/failed log should appear here.

Waking up

Shutting down (you won’t see “Shutting Down” on the LCD when using SSH)

Share:

Facebook
Twitter
Pinterest
LinkedIn

2 Responses

  1. cool project thanks. Do you know how to hide the root password in the command. this is an security threat, isn’t it?

    Patrick

Leave a Reply

Your email address will not be published. Required fields are marked *