Start automation if PC is offline / switched off


my PC has got a static IP address in my network. How can I start an automation with a delay (turn off lights) when the computer is switched off? My first idea is to ping PC’s IP address every minute? Do you have other suggestions?


The device tracker is made for this. Works better than the network ping function, as network ping stores a lot of information in your DB about response times.

Works perfectly. I also use it for tracking Google DNS ( to determine problems on internet break-out.

1 Like

My modem is a ZYXEL LTE3302. In the example of this integration I see netgear:

  - platform: netgear

Or is platform just a string which I can set as I want?

Is it possible to use this integration for my modem or PC? Are you sure? The documentation is very poor.

Im on ny phone, and can not get proper copy/paste to work. Will give a good example tomorrow, however here

  • platform: ping

Can not get indentation to work on the phone, however googledns-test needs 2nspaces more than hosts line.

This goes in the device_tracker part of your configuration.yaml

- platform: ping

This will create a entity called “device_tracker.google_ping_test”

1 Like

netgear is just an example. All of these do presence detection. Integrations - Home Assistant

1 Like

You could use something like this to give you sensors for PC state, you can even use it to shut down your PC from home assistant and lots more.

1 Like

I struggled a lot but I have my PC as a state now.

My automation with this PC is now: If the PC is switched off (not pingable?) turn off the shelly plug (light).

But the problem is that my automation is triggered every 5 - 10 minutes ALTHOUGH my PC is still running. I think there are “network issues” every 5 - 10 minutes and the PC is not pingable in these moments. How can I fix this problem?

My configuration.yaml:

And the trigger in the automation:

The trigger in YAML version:

platform: state
  - device_tracker.white_pc_ping
to: not_home

Have you confirmed by looking at the ping history that it’s dropping out and assuming it is how often this happens and for how long?

Thinking if you knew this then maybe you could change the trigger to have a ‘for’ time of a few mins or what ever suits to mitigate the occasion loss of ping.

If I interpret these tiny lines in the history correctly, it happens every 5-10 mins.

It’s hard to hover over these red lines but as you can see I could do it once. The PC seems to be away for seconds or maybe 1 min? I don’t know.

I set 2 mins in “For (optional)” and test this now. But what’s about consider_home in my configuration.yaml? I thought that’s the correct parameter in this scenario.

Fix your network.

Not sure that’s a network issue as it’s like clockwork and network issues don’t tend to behave that rhythmically.

You do know that you can change the dates and times in the history screen to make it clearer by zooming in on a smaller time period? Anyway the away section you highlighted state the entity was considered away for a matter of milliseconds.

So changing your trigger to away for 30 secs or so should solve the issue.

Consider home is simply the time the device has to be seen home before it is marked as home. So in your case you are sending a ping every 60 seconds then marking as home after 120, so in affect it will be marked as home when the device has responded correctly to the first 2 pings.

Yes, the problem is too rhythmic. I have problems with my modem im general. It’s a temporary solution because we can only access the internet with an LTE router at the moment. This is a new house where the internet line is not yet connected. WiFi devices like the hoover and camera are often disconnected. It seems I’m not the only one with this problem. There are a lot threads about this problem with my router.

But I solved the problem. But I thought consider_home does the opposite. Because the parameter is explained as “Seconds to wait till marking someone as not home after not being seen.” So I thought it’s working exactly like the “for” value in the trigger.