mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-29 21:03:40 +00:00
chore(dev): add HACS installation and sync scripts for testing
Added scripts to install HACS in DevContainer for testing the integration alongside other HACS components. Changes: - scripts/setup: Automatically install HACS and create symlink - scripts/sync-hacs: Sync HACS-installed integrations via symlinks - .gitignore: Ignore custom_components/* except tibber_prices HACS installs to config/custom_components/, symlinks in custom_components/ make integrations visible to Home Assistant. Impact: Developers can test with other integrations. No user changes.
This commit is contained in:
parent
3a9ba55dd3
commit
60c3b72932
3 changed files with 101 additions and 0 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -19,6 +19,11 @@ uv.lock
|
||||||
config/*
|
config/*
|
||||||
!config/configuration.yaml
|
!config/configuration.yaml
|
||||||
|
|
||||||
|
# HACS and other custom components installed for testing
|
||||||
|
# Ignore everything in custom_components/ except tibber_prices
|
||||||
|
custom_components/*
|
||||||
|
!custom_components/tibber_prices/
|
||||||
|
|
||||||
# Home Assistant database and logs
|
# Home Assistant database and logs
|
||||||
*.db
|
*.db
|
||||||
*.db-shm
|
*.db-shm
|
||||||
|
|
|
||||||
|
|
@ -25,4 +25,61 @@ fi
|
||||||
|
|
||||||
scripts/bootstrap
|
scripts/bootstrap
|
||||||
|
|
||||||
|
# Install HACS for testing with other custom components
|
||||||
|
echo ""
|
||||||
|
echo "==> Installing HACS in dev environment..."
|
||||||
|
echo " This allows testing your integration alongside other HACS components."
|
||||||
|
|
||||||
|
# Ensure config directory is initialized by Home Assistant first
|
||||||
|
if [ ! -f "config/.HA_VERSION" ]; then
|
||||||
|
echo " → Initializing Home Assistant config directory..."
|
||||||
|
hass --config "${PWD}/config" --script ensure_config >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create custom_components directory if it doesn't exist
|
||||||
|
mkdir -p config/custom_components
|
||||||
|
|
||||||
|
# Clean up existing HACS installation if present
|
||||||
|
if [ -d "config/custom_components/hacs" ]; then
|
||||||
|
echo " → Removing existing HACS installation..."
|
||||||
|
rm -rf config/custom_components/hacs
|
||||||
|
fi
|
||||||
|
if [ -L "custom_components/hacs" ]; then
|
||||||
|
echo " → Removing existing HACS symlink..."
|
||||||
|
rm -f custom_components/hacs
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Download and extract HACS (stable release ZIP)
|
||||||
|
cd config/custom_components
|
||||||
|
echo " → Downloading HACS..."
|
||||||
|
if wget -q https://github.com/hacs/integration/releases/latest/download/hacs.zip && \
|
||||||
|
unzip -q hacs.zip -d hacs && \
|
||||||
|
rm hacs.zip; then
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Install HACS Python dependencies
|
||||||
|
echo " → Installing HACS Python dependencies..."
|
||||||
|
if uv pip install -q 'aiogithubapi>=22.10.1'; then
|
||||||
|
# Create symlink so HA finds HACS alongside tibber_prices
|
||||||
|
echo " → Creating symlink in custom_components/..."
|
||||||
|
ln -sf "${PWD}/config/custom_components/hacs" custom_components/hacs
|
||||||
|
|
||||||
|
echo " ✓ HACS installed successfully in config/custom_components/hacs/"
|
||||||
|
echo " ℹ️ HACS is installed as stable release (no auto-updates)"
|
||||||
|
echo " ℹ️ HACS will install other integrations in config/custom_components/"
|
||||||
|
echo " ℹ️ Run './scripts/sync-hacs' after installing integrations via HACS"
|
||||||
|
else
|
||||||
|
echo " ⚠️ Warning: Failed to install HACS Python dependencies"
|
||||||
|
echo " ℹ️ You can install manually: uv pip install 'aiogithubapi>=22.10.1'"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " ⚠️ Warning: HACS installation failed"
|
||||||
|
echo " ℹ️ You can install manually:"
|
||||||
|
echo " cd config/custom_components"
|
||||||
|
echo " wget https://github.com/hacs/integration/releases/latest/download/hacs.zip"
|
||||||
|
echo " unzip hacs.zip -d hacs && rm hacs.zip"
|
||||||
|
cd ../..
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "==> Project is now ready to go!"
|
echo "==> Project is now ready to go!"
|
||||||
|
|
|
||||||
39
scripts/sync-hacs
Executable file
39
scripts/sync-hacs
Executable file
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# script/sync-hacs: Sync HACS-installed integrations to custom_components/
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
|
echo "==> Syncing HACS-installed integrations..."
|
||||||
|
|
||||||
|
# Check if config/custom_components exists
|
||||||
|
if [ ! -d "config/custom_components" ]; then
|
||||||
|
echo " ℹ️ No config/custom_components directory found"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create symlinks for all integrations in config/custom_components/
|
||||||
|
# except those that already exist in custom_components/
|
||||||
|
synced=0
|
||||||
|
for dir in config/custom_components/*/; do
|
||||||
|
component=$(basename "$dir")
|
||||||
|
target="custom_components/$component"
|
||||||
|
|
||||||
|
# Skip if already exists and is not a symlink (don't touch tibber_prices)
|
||||||
|
if [ -e "$target" ] && [ ! -L "$target" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create or update symlink
|
||||||
|
ln -sf "${PWD}/config/custom_components/$component" "$target"
|
||||||
|
echo " ✓ Linked: $component"
|
||||||
|
synced=$((synced + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $synced -eq 0 ]; then
|
||||||
|
echo " ℹ️ No new integrations to sync"
|
||||||
|
else
|
||||||
|
echo " ✓ Synced $synced integration(s)"
|
||||||
|
fi
|
||||||
Loading…
Reference in a new issue