Switch creation / Wake on LAN

hello, im very new to Home Assistant but i really to to learn as much as possible.

i want to wake up my NAS, it already works if i do this via shell script or shell command.

my problem is thad my config dont create any switch!
it doesnt matter if i write my code in an new .yaml file and include this or directly in configuration.yaml.

in my case it looks like this:

#top config
wake_on_lan:

switch:
  - platform: wake_on_lan
    mac: "AC:XX:XX:XX:XX:XX"
    name: "Hostname"
    host: "192.168.0.7"

image

i checked the spaces (2 in front of -platform, 4 in front of name,mac,host) checked the config, rebootet hassio etc. etc. i really dont know my problem.

thank your for your time!

greetings

:thinking:
mac: “xx-xx-xx-xx-xx-xx”

its just an “sample” code. ignore thad. the see the screenshot :wink:

Try it - - - - not : : : : :
mac: “AC-22-08-2A-50-0F”

ScreenShot_20211215121103

i tried with ---- instead of ::::. nothing changed

probable I have expressed myself incorrectly.

My problem is not the wake_on_lan function!
My problem is that the switch is not created. Doesnt matter if i write the mac with : or with -. the switch does not apear…

image

# Example configuration.yaml entry
switch:
  - platform: wake_on_lan
    mac: MAC_ADDRESS

https://www.home-assistant.io/integrations/wake_on_lan/

i am one step further now.

i copied my config 1 : 1 to another instance of Homeassistant, and hey… the switch apears there!
Also the standard switch from the switch documentation works for me. only the WOL switch doesnt apear.

any idea?

1 Like

You’re not looking for anything specifically that says WOL right? Your switch will be named switch_yourcomputername

yes. when im searching (after restart) for “switch.” it wont apear… my blind switch apears…

Can you try and just put the switch in your config file, rather than calling back to the switch.yaml? I know it should work the way you have it, but maybe a different method will knock something loose. For example, in my configuration.yaml, I have:

switch: 
  - platform: wake_on_lan
    mac: "xx-xx-xx-xx-xx-xx"
    name: "MewMew"
    broadcast_address: "xxx.xxx.x.xxx"

I have another PC below that as well. Both switches show and work with WoL

thanks for replay, i allready tried this. but nvm here again! i just edited like you wanted:

still no switch after restart… :frowning:
image

Check your logs. Are there any errors?

Hi @ondras12345,

also checked! No Entry…

i dont get it what the problem is… same code on other instance works.

Ok, this is probably not going to help, but try refreshing the frontend with ctrl+F5. That should ignore your browser’s cache and reload everything. It sometimes happens to me that when I add a new entity, I cannot access it from the entity filter quick bar. Maybe this is something similar.

also dont works :frowning: i think i try a reinstallation…

Try changing the name of the switch. Maybe there’s some weird name conflict.

good idea! tried it, but dont worked :frowning:

You have quotations for both name and mac address and the host is commented out - this is wrong.

Here is what I have in mine and it works:

  1. switch.yaml
- platform: wake_on_lan
  mac: 00:11:22:33:44:55
  name: server
  host: 192.168.1.X
  turn_off:
    service: shell_command.turn_off_server
  1. configuration.yaml
## wol ##

wake_on_lan:

shell_command:
  turn_off_server: "ssh -p 59622 [email protected] 'sudo systemctl start systemd-suspend'"

and add this to point your configuration.yaml to the switch.yaml file

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

## New entries

switch: !include switch.yaml

That pretty much it and ensure you follow the WOL guide for the rest as previously posted above by @krskrab:

Good luck and hope this helps

Note: I am using fedora for my server with NVIDIA card so my command to suspend differs from the WOL guide in HA

3 Likes

I have a problem getting the shell script to work to turn off the server. The current code is:

switch:
  - platform: wake_on_lan
    mac: "00:11:32:26:xx:xx"
    turn_off:
      service: shell_command.turn_off_kanga

shell_command:
  turn_off_kanga: "/usr/bin/ssh -i /config/scripts/id_rsa -o UserKnownHostsFile=/config/scripts/known_hosts [email protected] 'sudo shutdown now'"

I have automatic login into the synology server based on key pairs and “sudo shutdown now” can be used by the user on the server without password. known_hosts and id_rsa has been copied to the /config/scripts directory.

When I turn the switch off I get an error 255 so it seems the login into the server seems not to work. Anyone understands what goes wrong?