Files
hermes-skills/smart-home/smart-home-automation/references/ha-integration-config-editing.md
T

107 lines
3.3 KiB
Markdown

# Editing HA Integration Config Entries Directly
When a HA integration's configuration (host, port, credentials) needs updating
but the UI is unavailable or the integration was auto-discovered (zeroconf/ssdp),
you can edit the config entry storage file directly.
## File Location
```
/mnt/data/supervisor/homeassistant/.storage/core.config_entries
```
Accessed via Proxmox guest agent (HA is VM 106 on proxmox1):
```bash
ssh -i ~/.ssh/id_ed25519_proxmox root@10.0.20.10 \
"qm guest exec 106 --timeout 30 -- bash -c 'cat /mnt/data/supervisor/homeassistant/.storage/core.config_entries'"
```
## Format
JSON array of config entry objects. Each entry has:
```json
{
"entry_id": "5e1d2138...",
"domain": "nut",
"title": "192.168.100.27:3493",
"data": {
"host": "192.168.100.27",
"port": 3493
},
"source": "zeroconf",
"disabled_by": null,
...
}
```
## Editing Procedure
1. **Backup first**:
```bash
cp .../core.config_entries .../core.config_entries.bak
```
2. **Find the entry** — grep for the domain or old IP:
```bash
grep -A20 '"domain":"nut"' core.config_entries | head -25
```
3. **Replace the value** (sed):
```bash
sed -i 's/"host":"192.168.100.27"/"host":"10.0.30.100"/g' core.config_entries
```
4. **Verify the change**:
```bash
grep '"host":"10.0.30.100"' core.config_entries
```
5. **Restart HA** — changes to `.storage/` files only take effect after restart:
```bash
curl -s -X POST "$HA_URL/api/services/homeassistant/restart" \
-H "Authorization: Bearer $HA_TOKEN" \
-H "Content-Type: application/json" -d '{}'
```
6. **Verify after restart** — poll `GET /api/config` until `state: RUNNING`,
then check entity states for the affected integration.
## NUT/UPS Walkthrough (June 2026)
### Problem
NUT integration entities all `unavailable`. Config entry pointed to old IP
`192.168.100.27:3493` after network migration to `10.0.30.x`.
### Root Causes (3 separate issues!)
1. **NUT server `MODE=none`** in `/etc/nut/nut.conf` → upsd wouldn't start
- Fix: `sed -i 's/^MODE=none/MODE=netserver/' /etc/nut/nut.conf`
2. **upsd.conf bound to old IP** — `LISTEN 192.168.100.27 3493`
- Fix: `echo 'LISTEN 0.0.0.0 3493' > /etc/nut/upsd.conf`
3. **Duplicate `[monitor]` section** in `upsd.users` (two entries, conflicting)
- Fix: Rewrite with single merged `[monitor]` section
4. **HA config entry pointed to old IP**
- Fix: `sed -i 's/"host":"192.168.100.27"/"host":"10.0.30.100"/g' core.config_entries`
### Verification
```bash
# On NUT host:
upsc apc@localhost # Should return UPS variables
# From HA/remote:
python3 -c "import socket; s=socket.socket(); s.settimeout(3); s.connect(('10.0.30.100', 3493)); print('OK')"
# In HA after restart:
curl -s "$HA_URL/api/states" -H "Authorization: Bearer $HA_TOKEN" | \
python3 -c "import sys,json; [print(f'{e[\"entity_id\"]}: {e[\"state\"]}') for e in json.load(sys.stdin) if 'apc' in e['entity_id'].lower()]"
```
### Key Entities After Fix
- `sensor.apc_akku_ladung`: 100 (battery charge %)
- `sensor.apc_batteriespannung`: 13.6 (battery voltage)
- `sensor.apc_eingangsspannung`: 244.0 (input voltage)
- `sensor.apc_status`: Online, Low Battery
- `sensor.apc_last`: 75 (load %)
⚠️ "Low Battery" at 100% charge with 60s runtime = aging battery (mfg date 2019/10).
Consider replacement.