Closed Timmguin closed 3 years ago
I'll try to cover each step, but you're most likely familiar with some parts already so just skip those you've already taken care of.
I'm assuming you've got homebridge installed. If not, see https://github.com/homebridge/homebridge/wiki.
The first step to get Wake On LAN up and running is to identify your target device's MAC address. The following resource should cover that: https://www.wikihow.com/Find-the-MAC-Address-of-Your-Computer.
Next, homebridge will need to be configured. If you haven't installed the plugin yet you can do so either via the Homebridge UI if installed, or via npm install -g homebridge-wol
. To configure a device for Wake On LAN, simply add the following to your homebridge installation's config.json
in the accessories
array:
{
"accessory": "NetworkDevice",
"name": "Generic",
"mac": "xx:xx:xx:xx:xx:xx"
}
Here accessory
is required to be NetworkDevice
, name
can be set to anything and mac
should be set to the MAC address you found from the first step.
This will make your PC show up as a switch in HomeKit and you will be able to turn it on. Next, you might want the switch to actually reflect the state of your PC - whether it's turned on or off. You'll then need to find its IP address (https://www.whatismybrowser.com/detect/what-is-my-local-ip-address).
Update your accessory configuration to add your IP in the ip
field:
{
"accessory": "NetworkDevice",
"name": "Generic",
"mac": "xx:xx:xx:xx:xx:xx",
"ip": "192.168.1.xxx"
}
The switch will now reflect the state of your PC.
Lastly, there is a lot of tweaking and other features available, but none of which are necessary. These are documented in the README
and also available in the Homebridge UI.
Starting a computer using wake on lan only requires the MAC. The start and shutdown commands are for more complex uses where you’d want more custom behaviour. You will also make sure that your computer is set up to actually work with WoL: https://www.lifewire.com/wake-on-lan-4149800
If starting still does not work after ensuring that WoL is enabled, then there might be something acting up in your network. If that’s the case, we’ll try to do more investigative work.
As for the shutdown command (necessary to actually shut down a computer), try to read the community wiki guide for some clues: https://github.com/AlexGustafsson/homebridge-wol/wiki/Running-on-Synology-Docker-and-turn-Windows-10-on-off-using-SSH-and-Samba
As a general note, the various start and shutdown commands are simply any command that can be run on the system in a regular terminal such as CMD in Windows. This plugin doesn’t intervene with the command in any way. For help with those, it’s usually preferable to search for it on a stack exchange site such as super user.
@Timmguin can you share the shutdownCommand
you're using? Make sure you strip any personal information. Also, could you share the logs? The samba tool used to communicate with Windows PC might have to be installed on your server running homebridge. The logs will yell if there's any issue executing the shutdown command.
As you can see, there are a lot of logs after the shutdown command is run. You’ll have to debug the shutdown command, since it seems to be incorrect. It’s always a good idea to run the command outside of this plugin. The plugin does nothing with the command, so if it works in a regular terminal, it will work with the plugin.
Sorry, but I don't have time for that. I'll leave this issue open, perhaps someone have something to chip in. You can always try to ask on https://superuser.com, Reddit or the like since the issue is quite general and not directly related to this plugin, there should be people there able to help you in a better way.
If you're interested in the topics of a terminal etc. you can always explore it more on your own and come back to the guide to experiment if you've learnt more.
Unfortunately I don't think there's any real way for this plugin to improve the usability as there will always be manual setup required for various computers and operating system, something that's out of scope for this simple plugin. If you have any ideas, please let me know.
Good luck and feel free to post updates here if you are able to progress or solve the issue - it might help others in the future!
It looks like the RSA key has not been created - or it was created under another user. Make sure it exists or try to create it (there should be steps for this in the aforementioned guide).
From the logs:
Warning: Identity file /homebridge/id_rsa not accessible: No such file or directory.
You look to be close now. The last step is to ensure that you're authenticating using SSH keys.
As the user running Homebridge on your server, try to run ssh -i /homebridge/id_rsa username@remote_Address echo 'hello world!'
to connect to your Windows machine and print "hello world!". If you're required to enter your password, SSH keys are not setup properly and you should continue to read this.
First, check if you have configured SSH keys. Do this by running the following command as the user running homebridge:
ls /homebridge/id_rsa
If you receive "no such file or directory", you will have to set the keys up.
> mkdir /homebridge
> ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /homebridge/id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /homebridge/id_rsa
Your public key has been saved in /homebridge/id_rsa.pub
Basically, try to look through the guide for the steps covering SSH keys.
You do not seem to have the privilege to create that file. You may either chose to create the file as root (with sudo
prefixed to the command), but unless you're already running homebridge as root, you're better off creating the file in a directory the user has the privilege to use. For example, if your homebridge user is homebridge
, you might as well exchange /homebridge/id_rsa
with /home/homebridge/.ssh/homebridge_rsa
etc.
On the homebridge server you should now have /homebridge/id_rsa
and /homebridge/id_rsa.pub
. To setup the target computer, run the following command on the homebridge server:
ssh-copy-id -i /homebridge/id_rsa user@host
Here, user
is the username you use to login to your Windows PC and host
the IP address of the Windows PC. You should be prompted to use your password. The command will likely write a text like "Succeeded, now try to login without using a password".
To try to login without using a password, you can now simply execute:
ssh -i /homebridge/id_rsa user@host
You do not need to do anything manually on your Windows PC. So for safety you should be able to remove any files you've copied over. In this case, you can think of /homebridge/id_rsa
as your password and /homebridge/id_rsa.pub
to be your username. The ssh-copy-id
command will copy over /homebridge/id_rsa.pub
to the target and set it up to allow you to login using the key instead of a password.
If you are able to login using the command above without any password, your homebridge setup should work as well.
Try using sudo
: sudo ssh-copy-id /homebridge/id_rsa username@xxx.xxx.x.xxx
Did you try the suggested -f
option?
ssh-copy-id -f /homebridge/id_rsa username@xxx.xxx.x.xxx
I'd recommend reading up on the following topics and potentially post questions on https://superuser.com or https://askubuntu.com if there are things you may not understand. There are also some keywords you may use to find more information online.
Unfortunately, it's a non-goal of this project to serve as an end-to-end solution for controlling computers via HomeKit as that would require further applications etc. installed on each device. Right now our solution is very general, allowing any command, but as you've experienced first hand it may be quite the hurdle to overcome depending on your previous knowledge. Hopefully, the documentation for common use cases like yours will become better with time, but right now I don't have the time to write it on my own. Thankfully I have received help with issues and wikis in the past and hopefully it will continue.
If you're able to solve your issue, please come back and write about it here or as a wiki post as it can help future users facing the same issues. If you have further questions more specific to this plugin or its usage, don't hesitate to ask them here as a discussion post (https://github.com/AlexGustafsson/homebridge-wol/discussions). If you have any feature requests or if you find bugs, you're always welcome top open an issue. Good luck!
Hello so i am completely new to github and anything involving coding but i do have wake on lan set up with my pc and alexa via an alexa skill but i will be switching to apple home kit soon and i would love to get this feature working there as well and i found this and i think It's is what i need and i added the plugin to my homebridge but i'm having trouble understanding how to set it up so help would be very much appreciated :)