Ping with smart plugs switches

So very new to home-assistant only just managed to get my smart plugs from smart life to work in Home-Assistant under Tuya and now I want to do what I thought was simple is a ping trigger

So I have virgin media (ISP1) to ping 194.168.8.100 which ISP2 EE can not ping so plug is on and ping to VM DNS every 5 seconds if two pings fail plug turns off then another trigger if ping succeeds by two pings plug turns on.

Any step by step would really help thanks

I did it!

went down a rabbit hope with needing to do Use the Ping Binary Sensor then found out it had moved might be a little guide later was fun getting it wrong and the switch going in a loop off/on

Ok so over night I let it run before I have a firewall drop pings for testing to know it worked but found it triggered at around 8:30am might be due to the ping being done over wifi? So I up the count from 2 to 5 and see how it goes but one thing I did spot was interval only goes down to 30 second when set to 5? is that a bug?

Anyway to add ping to HA was very simple if you don’t follow old posts due to it being move to settings > devices & services click add Integration and type ping.

Then I needed to setup two automation like so:
When add trigger device then your smart switch on
and another
When add trigger device your ping disconnected

very important add your And if
And if add condition device your ping disconnected

Then do add action device your smart switch off

next automation
When add trigger device then your smart switch off
and another
When add trigger device your ping connected

very important add your And if
And if add condition device your ping connected

Then do add action device your smart switch on