How to check if two sensor readings match?

Hi, newbie here. Sorry if it’s a silly question, but I haven’t been able to find anything on it so far, and the documentation is a bit overwhelming (for now).

I’m trying to check my phone’s public IP against the server’s and build an automation based off whether those two outputs match. I’m using the DNS IP integration to get the IP of the server, so it’s just a matter of checking the two against each other.

Any advice on the best approach?

Hi, welcome to the forum community and to Home Assistant.

Assuming you already have a trigger for this automation you’ll want to test these two values in a condition using a template condition.

It would look something like this…

Like DuckDNS does?

What is your end use?

You could screen scrape whatismyipaddress.com or similar sites too, or just ask Google ‘what is my External IP Address’. Be aware of their Terms and Conditions about automation however.
Be smart, and just check at the time your ‘connection status’ changes to ‘valid’, and not every 5 microseconds in a big loop please. You don’t want to be barred for inciting a DDOS type attack condition. Your IP Address doesn’t change once the session is established, only (and often unusually) when it is re-established.

This is perfect, thank you!

@HappyCadaver gave me exactly what I was looking for.

Basically I’m checking whether my phone is at home at 7AM on weekdays without the need to enable location services (which seems to be required any other way I tried to set this up, e.g. wifi SSID). I had set it up with a specific public IP, but that changed last week and broke my automation.

I’m using this to track phones of people visiting to avoid disabling the heat when us “official HA users” with the Companion App leave the house:

You may be making assumptions about external IP Address allocation that may not be valid. It is often pure chance the same IP Address is allocated if you reconnect, unless you are specifically paying for that facility.

Maybe setup Static IP addressing for known devices on your local LAN (in the DHCP portion of your router configuration), and check their connection status may be an alternative, however devices in sleep mode may disconnect sessions after a timeout so that may also not work, especially if they are battery powered where maintaining long term sessions is discouraged, by design.
Assuming a device will report in when it leaves your home zone is also fraught with danger. It is hard to measure the absence of something.