A full-stack application for monitoring and controlling Tuya-based smart cat devices locally. Built with Elysia (backend) and React (frontend), it provides comprehensive device management for smart feeders, fountains, and automatic litter boxes.
- Dashboard: Real-time overview of all connected devices
- Device Control: Intuitive controls for each device type
- Meal Planning: Visual meal schedule management for feeders
- Multi-language: Support for English and French (i18n)
- Responsive Design: Works on desktop and mobile
- Device Status: Real-time status monitoring for all connected devices
- Connection Management: Connect/disconnect all devices or individual devices
- Device Types: Support for feeders, fountains and litter boxes with type-specific endpoints
- Meal Plan Management: Create, read, and update feeding schedules with Base64 encoding/decoding and caching
- Manual Feeding: Trigger immediate feeding sessions with customizable portions
- Feeder status: Retrieve detailed feeding logs with parsed timestamps and portion tracking
- Multi-Feeder Support: Manage multiple feeders independently
- Comprehensive Status: Monitor litter level, cleaning cycles, sensor data, and system state
- Smart Controls: Trigger cleaning cycles, configure sleep modes, and adjust settings
- Sensor Analytics: Track defecation frequency, duration, and maintenance alerts
- Preference Management: Control lighting, sounds, child lock, and kitten mode
- Real-time Monitoring: Track water level, filter life, pump runtime, and UV operation
- Light Control: Turn the fountain light on/off remotely
- Maintenance Resets: Reset water time, filter life, and pump runtime counters
- UV Management: Control UV sterilization light and set runtime schedules
- Eco Mode: Switch between energy-saving modes for optimal efficiency
- Alert System: Monitor low water and no water warnings
- Multi-Fountain Support: Manage multiple fountains independently
- DPS Scanning: Discover available device data points with configurable ranges and timeouts
- Real-time Monitoring: Live device data updates and event tracking
- Device Analytics: Comprehensive device information and capability discovery
- Bun (latest version)
- Docker & Docker Compose (for production deployment)
- One or more Tuya-compatible smart cat devices (feeders, fountains, litter boxes)
- Device credentials (ID, Key, IP) for each device
-
Getting Device Credentials
To retrieve device credentials, you need a Tuya Cloud account (free):
- Create an account at https://iot.tuya.com
- Create a project and select the correct datacenter
- Add your devices (easiest way: scan QR code with Smart Life app)
- Use API Explorer > Device Management > Query device details
- Get the device ID from the devices list and retrieve the local key
Note: The local key changes when the device is reset or removed from Smart Life.
-
Clone the repository
git clone https://github.com/uplg/cat-monitor.git cd cat-monitor -
Install dependencies
# Install backend dependencies bun install # Install frontend dependencies cd frontend && bun install && cd ..
-
Device Configuration
Create a
devices.jsonfile in the root directory with your device configurations:[ { "name": "Pixi Smart Feeder", "id": "your_feeder_device_id", "key": "your_feeder_device_key", "category": "cwwsq", "product_name": "Pixi Smart Feeder", "ip": "192.168.1.174", "version": "3.4" }, { "name": "Cat Litter Box", "id": "your_litter_device_id", "key": "your_litter_device_key", "category": "msp", "product_name": "Cat Litter Box", "ip": "192.168.1.145", "version": "3.5" }, { "name": "Pixi Smart Fountain", "id": "your_fountain_device_id", "key": "your_fountain_device_key", "category": "cwysj", "product_name": "Pixi Smart Fountain", "ip": "192.168.1.44", "version": "3.3" } ]Device Configuration Fields:
name: Friendly name for your deviceid: Tuya device IDkey: Tuya device local keycategory: Device category (cwwsq for feeders, msp for litter boxes)product_name: Product name from Tuyaip: Local IP address of the deviceversion: Tuya protocol version (usually 3.4 or 3.5)
-
Environment Setup
cp .env.example .env
Configure your
.envfile:# API Server port PORT=3000 # JWT Secret for authentication (generate a secure random string using `openssl rand -hex 16`) JWT_SECRET=your-super-secret-jwt-key-change-me
-
Start the development server
# Start both backend and frontend in development mode bun run devOr start them separately:
# Backend only (port 3000) bun run dev:backend # Frontend only (port 5173) bun run dev:frontend
- Backend API:
http://localhost:3000 - Frontend:
http://localhost:5173 - OpenAPI Docs:
http://localhost:3000/openapi
- Backend API:
The recommended way to deploy Cat Monitor in production is using Docker Compose.
# Build and start all services
docker-compose up -d --build
# View logs
docker-compose logs -f
# Stop all services
docker-compose downThe application will be available at http://localhost (port 80).
If no users.json defined (rename/modify users.json.template), user: admin, password: admin will be used.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Docker Network β
β β
β ββββββββββββββββ ββββββββββββββββββββββββ β
β β Frontend β /api β Backend β β
β β (nginx) β βββββββΆ β (Elysia) β β
β β :80 β β :3000 β β
β ββββββββββββββββ ββββββββββββββββββββββββ β
β β β β
ββββββββββββΌβββββββββββββββββββββββββββββΌββββββββββββββββββ
β β
βΌ βΌ
Web Browser Tuya IoT Devices
| Service | Description | Port |
|---|---|---|
frontend |
React app served via nginx | 80 |
backend |
Elysia API server (internal network) | 3000 |
The docker-compose.yml mounts configuration files from the host:
devices.json- Device configurationsdevice-cache.json- Cached DPS (some devices only report changes but don't expose DPS directly, so we need to cache on data event/update)users.json- Users "DB".env- Environment variables
If you only need the API server:
docker build -t cat-monitor-api .
docker run -p 3000:3000 \
-v $(pwd)/devices.json:/app/devices.json \
-v $(pwd)/device-cache.json:/app/device-cache.json \
-v $(pwd)/users.json:/app/users.json \
--env-file .env \
cat-monitor-apiInteractive API documentation is available at http://localhost:3000/openapi
-
Device Connection Failed
- Verify device IP address and network connectivity
- Check if device is powered on and connected to WiFi
- Retry the request, Tuya devices don't support multi devices connected at the same time (it might be your phone as an example), else it's probably a wrong protocol version (3.3 instead of 3.4 as an example)
-
ECONNRESET
- Double-check
idandkeyin device.json - Verify device version (usually 3.3, 3.4 or 3.5 for recent tuya devices)
- Double-check
-
Meal Plan Not Reading
- The device may not have a meal plan retrieved yet, DPS don't expose the raw data so we need to update (and then it's saved on instance)
- Try setting a meal plan first using the POST endpoint
-
DPS Scan Taking Too Long
- Use smaller ranges:
?start=1&end=50instead of full scan - Reduce timeout:
?timeout=1000for faster scanning - Target known DPS ranges for your device type
- Use smaller ranges:
The API includes comprehensive logging. Check the console output for:
- Device connection status
- DPS scan results
- Meal plan encoding/decoding details
- Real-time event reports
| Layer | Technology |
| -------- | --------------------------------------- |
| Backend | Elysia, Bun, TuyAPI |
| Frontend | React 19, Vite, TailwindCSS, TypeScript |
| UI | Radix UI, Lucide Icons |
| State | TanStack Query (React Query) |
| i18n | i18next |
| Routing | React Router v7 |
| Deploy | Docker, nginx |
- Framework: Elysia (fast and ergonomic framework leveraging Bun)
- Device Communication: TuyAPI for Tuya device protocol
- Meal Plan Encoding: Custom Base64 binary format
- Real-time: Event-driven architecture with persistent connections
- Authentication: JWT-based auth with protected routes
MIT License - see LICENSE file for details
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For issues and questions:
- Check the troubleshooting section
- Leave an issue (try to add as much details as possible)
The frontend supports multiple languages:
- π¬π§ English (default)
- π«π· FranΓ§ais
Language is auto-detected from browser settings, or can be changed manually in the UI.
To add a new language, create a new JSON file in frontend/src/i18n/locales/ and register it in frontend/src/i18n/index.ts.
- TuyAPI for the device communication library
- Tinytuya for the wizard, helped a lot debugging version and discovering device capabilities
Happy monitoring! π±π½οΈπ§π½