File size: 12,415 Bytes
b304133 bf8ba08 b737689 7ecfd80 bf8ba08 b304133 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
---
license: apache-2.0
metrics:
- accuracy
tags:
- wifi
- attendence
- system
---
# WiFi Attendance Tracker - Employee Management Version
## Overview
The WiFi-Based Attendance & Break Tracker is an advanced employee time tracking system that monitors attendance by detecting MAC addresses of devices connected to the local WiFi network. This enhanced version includes comprehensive employee management features, password protection, and a modern web interface.
|#Model Working And Images



## Key Features
### π **Employee Management**
- **Add New Employees**: Password-protected employee addition with admin authentication
- **Search Functionality**: Search employees by name or MAC address
- **Employee Pictures**: Support for employee profile pictures
- **Password Protection**: Secure admin access with customizable passwords (default: 1122)
### β° **Advanced Time Tracking**
- **Time-In/Time-Out**: Automatic detection of first arrival and final departure
- **Break Monitoring**: Tracks when employees go on break and return
- **5:00 PM Auto-Timeout**: Employees automatically marked as timed out at office closing
- **Duration Calculations**: Precise tracking of total work time and break time
### π **Comprehensive Reporting**
- **Real-time Dashboard**: Live employee status updates every 10 seconds
- **Daily Attendance Sheets**: Detailed CSV reports with formatted durations
- **Event History**: Complete audit trail of all attendance events
- **Summary Statistics**: Daily overview with present/absent/break/timeout counts
### π **Modern Web Interface**
- **Responsive Design**: Works on desktop and mobile devices
- **Real-time Updates**: Live status changes and notifications
- **Interactive Dashboard**: Modern UI with statistics cards and employee cards
- **Modal Dialogs**: Professional forms for employee management
### π§ **System Features**
- **Non-Admin Operation**: Attempts to run without administrator privileges
- **Offline Operation**: Works completely without internet connection
- **Database Storage**: SQLite database for persistent data storage
- **JSON Configuration**: Separate employee data file for easy management
- **Integrated Application**: Single entry point for all functionality
## System Requirements
- **Operating System**: Windows 10/11, Linux, or macOS
- **Python**: 3.7 or higher
- **Network**: Local WiFi network access
- **Permissions**: Network scanning capabilities (admin/root recommended but not required)
## Installation
### Quick Setup (Windows)
1. **Extract the Project**
```
Extract wifi_attendance_tracker_advanced.zip to your desired location
```
2. **Run Setup Script**
```
Double-click setup.bat
```
3. **Configure Employees**
```
Edit employees.json with your employee data
```
4. **Start the Application**
```
Double-click run.bat or run: python main.py
```
### Manual Installation
1. **Install Python Dependencies**
```bash
pip install flask flask-cors bcrypt
```
2. **Configure System**
```bash
# Edit config.json for system settings
# Edit employees.json for employee data
```
3. **Run Application**
```bash
python main.py
```
## Configuration
### config.json
```json
{
"scan_interval_seconds": 60,
"web_port": 5000,
"office_timeout_hour": 17,
"office_timeout_minute": 0
}
```
### employees.json
```json
[
{
"name": "John Doe",
"mac_address": "aa-bb-cc-dd-ee-ff",
"picture": "static/img/john_doe.jpg"
},
{
"name": "Jane Smith",
"mac_address": "11-22-33-44-55-66",
"picture": "static/img/jane_smith.jpg"
}
]
```
## Usage
### Starting the Application
#### Web Interface Mode (Default)
```bash
python main.py
```
Access the web interface at: http://localhost:5000
#### Console Mode
```bash
python main.py --console
```
#### Custom Port
```bash
python main.py --port 8080
```
#### System Status
```bash
python main.py --status
```
### Web Interface Features
#### Dashboard Overview
- **System Status**: Current monitoring state and employee count
- **Statistics Cards**: Real-time counts of present, absent, on break, and timed out employees
- **Employee Status**: Live employee cards with status badges and time information
- **Recent Events**: Timeline of latest attendance events
#### Employee Management
1. **Adding Employees**:
- Click "Add Employee" button
- Fill in employee name and MAC address
- Optionally add picture path
- Enter admin password (default: 1122)
- Click "Add Employee"
2. **Searching Employees**:
- Use the search box to find employees by name or MAC address
- Results update in real-time
3. **Changing Admin Password**:
- Click "Settings" button
- Enter current password and new password
- Click "Change Password"
#### Monitoring Controls
- **Start Monitoring**: Begin attendance tracking
- **Stop Monitoring**: Pause attendance tracking
- **Refresh Data**: Manually update all data
- **Export CSV**: Download daily attendance summary
### Employee Pictures
To add employee pictures:
1. **Create Image Directory**:
```
Create: static/img/ directory
```
2. **Add Picture Files**:
```
Place images in: static/img/employee_name.jpg
```
3. **Update Configuration**:
```json
{
"name": "John Doe",
"mac_address": "aa-bb-cc-dd-ee-ff",
"picture": "static/img/john_doe.jpg"
}
```
## How It Works
### MAC Address Detection
The system uses the `arp -a` command to scan for devices on the local network. When an employee's device (identified by MAC address) is detected:
1. **First Detection**: Marked as "Time In"
2. **Continuous Presence**: Status remains "Present"
3. **Temporary Absence**: Marked as "On Break" if gone for short period
4. **Extended Absence**: Marked as "Time Out" if gone for extended period
5. **5:00 PM Timeout**: Automatically marked as "Timed Out" at office closing
### Status Logic
- **Present**: Device currently detected on network
- **Absent**: Device not detected and no previous activity today
- **On Break**: Device temporarily not detected but was present earlier
- **Timed Out**: Device not detected after 5:00 PM or extended absence
### Data Storage
- **SQLite Database**: Stores all attendance events and employee data
- **CSV Logs**: Daily attendance summaries exported to `logs/` directory
- **JSON Files**: Configuration and employee data in human-readable format
## Security Features
### Password Protection
- **Admin Authentication**: Required for adding new employees
- **Password Hashing**: Secure bcrypt hashing for stored passwords
- **Default Password**: 1122 (changeable through web interface)
- **Session Security**: No persistent login sessions for security
### Data Privacy
- **Local Storage**: All data stored locally, no cloud transmission
- **Offline Operation**: No internet connection required
- **Encrypted Passwords**: Admin passwords securely hashed
- **Access Control**: Employee management requires authentication
## Troubleshooting
### Common Issues
#### "Permission Denied" Errors
- **Windows**: Run Command Prompt as Administrator
- **Linux/macOS**: Use `sudo python main.py`
- **Alternative**: Use non-admin mode (limited network scanning)
#### No Employees Detected
1. Verify MAC addresses in `employees.json`
2. Check if devices are connected to same network
3. Ensure WiFi is enabled on employee devices
4. Run `python main.py --status` to check configuration
#### Web Interface Not Loading
1. Check if port 5000 is available
2. Try different port: `python main.py --port 8080`
3. Verify firewall settings
4. Check console for error messages
#### Database Errors
1. Delete `attendance.db` to reset database
2. Restart application to recreate tables
3. Check file permissions in project directory
### Network Scanning Limitations
#### Non-Admin Mode
When running without administrator privileges:
- Limited network scanning capabilities
- May not detect all devices
- Reduced accuracy in some network configurations
- Employee management features work normally
#### Admin Mode (Recommended)
- Full network scanning capabilities
- Accurate device detection
- Complete attendance tracking
- All features fully functional
## File Structure
```
wifi_attendance_tracker/
βββ main.py # Main application entry point
βββ attendance_tracker.py # Core attendance tracking logic
βββ database.py # Database operations
βββ auth.py # Authentication management
βββ web_interface.py # Flask web interface (legacy)
βββ config.json # System configuration
βββ employees.json # Employee data
βββ requirements.txt # Python dependencies
βββ setup.bat # Windows setup script
βββ run.bat # Windows run script
βββ templates/
β βββ index.html # Web interface template
βββ static/
β βββ css/
β β βββ style.css # Web interface styles
β βββ js/
β β βββ script.js # Web interface JavaScript
β βββ img/ # Employee pictures directory
βββ logs/ # CSV export directory
βββ attendance.db # SQLite database
```
## API Endpoints
The web interface provides REST API endpoints:
### System Status
- `GET /api/status` - Get system status
- `POST /api/start_monitoring` - Start monitoring
- `POST /api/stop_monitoring` - Stop monitoring
### Employee Management
- `GET /api/employees` - Get all employees
- `POST /api/add_employee` - Add new employee (requires password)
- `GET /api/search_employees?q=query` - Search employees
### Attendance Data
- `GET /api/attendance_events` - Get attendance events
- `GET /api/daily_summary?date=YYYY-MM-DD` - Get daily summary
- `GET /api/summary_stats?date=YYYY-MM-DD` - Get summary statistics
- `GET /api/export_csv?date=YYYY-MM-DD` - Export CSV
### Authentication
- `POST /api/change_password` - Change admin password
## Advanced Configuration
### Custom Office Hours
Edit `config.json`:
```json
{
"office_timeout_hour": 18,
"office_timeout_minute": 30
}
```
### Scan Interval
Adjust monitoring frequency:
```json
{
"scan_interval_seconds": 30
}
```
### Web Port
Change web interface port:
```json
{
"web_port": 8080
}
```
## Development
### Adding New Features
1. **Backend**: Modify `main.py` or create new modules
2. **Frontend**: Update `templates/index.html` and `static/` files
3. **Database**: Add new tables/columns in `database.py`
4. **API**: Add new endpoints in `main.py`
### Testing
```bash
# Test database functionality
python database.py
# Test authentication
python auth.py
# Test attendance tracking
python attendance_tracker.py
# Check system status
python main.py --status
```
## Support
### Getting Help
1. Check this README for common solutions
2. Run `python main.py --status` for system diagnostics
3. Check log files in `logs/` directory
4. Verify configuration files are properly formatted
### Reporting Issues
When reporting issues, include:
- Operating system and Python version
- Error messages from console
- Configuration files (remove sensitive data)
- Steps to reproduce the issue
## License
This project is provided as-is for educational and internal business use. Please ensure compliance with local privacy and employment laws when monitoring employee attendance.
## Version History
### Version 3.0 (Current)
- Employee management with password protection
- Enhanced web interface with modern design
- Non-admin operation support
- Employee pictures and search functionality
- Integrated single-file application
### Version 2.0
- Advanced time tracking with breaks
- 5:00 PM automatic timeout
- Daily attendance summaries
- Web interface with real-time updates
### Version 1.0
- Basic MAC address detection
- Simple console interface
- CSV logging
---
**WiFi Attendance Tracker - Employee Management Version**
*Advanced MAC Detection with Employee Management Features*
*Version 3.0 - 2025* |