A boilerplate template for creating TRMNL e-ink display plugins.
- Flask-based webhook endpoint with CORS support
- E-ink display optimization
- Built-in caching system
- Comprehensive error handling
- Structured logging
- Environment-based configuration management
- Display generator service with error display support
- API service template with caching
- Extensive utility functions for formatting and validation
- Python 3.12+
- TRMNL device and API key
- Docker (optional)
- Clone the repository:
git clone https://github.com/yourusername/your-plugin.git
cd your-plugin
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Create .env file:
cp .env.template .env
- Update .env with your configuration:
TRMNL_API_KEY=your_api_key_here
TRMNL_PLUGIN_UUID=your_plugin_uuid_here
python -m src.app
The development server will automatically open your default browser to the webhook endpoint. You can access:
- Home page: http://localhost:8080/
- Webhook endpoint: http://localhost:8080/webhook
├── .env.template # Environment variables template
├── .gitignore # Git ignore rules
├── README.md # Project documentation
├── render.yaml # Render deployment configuration
├── requirements.txt # Python dependencies
├── src/ # Source code directory
│ ├── app.py # Main application entry point
│ ├── config.py # Configuration management
│ ├── services/ # Core services
│ │ ├── api_service.py # API interaction service
│ │ └── display.py # Display generation service
│ └── utils/ # Utility functions
│ ├── __init__.py # Package exports
│ ├── formatters.py # Data formatting utilities
│ └── validators.py # Data validation utilities
└── tests/ # Test files
└── test_display.py # Display service tests
-
API Service (
src/services/api_service.py
)- Handles all API interactions
- Implements caching mechanism
- Tracks last update timestamp
-
Display Generator (
src/services/display.py
)- Creates optimized images for e-ink display
- Handles error displays
- Supports status bar and content layout
-
Utility Functions
formatters.py
: Date/time formatting, API response formattingvalidators.py
: Data validation, string sanitization- Common utilities exported through
__init__.py
-
Configuration (
src/config.py
)- Environment-based configuration
- Validation for required settings
- Default values for optional settings
- Modify
src/services/api_service.py
to implement your data fetching logic - Update
src/services/display.py
to customize the display layout - Add any additional utilities in
src/utils/
- Update configuration in
src/config.py
as needed
Run the test suite:
python -m pytest tests/
Current test coverage includes:
- Display generator initialization
- Error display generation
- API service functionality
- Display creation with mock data
Deploy using render.yaml configuration:
render deploy
The render.yaml file includes:
- Python 3.12.0 runtime
- Gunicorn web server
- Environment variable configuration
- Build and start commands
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT