When I used homebridge earlier, there was a program I could have running on my Windows PC that told Homebridge if the PC was on or off, and I could send a shutdown command.
Is it possible to make Home Assistant work like this?
So that if I start my PC manually it will get the status from it?
Will this get the state from the PC too? Even if I start the PC with the normal power button (not Home Assistant) will Home Assistant be able to get the state that it is turned on or off?
Thank you!
The wake on lan switch will ping your device to see if it’s on. The only downside is it will initially turn back off until your computer boots and the switch can register it’s on.
You’re right. I don’t defined a turn_off method on my WOL switch, so it turns back off after hitting it on. Maybe this is the reason why my switch is always off.
I managed to make the wake on lan function work, and it will get the state too.
But shutting off is not working.
This is my shell command:
shell_command:
pc: ‘net rpc shutdown -I 192.168.1.3 -U USERNAME%PASSWORD’
And this is the switch itself:
- platform: wake_on_lan
name: PC
mac_address: “MACADRESS”
host: 192.168.1.3
turn_off:
service: shell_command.pc
If I try to run this on SSH from the NAS itself (which Home Assistant is installed to).
This is the result:
Unknown parameter encountered: “printer admin”
Ignoring unknown parameter “printer admin”
Could not connect to server 192.168.1.3
The username or password was not correct.
Connection failed: NT_STATUS_LOGON_FAILURE
Could not connect to server 192.168.1.3
The username or password was not correct.
Connection failed: NT_STATUS_LOGON_FAILURE
The username that is displayed in C:\Users is my first name only. When I check out my username in the settings it is both my first and last name.
And if I try from SSH on my server with just my first name this is the result:
Unknown parameter encountered: “printer admin”
Ignoring unknown parameter “printer admin”
Could not connect to server 192.168.1.3
The username or password was not correct.
Connection failed: NT_STATUS_LOGON_FAILURE
Could not connect to server 192.168.1.3
The username or password was not correct.
Connection failed: NT_STATUS_LOGON_FAILURE
If I try with both first and last name, separated with a space I will get the question
“Enter Firstnames’s password:”
Which I enter, and then I get the same error:
The username or password was not correct.
Connection failed: NT_STATUS_LOGON_FAILURE
But the difference is that one is a recognized username and the others isnt. Even though it doesnt work anyway!
Latest version, just updated. Installed on a Debian server.
By the way, can you put shell_command on configuration.yaml or do you have to create another file for it. I think there is something easy I have missed, as everything else works. And I now can use the exact same command on SSH.
Now it got me thinking, maybe having Home Assistant installed in a Docker container causes problems? Maybe it wont let me run shell commands? I tried a simple test_cmd: touch /home/docker/.config/homeassistant/test.txt
And ran it from Home Assistant Services tab, and no file is created.
If you haven’t figured it out, a command in a docker container will run inside the container, not the host. So if you wanted to make a text file in /home/docker/.config/homeassistant, you’d probably want to use ‘touch /config/test.txt’ assuming you had ‘-v /home/docker/.config/homeassistant/:/config’ in your run command. I don’t think it’s possible to run a command as the host from a docker container (you could try ssh’ing into the host if necessary). The container acts as its own computer, not like a program on yours.