Spacer
October 12, 2025, 11:41am
1
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
SJ20035
October 12, 2025, 11:45am
2
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
tom_l
October 12, 2025, 12:43pm
3
If you just want to get your public IP address use this with the default configuration values:
2 Likes
AaronCake
(Aaron Cake)
October 13, 2025, 3:10pm
4
Can also pull it via SNMP from your router, if your router supports that.
davygravy
(Dave Purdy)
January 5, 2026, 4:17am
5
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.
stevemann
(Stephen Mann (YAML-challenged))
January 5, 2026, 4:45am
6
This works for me:
- platform: rest
name: "External IP"
resource: "https://api.ipify.org/?format=json"
value_template: "{{ value_json.ip }}"
1 Like