🇫🇷 Français | 🇬🇧 English
API REST sécurisée permettant à Claude Code et autres outils de lire et modifier les fichiers de configuration Home Assistant.
Secure REST API allowing Claude Code and other tools to read and modify Home Assistant configuration files.
- ✅ Lecture de fichiers (
/api/file/read) - ✅ Écriture de fichiers (
/api/file/write) - ✅ Suppression de fichiers (
/api/file/delete) - ✅ Listage de répertoires (
/api/file/list) - ✅ Vérification d'existence (
/api/file/exists) - 🔒 3 modes d'authentification (HA token, API secret, both)
- 🔒 Protection contre les path traversal
- 📏 Limite de taille de fichiers configurable
- 🎨 Extensions de fichiers autorisées configurables
-
Ajouter le repository dans Home Assistant :
- Paramètres → Modules complémentaires → Boutique des modules complémentaires
- Menu ⋮ (en haut à droite) → Repositories
- Ajouter :
https://github.com/p3x2007-ops/ha-file-api - Fermer
-
Installer l'add-on :
- Rafraîchir la page (F5)
- Chercher "File API v2"
- Cliquer → Installer
- Attendre la fin du build (1-2 min)
-
Configurer l'authentification :
- Onglet "Configuration"
- Choisir le mode d'authentification :
auth_mode: api_secret # ou home_assistant ou both api_secret: "votre_secret_ici" # Si mode api_secret
- Sauvegarder
-
Démarrer :
- Activer "Démarrer au boot" et "Watchdog"
- Cliquer sur "DÉMARRER"
Si vous préférez l'installation locale :
- Créer
/config/addons/file_api_v2/ - Télécharger et uploader les fichiers de ce dossier
- Ajouter repository local :
/config/addons - Installer depuis "Local add-ons"
File API v2 offre 3 modes d'authentification :
auth_mode: home_assistant
api_secret: ""Utilise les tokens Home Assistant natifs (Long-Lived Access Token).
auth_mode: api_secret
api_secret: "mon_secret_securise_123"Secret personnalisé, plus simple pour l'automatisation.
auth_mode: both
api_secret: "mon_secret_123"Accepte soit le token HA, soit votre API secret.
Générer un secret fort :
openssl rand -base64 32 | tr -d "=+/" | cut -c1-32curl https://YOUR_INSTANCE.ui.nabu.casa/api/hassio/ingress/file_api_v2/healthcurl -X POST \
"https://YOUR_INSTANCE.ui.nabu.casa/api/hassio/ingress/file_api_v2/api/file/read" \
-H "Authorization: Bearer YOUR_TOKEN_OR_SECRET" \
-H "Content-Type: application/json" \
-d '{"path": "configuration.yaml"}'curl -X POST \
"https://YOUR_INSTANCE.ui.nabu.casa/api/hassio/ingress/file_api_v2/api/file/write" \
-H "Authorization: Bearer YOUR_TOKEN_OR_SECRET" \
-H "Content-Type: application/json" \
-d '{"path": "www/test.txt", "content": "Hello!"}'- ✅ Accès limité au répertoire
/configuniquement - ✅ Protection contre le path traversal
- ✅ Extensions de fichiers contrôlées
- ✅ Taille de fichiers limitée (10 MB par défaut, configurable jusqu'à 100 MB)
- ✅ Authentification Bearer obligatoire
- ✅ Logging complet de toutes les opérations
# Mode d'authentification
auth_mode: api_secret # home_assistant | api_secret | both
# Secret API (si mode api_secret ou both)
api_secret: "votre_secret_fort"
# Niveau de logs
log_level: info # debug | info | warning | error
# Extensions autorisées
allowed_extensions:
- .yaml
- .yml
- .json
- .js
- .py
- .md
- .txt
- .sh
# Taille max fichiers (MB)
max_file_size_mb: 10 # 1-100Pour plus de détails, consultez la documentation dans le repository principal :
- QUICKSTART.md - Démarrage en 5 minutes (🇬🇧 English)
- CONFIGURATION.md - Guide complet d'authentification (🇬🇧 English)
- README.md - Documentation principale
- Vérifier le mode d'auth :
curl .../health - Si
api_secret: utiliser votre secret - Si
home_assistant: utiliser token HA
- Utiliser chemin relatif :
www/file.js(pas/config/www/file.js)
- Augmenter
max_file_size_mbdans la configuration
- 🎉 Modes d'authentification configurables (HA token, API secret, both)
- ✨ Configuration via UI addon
- 📖 Documentation complète en français
- 🔒 Sécurité renforcée
MIT
Créé pour automatiser les interactions Claude Code avec Home Assistant.
Secure REST API for managing Home Assistant configuration files via Claude Code and automation tools.
- ✅ Read files (
/api/file/read) - ✅ Write files (
/api/file/write) - ✅ Delete files (
/api/file/delete) - ✅ List directories (
/api/file/list) - ✅ Check file existence (
/api/file/exists) - 🔒 3 authentication modes (HA token, API secret, both)
- 🔒 Path traversal protection
- 📏 Configurable file size limit
- 🎨 Configurable allowed file extensions
-
Add the repository in Home Assistant:
- Settings → Add-ons → Add-on Store
- Menu ⋮ (top right) → Repositories
- Add:
https://github.com/p3x2007-ops/ha-file-api - Close
-
Install the add-on:
- Refresh the page (F5)
- Search for "File API v2"
- Click → Install
- Wait for build to complete (1-2 min)
-
Configure authentication:
- "Configuration" tab
- Choose authentication mode:
auth_mode: api_secret # or home_assistant or both api_secret: "your_secret_here" # If api_secret mode
- Save
-
Start:
- Enable "Start on boot" and "Watchdog"
- Click "START"
If you prefer local installation:
- Create
/config/addons/file_api_v2/ - Download and upload files from this folder
- Add local repository:
/config/addons - Install from "Local add-ons"
File API v2 offers 3 authentication modes:
auth_mode: home_assistant
api_secret: ""Uses native Home Assistant tokens (Long-Lived Access Token).
auth_mode: api_secret
api_secret: "my_secure_secret_123"Custom secret, simpler for automation.
auth_mode: both
api_secret: "my_secret_123"Accepts either HA token or your API secret.
Generate a strong secret:
openssl rand -base64 32 | tr -d "=+/" | cut -c1-32curl https://YOUR_INSTANCE.ui.nabu.casa/api/hassio/ingress/file_api_v2/healthcurl -X POST \
"https://YOUR_INSTANCE.ui.nabu.casa/api/hassio/ingress/file_api_v2/api/file/read" \
-H "Authorization: Bearer YOUR_TOKEN_OR_SECRET" \
-H "Content-Type: application/json" \
-d '{"path": "configuration.yaml"}'curl -X POST \
"https://YOUR_INSTANCE.ui.nabu.casa/api/hassio/ingress/file_api_v2/api/file/write" \
-H "Authorization: Bearer YOUR_TOKEN_OR_SECRET" \
-H "Content-Type: application/json" \
-d '{"path": "www/test.txt", "content": "Hello!"}'- ✅ Access limited to
/configdirectory only - ✅ Path traversal protection
- ✅ Controlled file extensions
- ✅ File size limit (10 MB default, configurable up to 100 MB)
- ✅ Mandatory Bearer authentication
- ✅ Complete logging of all operations
# Authentication mode
auth_mode: api_secret # home_assistant | api_secret | both
# API secret (if api_secret or both mode)
api_secret: "your_strong_secret"
# Log level
log_level: info # debug | info | warning | error
# Allowed extensions
allowed_extensions:
- .yaml
- .yml
- .json
- .js
- .py
- .md
- .txt
- .sh
# Max file size (MB)
max_file_size_mb: 10 # 1-100For more details, check the documentation in the main repository:
- QUICKSTART.en.md - 5-minute quickstart
- CONFIGURATION.en.md - Complete authentication guide
- README.md - Main documentation (bilingual)
- Check auth mode:
curl .../health - If
api_secret: use your secret - If
home_assistant: use HA token
- Use relative path:
www/file.js(not/config/www/file.js)
- Increase
max_file_size_mbin configuration
- 🎉 Configurable authentication modes (HA token, API secret, both)
- ✨ Configuration via add-on UI
- 📖 Complete bilingual documentation (French/English)
- 🔒 Enhanced security
MIT
Created to automate Claude Code interactions with Home Assistant.