The IoT WiFi moved from Default (192.168.1.x) to the IoT VLAN (192.168.2.x) with fixed IPs reserved in UniFi. HA 2026.9.3's tplink reconfigure flow ignores the entered host and reconnects to the stored one, so this edits data.host in .storage/core.config_entries with HA stopped, matching entries by MAC and refusing to write unless all 9 match. Backs up core.config_entries first and always restarts hass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.3 KiB
YAML
73 lines
2.3 KiB
YAML
---
|
|
# One-off: repoint Home Assistant's TP-Link (Kasa) config entries at their new
|
|
# addresses after the IoT WiFi moved from the Default network to the IoT VLAN
|
|
# (192.168.1.x -> 192.168.2.x, fixed IPs reserved in UniFi).
|
|
#
|
|
# HA 2026.9.3's tplink "Reconfigure" flow ignores the host entered in the form
|
|
# and reconnects to the stored one, so it cannot be used to change the address.
|
|
# Instead this edits data.host in .storage/core.config_entries while HA is
|
|
# stopped. Entries are matched by MAC (unique_id); nothing else is touched.
|
|
#
|
|
# Run:
|
|
# .venv/bin/ansible-playbook -i ansible/inventories/home/hosts.yml \
|
|
# ansible/oneoff/hass-tplink-rehost.yml
|
|
- name: Repoint HA tplink entries at the IoT VLAN
|
|
hosts: home.debyl.io
|
|
gather_facts: false
|
|
become: true
|
|
become_user: podman
|
|
vars:
|
|
hass_storage: /home/podman/.local/share/volumes/hass/config/.storage
|
|
hass_entries: "{{ hass_storage }}/core.config_entries"
|
|
tasks:
|
|
- name: Get podman uid for systemctl --user
|
|
ansible.builtin.command: id -u
|
|
register: podman_uid
|
|
changed_when: false
|
|
|
|
- name: Dry run - all 9 tplink entries must match before HA is stopped
|
|
ansible.builtin.script:
|
|
cmd: files/hass_tplink_rehost.py
|
|
executable: python3
|
|
register: dry_run
|
|
changed_when: false
|
|
failed_when: "'matched 9 of 9' not in dry_run.stdout"
|
|
|
|
- name: Show dry run
|
|
ansible.builtin.debug:
|
|
var: dry_run.stdout_lines
|
|
|
|
- name: Back up core.config_entries
|
|
ansible.builtin.copy:
|
|
src: "{{ hass_entries }}"
|
|
dest: "{{ hass_entries }}.bak-iot-vlan-20261001"
|
|
remote_src: true
|
|
mode: preserve
|
|
force: false
|
|
|
|
- name: Stop HA, rewrite hosts, start HA
|
|
environment:
|
|
XDG_RUNTIME_DIR: "/run/user/{{ podman_uid.stdout }}"
|
|
block:
|
|
- name: Stop hass
|
|
ansible.builtin.systemd:
|
|
name: hass.service
|
|
state: stopped
|
|
scope: user
|
|
|
|
- name: Rewrite tplink hosts
|
|
ansible.builtin.script:
|
|
cmd: files/hass_tplink_rehost.py apply
|
|
executable: python3
|
|
register: applied
|
|
|
|
- name: Show result
|
|
ansible.builtin.debug:
|
|
var: applied.stdout_lines
|
|
always:
|
|
- name: Start hass
|
|
ansible.builtin.systemd:
|
|
name: hass.service
|
|
state: started
|
|
scope: user
|