Trigger state change (d-link plug) on ping failure help

Noob here, spent the past few hours digging through forums and documentation but seem to be hitting a roadblock hoping you guys can help me with.

Goal:
Ping a local IP address, on failure, power cycle a smart plug

Progress
D-Link smart plug setup manual integration with (through configuration yaml file), works great no issues.

I’ve also setup a binary_sensor for ping to ping the server (powered through the dlink outlet), which appears to work correctly as well.

switch:
  platform: dlink
  host: 10.0.0.50
  username: admin
  password: XXXXX

binary_sensor:
  - platform: ping
    host: 10.0.0.99
    name: "Check Server"
    scan_interval: 30

I’m having issues though figuring out how to setup a trigger to power cycle the dlink outlet, as it does not show up as an actual “device” per-say. Because of this, does that mean that my automation would need to somehow set the state from on to off then from off to on?

This is where i’m getting stuck at, i’m not sure how I would go about doing a power cycle on the dlink device when the ping fails, can anybody help me out or point me in the right direction please?

Reference
I have a very old server that needs to be updated/upgraded but I have not had the time yet to buy new parts, and the easiest solution for me to deal with it for now is to just power cycle. If I could get this automation setup and working it could buy me a little more time to get the funds and parts together to do the upgrade, without much downtime.

Thanks!!

You need a state trigger on the entity.

Only some integrations create devices, most are purely entities, and most use service calls rather than device actions.

Okay thanks, but what about “cycling” the power of the device, what’s the best way to handle that?

  1. Turn off the switch (using the switch.turn_off service)
  2. Delay for, say, 10 seconds
  3. Turn on the switch

Ahhh okay thanks it was under the “Call service” i think it what got me confused (that with the device being known as an “entity”). Once I looked through that to find the switch.turn_off was able to figure the rest of it out. Probably basic n00b stuff but your replies helped me to figure it out, so thank you!!