Hey there! 👋 This is a fun little project I put together to display weather info on my Kindle. It's specifically built to work with Environment Canada's weather data (because their API is free and pretty decent!).
This is the server that I'm using for the Kindle Dashboard specified in this blog post: Reviving my Kindle PW7
👆 This is how it looks on my Kindle! (Rotated 90° for Kindle display)
This dashboard generates a clean, Kindle-friendly weather display that shows:
- Current temperature and conditions
- Feels like temperature
- Wind speed and humidity
- Air Quality Health Index (AQHI)
- Hourly forecast
- Daily forecast (day/night split)
- Battery level of your Kindle
- Weather alerts (when active)
Look, this is a pretty rough project that I hacked together for my own use. It works for me, but there might be bugs, and the code could definitely use some cleanup. That said, if you're in Canada and want to build your own Kindle weather display, this could be a good starting point!
- Backend: Node.js with TypeScript
- Web Framework: Express
- Image Processing:
- Playwright (for capturing the HTML dashboard)
- Sharp (for image processing and Kindle-friendly conversion)
- Weather Data: Environment Canada API (not sure if you're allowed to use it for this purpose, so use at your own risk)
- Icons: Lucide icons (for consistent, clean weather icons)
- Containerization: Docker & Docker Compose
- Responsive Design: The dashboard is built with CSS Grid and Flexbox
- Dynamic Sizing: Text automatically scales based on content length
- Kindle Optimization: Images are converted to B&W and rotated for Kindle display
- Icon Mapping: Includes a comprehensive mapping of Environment Canada weather codes to Lucide icons
- Battery Display: Shows your Kindle's battery level with appropriate icons
- Docker
- Docker Compose
- A thirst for weather data 🌤️
- Grab the code:
git clone [email protected]:terminalbytes/kindle-dashboard.git
cd kindle-dashboard
- Modify the location LAT/LONG in the
api-weather.ts
file. - Fire it up:
docker-compose up -d
This will:
- Build the Docker image
- Start the weather service
- Make it available on port 8080
To generate a new dashboard (and update battery level):
curl http://localhost:8080/battery/75 # Change 75 to your actual battery percentage
Your fresh dashboard will be available at:
http://localhost:8080/dash.png
There's a handy script (icon-codes.ts
) that helps map Environment Canada's weather icon codes to their conditions. It parses API responses to build a comprehensive mapping, which is super useful if you want to add new icon mappings or understand what each code means.
The main weather dashboard generation happens in api-weather.ts
. It:
- Fetches weather data from Environment Canada
- Maps their icon codes to Lucide icons
- Generates a responsive HTML dashboard
- Uses Playwright to capture it as an image
- Processes the image with Sharp to make it Kindle-friendly
If you want to hack on it locally:
docker build -t kindle-dashboard .
docker run -p 8080:8080 kindle-dashboard
- Default location is set to Medicine Hat, Alberta (modify
WEATHER_LOCATION
inapi-weather.ts
to change) - Images are saved in the
public
directory - Runs on port 8080 by default
- Dashboard dimensions are optimized for Kindle (1448x1072)
Found a bug? Want to add a feature? PRs are welcome! Just remember:
- Fork it
- Branch it
- Send it!
MIT License - Go wild! Just don't blame me if your Kindle shows the wrong weather 😉
Copyright (c) 2024 terminalbytes
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.