This is a custom integration for Home Assistant that allows you to monitor Minecraft servers managed by Crafty Controller. It provides sensors for tracking general server status, CPU usage, memory usage, and other metrics.
This was last verified working against Home Assistant 2024.5.2 and Crafty Controller 4.3.2
- General Status: Monitor server uptime status (running or stopped).
- CPU Usage: Track server CPU usage in percentage.
- Memory Usage: Track server memory usage in gigabytes.
- Additional Attributes: View player count, server ports, and more.
-
Download the Custom Component:
- Clone this repository or download it as a zip file.
-
Copy to
custom_components
:- Copy the
crafty_controller
folder into your Home Assistantcustom_components
directory. This is located in the config folder. Create it if it's not present.
- Copy the
-
Update
configuration.yaml
:- Add the following configuration to your
configuration.yaml
file:
sensor: - platform: crafty_controller crafty_base_url: "https://your-crafty-server-url:8443" api_token: "YOUR_API_TOKEN" verify_ssl: true # or false to disable SSL verification
- Add the following configuration to your
-
Restart Home Assistant:
- Restart your Home Assistant instance to load the custom component.
To set up a development environment, follow these steps:
-
Create a Virtual Environment:
- Create a virtual environment for Home Assistant:
python3 -m venv venv
-
Activate the Virtual Environment:
- On Windows:
venv\Scripts\activate
- On Linux/macOS:
source venv/bin/activate
-
Install Dependencies:
- Install
homeassistant-stubs
and other development dependencies:
pip install -r dev-requirements.txt
- Install
-
Linting and Typing:
- Optionally, use linting tools like
flake8
and type-checkers likemypy
for code quality:
flake8 crafty_controller mypy crafty_controller
- Optionally, use linting tools like
-
Run Home Assistant in Development Mode:
- Start Home Assistant with the
--debug
flag:
hass --debug
- Start Home Assistant with the
After installation and configuration, the integration will automatically create the following sensors:
- General Status Sensor: Reports whether the server is running or stopped.
- CPU Usage Sensor: Shows server CPU usage as a percentage.
- Memory Usage Sensor: Displays memory usage in gigabytes.
These sensors can be used in Home Assistant automations, dashboards, and scripts.
- Ensure that the Crafty Controller API is accessible and that the provided API token has sufficient permissions.
- Check the Home Assistant logs for error messages related to
crafty_controller
.
It's worth noting that Python is not a language I have a lot of experience with. This can probably be written a lot better and cleaner. Contributions are welcome! Feel free to open issues or submit pull requests to improve the integration.
This project was built with assistance from various tools, including AI-based suggestions. All code was carefully reviewed and customized to meet the project's specific needs.
This project is licensed under the MIT License.