1+ #! /bin/bash
2+
3+ # Install Dyson Custom Integration for Home Assistant
4+ # This script provides instructions for downloading and installing the ha-dyson custom component
5+
6+ set -euo pipefail
7+
8+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
9+ PROJECT_ROOT=" $( dirname " $SCRIPT_DIR " ) "
10+ CUSTOM_COMPONENTS_DIR=" $PROJECT_ROOT /homeassistant/custom_components"
11+ DYSON_COMPONENT_DIR=" $CUSTOM_COMPONENTS_DIR /dyson"
12+
13+ echo " Dyson Custom Integration Setup"
14+ echo " =============================="
15+ echo " "
16+
17+ # Create custom_components directory if it doesn't exist
18+ mkdir -p " $CUSTOM_COMPONENTS_DIR "
19+
20+ # Check if we can access GitHub API
21+ GITHUB_RESPONSE=$( curl -s --connect-timeout 5 --max-time 10 https://api.github.com/repos/libdyson-wg/ha-dyson/releases/latest 2> /dev/null || echo " FAILED" )
22+
23+ if [[ " $GITHUB_RESPONSE " != " FAILED" ]] && [[ " $GITHUB_RESPONSE " != * " Blocked by DNS monitoring proxy" * ]] && [[ -n " $GITHUB_RESPONSE " ]]; then
24+ echo " ✅ Network access available - attempting automatic installation..."
25+
26+ # Extract version from response
27+ LATEST_RELEASE=$( echo " $GITHUB_RESPONSE " | grep ' "tag_name"' | cut -d ' "' -f 4)
28+
29+ if [ -z " $LATEST_RELEASE " ]; then
30+ echo " ❌ Could not determine latest release version from API response"
31+ echo " 📋 Please install manually using the instructions below"
32+ MANUAL_INSTALL=true
33+ else
34+ DOWNLOAD_URL=" https://github.com/libdyson-wg/ha-dyson/archive/${LATEST_RELEASE} .tar.gz"
35+
36+ echo " 📦 Downloading ha-dyson version: $LATEST_RELEASE "
37+
38+ # Create temporary directory for download
39+ TEMP_DIR=$( mktemp -d)
40+ cd " $TEMP_DIR "
41+
42+ # Download and extract
43+ if curl -L " $DOWNLOAD_URL " -o dyson.tar.gz; then
44+ tar -xzf dyson.tar.gz
45+
46+ # Find the extracted directory (it will be ha-dyson-<version>)
47+ EXTRACTED_DIR=$( find . -maxdepth 1 -type d -name " ha-dyson-*" | head -1)
48+
49+ if [ -n " $EXTRACTED_DIR " ] && [ -d " $EXTRACTED_DIR /custom_components/dyson" ]; then
50+ echo " 📁 Installing dyson custom component to $DYSON_COMPONENT_DIR "
51+ rm -rf " $DYSON_COMPONENT_DIR "
52+ cp -r " $EXTRACTED_DIR /custom_components/dyson" " $DYSON_COMPONENT_DIR "
53+ echo " ✅ Dyson custom component installed successfully!"
54+
55+ # Cleanup
56+ cd " $PROJECT_ROOT "
57+ rm -rf " $TEMP_DIR "
58+
59+ echo " "
60+ echo " 🎉 Automatic installation complete!"
61+ else
62+ echo " ❌ Error: dyson custom component not found in downloaded archive"
63+ MANUAL_INSTALL=true
64+ fi
65+ else
66+ echo " ❌ Failed to download release archive"
67+ MANUAL_INSTALL=true
68+ fi
69+ fi
70+ else
71+ echo " ⚠️ Network access limited or GitHub API blocked - manual installation required"
72+ MANUAL_INSTALL=true
73+ fi
74+
75+ if [ " ${MANUAL_INSTALL:- false} " = " true" ]; then
76+ echo " "
77+ echo " 📋 Manual Installation Instructions"
78+ echo " =================================="
79+ echo " "
80+ echo " 1. Visit: https://github.com/libdyson-wg/ha-dyson/releases/latest"
81+ echo " 2. Download the latest release archive (Source code tar.gz)"
82+ echo " 3. Extract the archive"
83+ echo " 4. Copy the 'custom_components/dyson' directory to:"
84+ echo " $CUSTOM_COMPONENTS_DIR /"
85+ echo " "
86+ echo " Example commands:"
87+ echo " wget https://github.com/libdyson-wg/ha-dyson/archive/refs/tags/\$ VERSION.tar.gz"
88+ echo " tar -xzf \$ VERSION.tar.gz"
89+ echo " cp -r ha-dyson-\$ VERSION/custom_components/dyson $CUSTOM_COMPONENTS_DIR /"
90+ echo " "
91+ fi
92+
93+ echo " "
94+ echo " 📝 Next Steps"
95+ echo " ============"
96+ echo " "
97+ echo " 1. 🔧 Build and restart the Docker container:"
98+ echo " make build && make up"
99+ echo " "
100+ echo " 2. 🏠 Configure in Home Assistant:"
101+ echo " - Go to Settings > Devices & Services"
102+ echo " - Click 'Add Integration' and search for 'Dyson'"
103+ echo " - Follow the setup wizard"
104+ echo " "
105+ echo " 3. 🔐 Authentication Options:"
106+ echo " - Option A: Use your MyDyson account (email/password)"
107+ echo " - Option B: Use device Wi-Fi information from device sticker"
108+ echo " "
109+ echo " 4. 📖 For detailed setup instructions, see:"
110+ echo " docs/dyson-integration.md"
111+ echo " "
112+
113+ # Check if component is already installed
114+ if [ -d " $DYSON_COMPONENT_DIR " ]; then
115+ echo " ✅ Dyson custom component directory exists at: $DYSON_COMPONENT_DIR "
116+ if [ -f " $DYSON_COMPONENT_DIR /manifest.json" ]; then
117+ echo " ✅ Component manifest found - installation appears complete"
118+ else
119+ echo " ⚠️ Component directory exists but manifest.json not found"
120+ fi
121+ else
122+ echo " ❌ Dyson custom component not yet installed"
123+ fi
0 commit comments