Home Assistant: Automatically Restart Tailscale After an ISP IP Change

If your internet service provider regularly disconnects your connection and assigns a new public IP address, the Tailscale add-on—a modular application within the system—in Home Assistant can occasionally lose connection to the network. Access is often only restored after a manual restart. In this guide, you will set up a helper—a virtual storage entity for data—and an automation that detects IP changes and automatically reboots the service.

What You Need

  • Home Assistant OS or Supervised (with add-on support)
  • Installed and configured Tailscale add-on
  • A sensor to detect your external IP address

1. Create a Text Helper for the IP Address

For the system to recognize an address change, the last known state must be saved.

  1. Navigate to Settings > Devices & Services > Helpers.
  2. Click Create Helper in the bottom right corner and select Text.
  3. Assign a name such as Letzte externe IP (generating the entity input_text.letzte_externe_ip; an entity is an individual data point in Home Assistant) and save the entry.
  4. Enter your current public IP address once into the newly created text field.

2. Monitor the External IP Address via Sensor

You need a sensor that polls your public IP at regular intervals (for example, every 5 minutes).

Add the configuration to your configuration.yaml (or sensor.yaml if split), for instance by querying an external web service:

sensor:
  - platform: rest
    name: "Aktuelle externe IP"
    resource: https://www.wieistmeineip.de/
    scan_interval: 300

After saving, reload the YAML configuration under Developer Tools > YAML > YAML configuration reloading.

3. Create an Automation to Trigger the Reconnect

The automation compares the IP fetched by the sensor with the value stored in the text helper. If they differ, the add-on restarts and the helper updates.

Create a new rule under Settings > Automations & Scenes > Create Automation. Click the three dots in the top right corner, select Edit in YAML, and insert the following code:

alias: "Tailscale bei neuer IP neu starten"
trigger:
  - trigger: state
    entity_id: sensor.aktuelle_externe_ip
condition:
  - condition: template
    value_template: "{{ states('sensor.aktuelle_externe_ip') != states('input_text.letzte_externe_ip') }}"
action:
  - action: DEINE_ADDON_NEUSTART_AKTION
    data:
      addon: DEIN_TAILSCALE_ADDON_SLUG
  - action: input_text.set_value
    target:
      entity_id: input_text.letzte_externe_ip
    data:
      value: "{{ states('sensor.aktuelle_externe_ip') }}"

Adjust the entity IDs, the chosen restart service action, and the add-on slug to match your specific setup if necessary.

Does It Work?

To test the setup, enter an incorrect IP address into the input_text.letzte_externe_ip helper. After the sensor’s next polling interval, the automation should fire, restart the Tailscale add-on, and update the text helper with the correct IP address.

Troubleshooting

  • Automation does not trigger: Check under Developer Tools > States to see whether sensor.aktuelle_externe_ip returns a valid value or is listed as unavailable.
  • Add-on does not restart: Verify the restart action and double-check the spelling of the add-on slug in Developer Tools under Actions.
  • Router integration limitations: Some router integrations (such as UniFi) reportedly do not provide the WAN address directly as a usable entity. An external REST sensor bypasses this limitation.
  • Post-restart delay: Tailscale may take a few seconds after starting before the connection in your tailnet becomes fully active again.

For extra visibility, you can also add a notification step to the actions to alert you whenever an IP change occurs.

Raspberry Pi 5 (16 GB)
Produktbild: Raspberry Pi
Loading product data …

Sources: Forum: Simon42 – Forum, firstreview.eu, home-assistant.io

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top