- How does this package detect coffee machine usage?
- The package uses a Raspberry Pi running a Python script to listen for coffee machine sounds. When it detects brewing noises, it sends data to your Laravel app via HTTP requests or direct database writes. The tile then visualizes the stats on your dashboard.
- Do I need a Raspberry Pi to use this?
- Yes, this package requires a Raspberry Pi (or equivalent) with a microphone near your coffee machine. The Python script runs on the Pi to capture audio and trigger coffee counts. There’s no built-in fallback if the hardware fails.
- Which Laravel versions does this package support?
- The package is tested on Laravel 8 and 9 with PHP 8.0+. Older versions may require adjustments, as it relies on Laravel Dashboard (v1.0+), which also has version constraints. Always check the [Laravel Dashboard docs](https://docs.spatie.be/laravel-dashboard) for compatibility.
- Can I use this without spatie/laravel-dashboard?
- No, this package is designed as a tile for the Spatie Laravel Dashboard. You must install and configure `spatie/laravel-dashboard` first. It won’t work as a standalone solution or with other dashboard frameworks.
- How do I set up the Python script for audio detection?
- The Python script is a separate repository ([dashboard-coffee-listener](https://github.com/spatie/dashboard-coffee-listener)). You’ll need to install Python 3.x, clone the repo, and configure it to send data to your Laravel app’s API endpoint (e.g., `/api/coffee`). Follow the script’s README for setup instructions.
- What happens if the Raspberry Pi crashes or loses network connectivity?
- The dashboard will display stale data until the Pi or network recovers. There’s no built-in redundancy or retry logic for failed requests. For production, consider Dockerizing the Python script or adding a health check to auto-restart it.
- Can I customize the coffee detection logic (e.g., adjust sensitivity)?
- The audio detection logic is handled by the Python script, not the Laravel package. You’ll need to modify the script’s source code (e.g., `detect_coffee.py`) to tweak sensitivity or noise filtering. Changes won’t affect the Laravel tile itself.
- How do I add the coffee tile to my dashboard?
- After publishing migrations and setting up the Python script, add the tile to your dashboard view using the Livewire component: `<livewire:coffee-tile position="e7:e16" />`. The `position` attribute controls its placement, and `total-offset` lets you adjust the displayed total (e.g., for initial calibration).
- Is there a way to test the audio detection without a real coffee machine?
- Yes, you can simulate coffee sounds by playing audio files (e.g., recordings of your machine brewing) near the Pi’s microphone. The Python script includes a test mode—check its documentation for details. Alternatively, mock HTTP requests to the Laravel endpoint for development.
- What are the alternatives if I don’t want to use a Raspberry Pi?
- If hardware setup is prohibitive, consider manual input via a simple API endpoint (e.g., `/api/log-coffee`) or a mobile app for employees to log coffee consumption. Alternatively, use IoT sensors (e.g., ESP32 with a flow meter) for more reliable data collection, though these require custom integration.