Get Wan Address of Home Assistant

Hey

How do i get the ip address of HASS. not 192.168.1.x
Looking for the one its is using ti access the internet. DNSIP offers no help.
is there a sensor “command_line” i can put it???

If you’re behind a normal domestic router, it’s that device that sees your public IP address on its WAN interface, not the machine you’re running Home Assistant on.

Give us a few more details about your setup (installation type, router model, internet connection) and we may be able to help.

How is dnsip not helping? Did you install the integration?

Hey Troon,

Yeah i am running a linksysWRT1900 on OpenWRT.
I basiclly run most things through one of the VPNs set on the router.
I cant use the dynamic dns because it brings me the ISP IP and not the VPN IP
Host name of the router bring me the local address of the router.

Thanks :slight_smile:

Solved with
sensor:

3 Likes

That was the kind of solution I was going to suggest. There are lots of “my IP address” web pages out there. I created one on a server I manage. Every time HA gets it’s address from home, my web server also saves it, so now my server has my “home” IP address, which I use in some other pages. I never have to change code when my ISP gives me a different IP address.

I could not get this to work. I believe I copied the command correctly, but do not get the results expected.
Under default_config: in my configuration.yaml

sensor:
  - platform: command_line
    name: VPNADDRESS
    command: “wget -O - -q https://checkip.amazonaws.com 2 ”
    scan_interval: 30

results from Developer Tools - States:

 command: “wget -O - -q https://checkip.amazonaws.com”

Not sure whys its added the 2.

1 Like

The 2 means 2 clicks on the link :wink:.

But the quotation marks don’t look right, doesnt it have to be:?

command: "wget -O - -q https://checkip.amazonaws.com"
1 Like

Thanks! BTW… Good eye!! :face_with_monocle: Indeed, it was the quotation marks. I would have never thought, especially using cut&paste. Curiosity, what does the extra - without an option do?

Cut & paste from a post that wasn’t properly formatted, so the forum software converted the quotes into so-called smart quotes — typographically-correct for text, but not for code. This is why it’s always important to format code correctly, as you have done.

It’s not an extra - as such, it’s in combination with the -O and means “send to standard output” instead of saving it to a file. At the command line, this would print out the reply from the URL.

1 Like

not working anymore since version : 2023.12.0
i changed it to : ( without good results ) (state = unknown in HA )

command_line:
  - binary_sensor:
      name: VPNADDRESS
      command: "wget -O - -q https://checkip.amazonaws.com 47"
      scan_interval: 30

it is a sensor, not a binary_sensor.

/config/configuration.yaml:

sensor:
  - platform: command_line
    name: wan_address
    command: "wget -O - -q https://checkip.amazonaws.com"
    scan_interval: 30

For Version 2024.2.1
with new configuration syntax.

Copy, Paste have fun!

command_line:
  - sensor:
      unique_id: wan_adress
      name: WAN Adresse
      command: "wget -O - -q https://checkip.amazonaws.com" 
      scan_interval: 30
3 Likes

Thanks - this worked for me (pasted into configuration.yaml)

Looks good - just some spelling improvements would be:

command_line:
  - sensor:
      unique_id: wan_address
      name: WAN Address
      command: "wget -O - -q https://checkip.amazonaws.com" 
      scan_interval: 30