Sensor with device state - WoL switch if offline

Hey,

I am currently trying to create a template sensor, which shows either my PC state (if online) or changes to a WoL switch/button (if offline).

My current config so far is only able to differntiate between on and off:

- platform: template
  sensors:
    device_desktop:
      value_template: "{% if is_state('device_tracker.device_desktop', 'home') %}on{% else %}off{% endif %}"

I looked at switch.template, but this would require me to have a turn off action, which I don’t have. So my idea is to have something like a hyperlink, which then triggers a input_boolean, but I don’t know which component to use for that.
Maybe someone can help me a little.

Thanks in advance,
Cludch

1 Like

Use this

switch:
  - platform: wake_on_lan
    mac_address: "AA-BB-CC-DD-EE-FF"
    name: "THEFRIENDLYNAMEYOUWANT"
    host: "192.168.1.11" #this is the ip of the computer you want to wake.

I am using this for waking up my computer and it also shows the state (on or off).
There is a command to also turn off the computer but havent found it yet.
You can program the same switch to send a shell command to the computer to turn it off.
3

1 Like