Skip to content

Commit 8655df2

Browse files
committed
Update documentation
1 parent 179270e commit 8655df2

4 files changed

Lines changed: 100 additions & 4 deletions

File tree

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Manage Shelly devices on your local network without connecting them to the Shell
1717
- Device configuration changes
1818
- Bulk operations across multiple devices
1919
- Status monitoring
20+
- Component action discovery and execution
21+
- Dynamic device capability detection
22+
- Component-specific controls (switches, covers, lights, etc.)
2023

2124
Available as:
2225

@@ -133,13 +136,17 @@ GET /api/health # Service health check
133136
GET /api/devices/scan # Discover devices on network
134137
GET /api/devices/{ip}/status # Get device status
135138

136-
# Device operations
139+
# Device operations
137140
POST /api/devices/{ip}/update # Update device firmware
138141
POST /api/devices/{ip}/reboot # Reboot device
139142
POST /api/devices/bulk/update # Bulk firmware updates
140143

144+
# Component Actions
145+
GET /api/devices/{ip}/components/actions # Discover available actions
146+
POST /api/devices/{ip}/components/{id}/action # Execute component action
147+
141148
# Configuration management
142-
GET /api/devices/{ip}/config # Get device configuration
149+
GET /api/devices/{ip}/config # Get device configuration
143150
POST /api/devices/{ip}/config # Update device configuration
144151
```
145152

packages/api/README.md

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,17 @@ GET /api/devices/scan # Scan network for devices
6363
GET /api/devices/{ip}/status # Get device status
6464
?include_updates=true # Include update information
6565

66-
POST /api/devices/{ip}/update # Update device firmware
66+
POST /api/devices/{ip}/update # Update device firmware
6767
?channel=stable # Update channel (stable/beta)
6868

6969
POST /api/devices/{ip}/reboot # Reboot device
7070

7171
POST /api/devices/bulk/update # Bulk firmware updates
7272
# Body: {"device_ips": ["192.168.1.100", "192.168.1.101"], "channel": "stable"}
73+
74+
# Component Actions
75+
GET /api/devices/{ip}/components/actions # Discover available actions
76+
POST /api/devices/{ip}/components/{id}/action # Execute component action
7377
```
7478

7579
### Configuration Management
@@ -83,6 +87,21 @@ GET /api/config # Get global configuration
8387
PUT /api/config # Update global configuration
8488
```
8589

90+
### Component Actions
91+
92+
The Component Actions system provides dynamic action discovery and execution for individual device components.
93+
94+
#### Discovery
95+
```bash
96+
GET /api/devices/{ip}/components/actions # Get all available actions for device
97+
```
98+
99+
100+
#### Execute Component Action
101+
```bash
102+
POST /api/devices/{ip}/components/{component_id}/action
103+
```
104+
86105
### Monitoring (Future)
87106

88107
```bash
@@ -131,6 +150,73 @@ curl -X POST "http://localhost:8000/api/devices/192.168.1.100/update?channel=sta
131150
}
132151
```
133152

153+
### Component Actions Examples
154+
155+
#### Discover Device Actions
156+
```bash
157+
curl "http://localhost:8000/api/devices/192.168.1.100/components/actions"
158+
```
159+
160+
**Response Example:**
161+
```json
162+
{
163+
"device_ip": "192.168.1.100",
164+
"components": [
165+
{
166+
"component_id": "switch:0",
167+
"component_type": "switch",
168+
"available_actions": [
169+
{
170+
"action": "toggle",
171+
"description": "Toggle switch state",
172+
"parameters": {}
173+
},
174+
{
175+
"action": "turn_on",
176+
"description": "Turn switch on",
177+
"parameters": {}
178+
}
179+
]
180+
}
181+
]
182+
}
183+
```
184+
185+
#### Toggle a Switch
186+
```bash
187+
curl -X POST "http://localhost:8000/api/devices/192.168.1.100/components/switch:0/action" \
188+
-H "Content-Type: application/json" \
189+
-d '{"action": "toggle", "params": {}}'
190+
```
191+
192+
**Request Body:**
193+
```json
194+
{
195+
"action": "toggle",
196+
"params": {}
197+
}
198+
```
199+
200+
**Response:**
201+
```json
202+
{
203+
"ip": "192.168.1.100",
204+
"component_id": "switch:0",
205+
"action": "toggle",
206+
"success": true,
207+
"result": {
208+
"new_state": "on"
209+
}
210+
}
211+
```
212+
213+
#### Open a Cover
214+
```bash
215+
curl -X POST "http://localhost:8000/api/devices/192.168.1.100/components/cover:0/action" \
216+
-H "Content-Type: application/json" \
217+
-d '{"action": "open", "params": {}}'
218+
```
219+
134220
### Error Response
135221

136222
```json

packages/cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ uv run --package shelly-manager-cli pytest packages/cli/tests/unit/use_cases/ -v
376376
uv run --package shelly-manager-cli pytest packages/cli/tests/ --cov=cli --cov-report=html
377377
```
378378

379-
Detailed testing documentation: [tests/README.md](tests/README.md)
379+
**Testing Documentation**: Tests are located in `packages/cli/tests/` with unit tests for commands and use cases.
380380

381381
## Architecture
382382

packages/core/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Contains the core business logic that defines how Shelly Manager works. Framewor
1111
- Domain models for Shelly devices and operations
1212
- Business rules for device management
1313
- Use cases that orchestrate operations (scan, update, reboot)
14+
- Component action discovery and execution use cases
1415
- Gateway contracts for external dependencies
1516
- No dependencies on frameworks, databases, or UI
1617

@@ -29,6 +30,8 @@ packages/core/src/core/
2930
│ ├── scan_devices.py # Device discovery
3031
│ ├── update_device_firmware.py
3132
│ ├── reboot_device.py
33+
│ ├── execute_component_action.py # Component action execution
34+
│ ├── get_component_actions.py # Component action discovery
3235
│ └── ...
3336
├── gateways/ # External interfaces (abstract)
3437
│ ├── device/ # Device communication contracts

0 commit comments

Comments
 (0)