-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_ha_dev.sh
More file actions
executable file
·71 lines (59 loc) · 1.91 KB
/
Copy pathrun_ha_dev.sh
File metadata and controls
executable file
·71 lines (59 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -e # Fail on error
if [ ! -d "ha_venv" ]; then
echo "Creating Home Assistant venv using Python 3.12..."
python3.12 -m venv ha_venv
# shellcheck source=/dev/null
source ha_venv/bin/activate
echo "Installing Home Assistant..."
pip install homeassistant colorlog
else
# shellcheck source=/dev/null
source ha_venv/bin/activate
fi
# Ensure config directory exists
mkdir -p config/www/fonts
# Copy the card and fonts to www for /local/ access
rm -f "$(pwd)/config/www/idotmatrix-card.js"
cp -f "$(pwd)/custom_components/idotmatrix/www/idotmatrix-card.js" "$(pwd)/config/www/idotmatrix-card.js"
# Copy font if it exists
if [ -f "$(pwd)/custom_components/idotmatrix/fonts/Rain-DRM3.otf" ]; then
cp -f "$(pwd)/custom_components/idotmatrix/fonts/Rain-DRM3.otf" "$(pwd)/config/www/fonts/Rain-DRM3.otf"
fi
# Check if integration is linked
if [ ! -L "config/custom_components/idotmatrix" ]; then
echo "Linking integration..."
mkdir -p config/custom_components
rm -rf config/custom_components/idotmatrix
# Use absolute path for safety
ln -sf "$(pwd)/custom_components/idotmatrix" "$(pwd)/config/custom_components/idotmatrix"
fi
# Overwrite configuration.yaml to ensure valid YAML (no duplicate keys) and correct settings
echo "Generating configuration.yaml..."
cat > config/configuration.yaml <<EOF
default_config:
http:
server_port: 8128
cors_allowed_origins:
- all
frontend:
themes: !include_dir_merge_named themes
extra_module_url:
- /local/idotmatrix-card.js?v=$(date +%s)
# Time sensor for iDotMatrix card
sensor:
- platform: time_date
display_options:
- time
- date
EOF
PORT=8128
if command -v lsof >/dev/null 2>&1; then
PIDS=$(lsof -tiTCP:${PORT} -sTCP:LISTEN || true)
if [ -n "$PIDS" ]; then
echo "Stopping processes on port ${PORT}: ${PIDS}"
kill "$PIDS" || true
fi
fi
echo "Starting Home Assistant..."
hass -c config