Skip to content

Commit 9083f19

Browse files
committed
agent file
1 parent b990659 commit 9083f19

1 file changed

Lines changed: 112 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a Docker-based Amazon Dash Button hack that sniffs network traffic to detect Amazon Dash button presses and triggers various actions like writing to Google Sheets, Google Calendar, or firing IFTTT events. The project is primarily written in Python 3.12+ and uses Scapy for network packet inspection.
8+
9+
## Development Commands
10+
11+
### Environment Setup
12+
```bash
13+
# Set up or activate development environment
14+
. ./activate.sh
15+
16+
# Install/upgrade dependencies
17+
make reqs
18+
```
19+
20+
### Testing and Quality
21+
```bash
22+
# Run tests with doctests
23+
pytest
24+
25+
# Run network sniff check (requires sudo)
26+
make check
27+
28+
# Type checking (via pre-commit hook)
29+
mypy src/
30+
31+
# Linting (via pre-commit hook)
32+
ruff check src/
33+
ruff format src/
34+
```
35+
36+
### Development Workflow
37+
```bash
38+
# Build documentation
39+
make docs
40+
41+
# Version management
42+
make ver-bug # Bump bug version
43+
make ver-feature # Bump feature version
44+
make ver-release # Bump release version
45+
46+
# View all available make commands
47+
make help
48+
```
49+
50+
### Running the Application
51+
```bash
52+
# For development on macOS/Windows (cannot sniff in Docker)
53+
sudo python src/amazon_dash.py
54+
55+
# For production (Linux with Docker)
56+
docker run --net host -it --rm -v $PWD/../amazon-dash-private:/amazon-dash-private:ro andgineer/amazon-dash-button-hack
57+
```
58+
59+
## Code Architecture
60+
61+
### Core Components
62+
63+
**Main Application (`src/amazon_dash.py`)**
64+
- `AmazonDash` class: Main server that sniffs ARP traffic to detect button presses
65+
- Uses Scapy for network packet inspection
66+
- Implements debounce logic to prevent duplicate button press detection
67+
- Loads configuration from JSON files in `amazon-dash-private/` directory
68+
69+
**Configuration Models (`src/models.py`)**
70+
- Pydantic models for type-safe configuration
71+
- Defines button actions, settings, time summaries, and dashboard items
72+
- Uses Python 3.10+ `collections.abc` for type hints
73+
74+
**Action Processing (`src/action.py`)**
75+
- `Action` class: Processes button press events and executes configured actions
76+
- Coordinates between different service integrations (Google, IFTTT, OpenHab)
77+
- Handles time-based action summaries and conditional logic
78+
79+
### Service Integrations
80+
81+
The project supports multiple external service integrations:
82+
- **Google Services** (`google_api.py`, `google_sheet.py`, `google_calendar.py`): Google Sheets and Calendar integration
83+
- **IFTTT** (`ifttt.py`): Webhook-based automation
84+
- **OpenHab** (`openhab.py`): Home automation system integration
85+
86+
### Configuration Structure
87+
88+
Required configuration files in `amazon-dash-private/`:
89+
- `settings.json`: Main application settings
90+
- `buttons.json`: Button MAC addresses and action mappings
91+
- `amazon-dash-hack.json`: Google API credentials
92+
- `ifttt-key.json`: IFTTT webhook key
93+
- `openweathermap-key.json`: Weather API key (optional)
94+
95+
### Code Quality Standards
96+
97+
- **Line length**: 100 characters (99 for tests)
98+
- **Type checking**: MyPy enabled for src/ (excluded for tests/)
99+
- **Linting**: Ruff with extensive rule set including Pylint, security checks, import ordering
100+
- **Formatting**: Ruff formatter
101+
- **Pre-commit hooks**: Automated code quality checks
102+
- **Testing**: Pytest with doctests enabled
103+
104+
### Key Dependencies
105+
106+
- `scapy`: Network packet inspection
107+
- `pydantic`: Configuration validation and type safety
108+
- `google-api-python-client`: Google services integration
109+
- `requests`: HTTP client for webhooks
110+
- `python-dateutil`: Date/time handling
111+
112+
The application requires `sudo` privileges for network sniffing and works best on Linux systems where Docker can access host networking directly.

0 commit comments

Comments
 (0)