@@ -189,9 +189,163 @@ Comprehensive documentation is available on our [Documentation Site](https://dom
189189- [ User Scripts] ( https://domalab.github.io/ha-unraid/advanced/user-scripts/ )
190190- [ Contributing Guide] ( https://domalab.github.io/ha-unraid/development/contributing/ )
191191
192+ ## Development Environment
193+
194+ This project provides a complete development environment using Visual Studio Code Dev Containers, making it easy for contributors to get started with a fully configured Home Assistant development setup.
195+
196+ ### Prerequisites
197+
198+ Before setting up the development environment, ensure you have the following installed:
199+
200+ - ** Docker** : Required for running the development container
201+ - [ Install Docker Desktop] ( https://docs.docker.com/get-docker/ ) (Windows/Mac)
202+ - [ Install Docker Engine] ( https://docs.docker.com/engine/install/ ) (Linux)
203+ - ** Visual Studio Code** : The primary development environment
204+ - [ Download VS Code] ( https://code.visualstudio.com/ )
205+ - ** Dev Containers Extension** : Enables devcontainer support in VS Code
206+ - [ Install Dev Containers Extension] ( https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers )
207+
208+ ### Devcontainer Setup
209+
210+ The project includes a pre-configured development container that provides:
211+ - Python 3.13 environment
212+ - Home Assistant with debugging capabilities
213+ - Pre-installed development dependencies (ruff, colorlog, asyncssh)
214+ - VS Code extensions for Python development, linting, and GitHub integration
215+ - Automatic port forwarding for Home Assistant (port 8123)
216+
217+ #### Getting Started
218+
219+ 1 . ** Clone the repository** :
220+ ``` bash
221+ git clone https://github.com/domalab/ha-unraid.git
222+ cd ha-unraid
223+ ```
224+
225+ 2 . ** Open in VS Code** :
226+ ``` bash
227+ code .
228+ ```
229+
230+ 3 . ** Open in Dev Container** :
231+ - When VS Code opens, you should see a notification to "Reopen in Container"
232+ - Alternatively, press ` Ctrl+Shift+P ` (or ` Cmd+Shift+P ` on Mac) and select "Dev Containers: Reopen in Container"
233+ - Or click the green button in the bottom-left corner and select "Reopen in Container"
234+
235+ 4 . ** Wait for container setup** :
236+ - The container will build and install dependencies automatically
237+ - The ` scripts/setup ` command runs automatically to install Python requirements
238+
239+ ### Development Workflow
240+
241+ #### Starting Home Assistant for Testing
242+
243+ The development environment includes a dedicated script to run Home Assistant with the integration loaded:
244+
245+ ``` bash
246+ scripts/develop
247+ ```
248+
249+ This command:
250+ - Creates a ` config ` directory if it doesn't exist
251+ - Initializes Home Assistant configuration
252+ - Sets up the Python path to include the custom components
253+ - Starts Home Assistant in debug mode with the integration loaded
254+ - Makes Home Assistant available at ` http://localhost:8123 `
255+
256+ #### Code Formatting and Linting
257+
258+ The project uses Ruff for code formatting and linting:
259+
260+ ``` bash
261+ scripts/lint
262+ ```
263+
264+ This command:
265+ - Formats code according to project standards
266+ - Fixes linting issues automatically where possible
267+ - Should be run before committing changes
268+
269+ #### Testing the Integration
270+
271+ 1 . ** Start the development environment** :
272+ ``` bash
273+ scripts/develop
274+ ```
275+
276+ 2 . ** Access Home Assistant** :
277+ - Open your browser to ` http://localhost:8123 `
278+ - Complete the initial Home Assistant setup if prompted
279+
280+ 3 . ** Add the Unraid integration** :
281+ - Go to Settings → Devices & Services
282+ - Click "Add Integration"
283+ - Search for "Unraid" and configure with your Unraid server details
284+
285+ 4 . ** Debug and develop** :
286+ - The integration runs with debug logging enabled
287+ - Check the Home Assistant logs for detailed information
288+ - Make changes to the code and restart Home Assistant to test
289+
290+ ### Configuration and Files
291+
292+ #### Key Development Files
293+
294+ - ** ` .devcontainer.json ` ** : Defines the development container configuration
295+ - ** ` config/configuration.yaml ` ** : Home Assistant configuration for development
296+ - ** ` scripts/setup ` ** : Installs Python dependencies
297+ - ** ` scripts/develop ` ** : Starts Home Assistant in development mode
298+ - ** ` scripts/lint ` ** : Formats and lints the code
299+ - ** ` requirements.txt ` ** : Python dependencies for development
300+
301+ #### Development Configuration
302+
303+ The development Home Assistant instance is configured with:
304+ - Debug mode enabled
305+ - Debug logging for the Unraid integration
306+ - Default Home Assistant integrations loaded
307+ - Custom components path set to include this project
308+
309+ ### Additional Developer Resources
310+
311+ #### Available Commands
312+
313+ - ** Setup environment** : ` scripts/setup `
314+ - ** Start development server** : ` scripts/develop `
315+ - ** Format and lint code** : ` scripts/lint `
316+
317+ #### Development Tips
318+
319+ - ** Hot reload** : Restart Home Assistant to see code changes
320+ - ** Debugging** : Use VS Code's integrated debugger with the Python extension
321+ - ** Logging** : Check Home Assistant logs for integration-specific debug information
322+ - ** Testing** : Test with a real Unraid server or mock the SSH connections for unit testing
323+
324+ #### VS Code Extensions Included
325+
326+ The devcontainer automatically installs these helpful extensions:
327+ - ** Ruff** : Python linting and formatting
328+ - ** Python & Pylance** : Python language support and IntelliSense
329+ - ** GitHub Pull Requests** : GitHub integration for pull requests
330+ - ** Coverage Gutters** : Code coverage visualization
331+
332+ #### Port Forwarding
333+
334+ The development container automatically forwards:
335+ - ** Port 8123** : Home Assistant web interface
336+
192337## Contributing
193338
194- Contributions to this integration are welcome. Please fork the repository and submit a pull request with your changes. Make sure to follow the contribution guidelines. See our [ Contributing Guide] ( https://domalab.github.io/ha-unraid/development/contributing/ ) for more details.
339+ Contributions to this integration are welcome. Please fork the repository and submit a pull request with your changes. Make sure to follow the contribution guidelines and use the development environment described above. See our [ Contributing Guide] ( https://domalab.github.io/ha-unraid/development/contributing/ ) for more details.
340+
341+ ### Development Workflow for Contributors
342+
343+ 1 . Set up the development environment using the instructions above
344+ 2 . Create a new branch for your feature or bug fix
345+ 3 . Make your changes and test them using ` scripts/develop `
346+ 4 . Run ` scripts/lint ` to ensure code quality
347+ 5 . Test your changes thoroughly with a real Unraid server
348+ 6 . Submit a pull request with a clear description of your changes
195349
196350## License
197351
0 commit comments