I have to ping every 5 - 10 second a device to see if it is online or offline (i don't know the ip)

Routers route between physically connected networks. VPN's connect devices on networks that are not necessarily directly connected. That might be a network or just an individual device.

The critical difference is that a router does not provide an encrypted link whereas a VPN does. So if you need to route over an untrusted network (e.g. the Internet), you need a VPN in addition to a router.

I fully understand networking, where in op's story can we make the assumption that there is an untrusted network involved ? I think op should paint a topology picture before one needs to jump to vpn's.

At first glance this all appears to be within a LAN (ie. PC + NAS in LAN ?), or are they separate locations ? I can't tell.
If the latter, an option could be to use a ddns service like dyndns, update the IP via REST dynamically from the PC and query domain using the API (which exposes the last IP update time) from node-red, then you don't have to expose anything to the internet.

If this "server" is so critical that 5 seconds of "downtime" is too much, it is time to think about a more robust solution (like VPS) than a mobile router with dynamic IP's.

In post 9

It's possible I'm misunderstanding your exact need but if you're just checking power status, can't you plug the device in using a Tasmota plug (or Kasa which also uses LAN-only connections) and check the power state as frequently as you like? Then do a Switch node for if the power is off do X and power on do Y?

Reading this again then I am also confused. Taken literally it says that you want to run something on a PC that tells you whether that same PC is connected to the internet? If so then just ping something like Or maybe ping a few well known servers and if any of them respond then you are online.

Late to the party but...
It looks like this is all on a residential network, and if so how exactly do you get to the internet? As @TotallyInformation said you must have a router somewhere, and as @bakman2 stated it would be useful to know the exact topology. My two cents is a lot of residential routers have VPN capabilities. If he has a router at both ends that he controls and has VPN baked in that seems a solution. Lots of unknowns.

Currently i'm out for work and i have my personal tower pc with me.
I leave it in the hotel room mining while i'm at work.
The fact is that every time i come home the PC is on the startup screen as if someone has rebooted or the power went missing (kernel error, same one that you get when you unplug it).
So i'm searching a way to find out if the pc is the only thing turned off while i'm away.
What i want to do is, if my pc goes offline a telegram message allerts me so i can use my drop in in the alexa (located in the same room) to see if the power is on in the first place and then hear if there is someone messing with my pc (cleaning lady perhaps?) but the last one is only a supposition.

Moral of the story, this is not a long term operation, in reality i'm just trying to learn node red and every aspect of it, so this is more an exercise to me.

No no, the only thing i need is to know if the power on that pc is missing for a period of time

By the way i resolved everything with 2 MQTT brokers working in parallel (so i can exclude that one site is down).
The pc sends a keepalive signal every 3 seconds via MQTT to the NAS that has a 10 seconds timer for an alarm which get resetted everytime it receive the keepalive signal.

Do you leave the air confitioning on too, so it stays cool?
Maybe the hotel don't think it's a good use of their electricity!

no only the windows open, then we pay a awful lot for how lurid this hotel is, i think is my right to use the power socket as i like in my room...

I'm pretty sure you are wrong and any hotel no matter the quality would find your use highly objectionable and may well confiscate the device. Certainly don't try it in cities with strong betting cultures such as Vagas. Nor should you try it in areas that have poor privacy and security such as Moscow.

Indeed, many hotel rooms have card readers that disconnect the power, lighting, etc when you are not in the room.

I'm trying to figure out exactly how this relates to node red? Moderators weigh in here?

If all you are trying to determine is when the machine was switched off then just look in /var/log/syslog