Use computers on LAN as sensors

Hi,
I was wondering if there’s a way to use the other computers on my network as a sensor somehow? Basically I want to make an automation that states: if laptop wakes up from sleep / turns on, then keep the light on. No idea how to measure the laptop waking up though. I’ve come across Glances in my search but can’t see how I’d get that to achieve what I want. Any pointers welcome.

You can use a presence detection component like:


And then check the state of the device, if the state is “home” then the device is on/awake and you can trigger your automation.

Thanks Michael,
I set up both of these and the Ping based device_tracker works best for me. Thanks for the suggestion.
When I set up Nmap it add a lot of devices to my dev-states tool - I’m guessing they’re all the different devices connected to my router. They all have a random character string name e.g. device_tracker.807abf5f9018
I’ve since commented the Nmap component out of my configuration but all the device_track.xxx entities remain on the dev-states tool page. Is there any way of removing these do you know?

Edit the known_device.yaml file to remove the unwanted entries.

The ping component works well, no need for NMAP I think.

1 Like

Although this works well if a computer is turned off, if a computer is only asleep, it is still reported as “home” by Ping / Nmap. Is there any way of telling if a computer is asleep?

Try using wake on LAN switch https://home-assistant.io/components/switch.wake_on_lan/

It shows my computer is off when it is in sleep mode, while I also am using my netgear router to check if devices are connected. So the network polling says my computer is connected, but wake on LAN says it is off (which is what I would expect in sleep mode)

2 Likes

Hi,
I was using the wake on lan to detect my pc status and it was working fine but suddenly stopped working and shows pc off all the time. Have you ever had this issue?
Regards
Ali

I have no knowledge about (Wake on LAN). But I think your computer has changed ip and you need to set a static ip for your pc.

Thanks. The problem was an update on my norton360 and it updated a firewall on my computer which was blocking homeassistant to send the command.