Help Requested: Automation to notify me if my WAN IP changes

I’ve installed the DNS IP Integration. Actually, firstly, does anyone know what the update interval is (and whether/how it can be modified)?

I’d like my HA to send me a notification (in my case, via Twilio SMS), with the new IP address, if the IP address were to change. Such a feature would be particularly useful for those who access their HA via VPN. The DNS IP integration creates an entity called sensor.myip. I am not yet acquainted with Node Red, so I think the best way to achieve my objective is to create an automation that takes a snapshot of the current IP address nightly (in my case, at midnight), and checks the IP address against that nightly snapshot throughout the next day (in my case, every hour).

So far this is my automation. I’m stuck on the part where the entity state at each hourly interval is compared to the midnight state. Is anyone willing to chime in?

alias: IP Address Change > Notify
description: ''
trigger:
  - platform: time
    at: '00:00:00'
    id: Midnight Snapshot
  - platform: time_pattern
    id: Hourly Check
    hours: /1
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: Midnight Snapshot
        sequence:
          - service: scene.create
            data:
              scene_id: ip_at_midnight
              snapshot_entities: sensor.myip
      - conditions:
          - condition: trigger
            id: Hourly Check
        sequence:

    default: []
mode: single

I just do this:

- id: 1a4dc408-76f5-41cf-8b68-c3ec3bcf3c59
  alias: 'IP Change'
  trigger:
    platform: state
    entity_id: sensor.myip
  action:
  - service: notify.telegram_system
    data:
      title: '⚠️ *Public IP changed*'
      message: "From {{ trigger.from_state.state }} to {{ trigger.to_state.state }}"

That’s perfect! Thank you!

1 Like

I occasionally get notifications that my IP has changed from unavailable to x.x.x.x. I’m trying to configure some conditions to prevent this. Here’s what I’ve landed on. Unfortunately, since my IP changes so infrequently this is a bit difficult to test:

alias: Public IP Changed
description: Send a notification when the Public IP has changed
trigger:
  - platform: state
    entity_id:
      - sensor.myip
condition:
  - condition: template
    value_template: "{{ trigger.to_state.state != 'None' }}"
  - condition: template
    value_template: "{{ trigger.from_state.state != 'None' }}"
action:
  - service: notify.notify
    data:
      title: ⚠️ Public IP changed
      message: From {{ trigger.from_state.state }} to {{ trigger.to_state.state }}
mode: single

You can temporarily assign states to the sensor in Developer Tools → States for testing.