Wake on LAN - Switch?

Hi,
Just changing over my options due to the switch function no longer being supported. I’ve sorted out my Logitech Harmony, but struggling with the Wake on Lan option.
This is the guide I used originally - Wake on LAN - Home Assistant
What do I need to substitute the switch part for now?

I use a template switch

  - platform: template
    switches:
      desktop_francis:
        value_template: "{{ is_state('binary_sensor.desktopfrancis', 'on') }}"
        turn_on:
          - service: wake_on_lan.send_magic_packet
            data:
              mac: '9C:5C:8E:C0:24:B9'
        turn_off:
          - service: hassio.addon_stdin
            data:
              addon: core_rpc_shutdown
              input: pc_francis
        unique_id: 6d987d00-b390-4f57-ad25-9ca17ddb8958

I did it this way and it works perfectly - have not tried it with a template (and @francisp I like the extra functionality to actually call a shutdown, I may implement that)

image

(I click on the lightning bolt on the right, it sends the message, waits 1/2 a second, then goes back to it’s original state.)

With this in my configuration.yaml:

#Wake-On-Lan 'Magic Packet'
switch:
  - platform: wake_on_lan
    mac: ##-##-##-##-##-##

Using this automation code behind it:

Hope that helps -

i use one like francis do:

- platform: template
  switches:
    pc_power:
      friendly_name: "PC Power Switch"
      unique_id: "3f5b8bda-27f4-45df-9b86-1c77b8f7f86d"
      value_template: "{{ is_state('switch.tasmota_16d5c6', 'on') and is_state('binary_sensor.ping_pc', 'on') }}"
      turn_on:
        service: wake_on_lan.send_magic_packet
        data:
          mac: B4:2E:99:EE:9C:77
      turn_off:
        service: hassio.addon_stdin
        data:
          addon: core_rpc_shutdown
          input: PC_Shutdown
      icon_template: "mdi:desktop-classic"

and i made this switch available for alexa so i can turn on and off my pc via voice command too ^^

Where can I get details on how to implement this part of it?

Here addons/rpc_shutdown/DOCS.md at 13f49f1c31f157ddf6eac81d513174fa24144897 · home-assistant/addons · GitHub

1 Like

@Spegeli I created a button that when it is clicked calls an automatin to run it. However I get this in my log. Any ideas?

Jul  6 22:23:23 kruse-pi homeassistant[1561]: #033[32m2024-07-06 22:23:23.258 INFO (MainThread) [homeassistant.components.automation.basement_shut_down_basment_pc] Basement - Shut Down Basment PC: Running automation actions#033[0m
Jul  6 22:23:23 kruse-pi homeassistant[1561]: #033[32m2024-07-06 22:23:23.259 INFO (MainThread) [homeassistant.components.automation.basement_shut_down_basment_pc] Basement - Shut Down Basment PC: Executing step call service#033[0m
Jul  6 22:23:23 kruse-pi addon_core_rpc_shutdown[1561]: [22:23:23] INFO: #033[32mRead alias: basement-pc#033[0m
Jul  6 22:23:23 kruse-pi addon_core_rpc_shutdown[1561]: [22:23:23] INFO: #033[32mShutdown basement-pc -> 192.168.10.11#033[0m
Jul  6 22:23:24 kruse-pi addon_core_rpc_shutdown[1561]: Could not connect to server 192.168.10.11
Jul  6 22:23:24 kruse-pi addon_core_rpc_shutdown[1561]: Connection failed: NT_STATUS_CONNECTION_REFUSED
Jul  6 22:23:24 kruse-pi addon_core_rpc_shutdown[1561]: Could not connect to server 192.168.10.11
Jul  6 22:23:24 kruse-pi addon_core_rpc_shutdown[1561]: Connection failed: NT_STATUS_CONNECTION_REFUSED
Jul  6 22:23:24 kruse-pi addon_core_rpc_shutdown[1561]: [22:23:24] ERROR: #033[35mShutdown failed: #033[0m

I tried it twice above

Note the username used has spaces in it - but the configuration does not like single or double quotes around the user name… thoughts?

Dont know if the space is the issue but you can do the following:

Simply make another Account on your PC, name them for Example “HomeAssistant” (or whatever you want) and give them a Passwort. Then use this account for the shutdown command ^^

That what i have done too because my main account is created via a microsoft account with Name & Surname and Space between them too.

@Spegeli thank you for your help! I may try the same but first I have entered a bug fix request here - let’s see what we hear back…