100 lines
2.4 KiB
Markdown
100 lines
2.4 KiB
Markdown
# Home Assistant Legacy Template Migration
|
||
|
||
**Pure Bash script** to fix all **67 template deprecation warnings** by migrating from legacy `platform: template` syntax to modern `template:` syntax.
|
||
|
||
✅ **No Python required** - Works directly in SSH add-on!
|
||
|
||
## 🚀 Quick Start
|
||
|
||
```bash
|
||
cd /config
|
||
wget https://gitea.hideawaygaming.com.au/jessikitty/ha-template-migration/raw/branch/main/migrate_templates.sh
|
||
chmod +x migrate_templates.sh
|
||
bash migrate_templates.sh
|
||
```
|
||
|
||
Then:
|
||
```bash
|
||
ha core check # Verify configuration
|
||
ha core restart # Apply changes
|
||
```
|
||
|
||
## ⚠️ What This Fixes
|
||
|
||
Home Assistant 2026.6 will remove support for legacy template syntax.
|
||
|
||
**Before (deprecated):**
|
||
```yaml
|
||
binary_sensor:
|
||
- platform: template
|
||
sensors:
|
||
router_authenticated:
|
||
friendly_name: "Router Authenticated"
|
||
value_template: "{{ states('input_text.router_token') != '' }}"
|
||
```
|
||
|
||
**After (modern):**
|
||
```yaml
|
||
template:
|
||
- binary_sensor:
|
||
- name: "Router Authenticated"
|
||
state: "{{ states('input_text.router_token') != '' }}"
|
||
unique_id: router_authenticated
|
||
```
|
||
|
||
## 📊 What It Does
|
||
|
||
✅ Pure Bash - no Python dependencies
|
||
✅ Scans all YAML files
|
||
✅ Creates timestamped backups
|
||
✅ Converts to modern syntax
|
||
✅ Updates configuration.yaml
|
||
✅ Generates restore script
|
||
|
||
## 🛡️ Safety Features
|
||
|
||
- **No Dependencies** - Works in SSH add-on without Python
|
||
- **Automatic Backups** - All files backed up before changes
|
||
- **Exit on Error** - Stops if any step fails
|
||
- **Easy Restore** - One command rollback
|
||
- **No Data Loss** - Preserves all configurations
|
||
|
||
## 📝 Expected Output
|
||
|
||
```
|
||
======================================================================
|
||
Home Assistant Legacy Template Migration (Bash)
|
||
======================================================================
|
||
|
||
✓ Created backup: /config/backups/template_migration_20251223_123456
|
||
|
||
ℹ Found 67 legacy template entities:
|
||
- 15 sensor(s)
|
||
- 52 binary_sensor(s)
|
||
|
||
✓ MIGRATION COMPLETE
|
||
Migrated: 67 template entities
|
||
```
|
||
|
||
## 🔄 Restore if Needed
|
||
|
||
```bash
|
||
bash /config/backups/template_migration_YYYYMMDD_HHMMSS/restore.sh
|
||
ha core restart
|
||
```
|
||
|
||
## 🎯 Result
|
||
|
||
After running, all **67 repair warnings will be cleared!** ✅
|
||
|
||
## 💡 Why Bash?
|
||
|
||
✅ Works in SSH add-on without installing packages
|
||
✅ Faster execution
|
||
✅ No dependency issues
|
||
✅ Native YAML parsing with awk
|
||
|
||
---
|
||
|
||
**Repository:** https://gitea.hideawaygaming.com.au/jessikitty/ha-template-migration
|