Create sensor from external IP

Hello,

I am quite new to HA and need some help.

I want to create some kind of sensor from an external IP (IPv4) address.

To get the IP, I have a simple shell script, which I can execute in HA and which returns the desired IP address.

Thanks in advance

Jan

1 Like

Since it is a shell script you can use the command_line integration.

sensor:
  - platform: command_line
    name: External IP Address
    command: "curl -s https://api.ipify.org"
    scan_interval: 300
    unique_id: external_ip_address
1 Like

If you just want to get your public IP address use this with the default configuration values:

2 Likes

Can also pull it via SNMP from your router, if your router supports that.

I tried this, but what the docs say is the SNMP OID for the public/wan ip actually turns out to be the ISP’s gateway ip. I’ve gone over it repeatedly, checking several whats-mp-ip sites.

Of note, I have a dynamic external ip.

This works for me:

- platform: rest
  name: "External IP"
  resource: "https://api.ipify.org/?format=json"
  value_template: "{{ value_json.ip }}"
1 Like