@@ -63,13 +63,17 @@ GET /api/devices/scan # Scan network for devices
6363GET /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
6969POST /api/devices/{ip}/reboot # Reboot device
7070
7171POST /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
8387PUT /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
0 commit comments