Help getting WAN IP address

I was wondering if anyone had any ideas on how I could get my WAN address into HA for use in automations and notifications.

I have a Netgear R7000 running xvortex’s Asus WR-Merlin and am using Hassio.

I would like to know when my router dual WAN fails over or back. I can tell which WAN interface is being used from the first couple of octets of the WAN IP address.

SNMP looks like the go but I have no idea how to obtain the required MIB. I downloaded an SNMP walker and had no idea what I was doing.

Is there an easier way?

EDIT: I am using DuckDNS and that does reflect WAN IP changes when the dual WAN changes over. Is there any way I can use that?

EDIT2: This looks like just the thing.

Yes, this will show your public IP in HA and updates every 2min by default.

My Automation on IP change:

  - alias: IP Address Update
    hide_entity: true
    initial_state: true
    trigger:
      - platform: state
        entity_id: sensor.myipopendnscom
    action:
      - service: notify.telegram
        data:
          title: Your Public IP has changed to
          message: "{{ states.sensor.myipopendnscom.state }}"
      - service: persistent_notification.create
        data_template:
          title: "{{ as_timestamp(now()) | timestamp_custom('%b %d %Y %I:%M:%S %p', true) }}"
          message: "Your public IP has changed, and is currently {{ states.sensor.myipopendnscom.state }}"
          notification_id: IP Address Update
2 Likes

Yep. Works perfectly. My automation was very similar.

- id: dns_notification
  alias: 'DNS Change Notification'
  trigger:
  - platform: state
    entity_id: sensor.[my domain redacted]
  action:
  - service: notify.all_ios_devices
    data_template:
      message: 'IP changed: {{ trigger.from_state.state }} → {{ trigger.to_state.state }}'
      data:
        push:
          sound: "DNSChange.wav"

The message times tamp is a good idea. I’ll add that , thanks.