Spaces:
Sleeping
Sleeping
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>SmartHome Hub Pro β Developer API Reference</title> | |
| </head> | |
| <body> | |
| <nav>Navigation menu (ignored by parser)</nav> | |
| <h1>SmartHome Hub Pro β Local API Reference</h1> | |
| <p>The Hub exposes a REST API on port <strong>8080</strong> for local LAN control. | |
| All endpoints require an API token obtained from the app (Settings β Developer β API Token).</p> | |
| <h2>Authentication</h2> | |
| <p>Include the token in the <code>Authorization</code> header:</p> | |
| <p><code>Authorization: Bearer <your-api-token></code></p> | |
| <h2>Endpoints</h2> | |
| <h3>GET /api/v1/devices</h3> | |
| <p>Returns a list of all paired devices and their current state.</p> | |
| <p><strong>Response example:</strong></p> | |
| <p><code>{ "devices": [{ "id": "d001", "name": "Living Room Light", "type": "light", "state": "on", "brightness": 80 }] }</code></p> | |
| <h3>POST /api/v1/devices/{id}/control</h3> | |
| <p>Send a command to a specific device.</p> | |
| <p><strong>Body parameters:</strong></p> | |
| <table> | |
| <tr><th>Parameter</th><th>Type</th><th>Description</th></tr> | |
| <tr><td>command</td><td>string</td><td>on, off, toggle, set_brightness, set_color</td></tr> | |
| <tr><td>value</td><td>any</td><td>For set_brightness: 0-100. For set_color: hex string.</td></tr> | |
| </table> | |
| <h3>GET /api/v1/hub/status</h3> | |
| <p>Returns Hub firmware version, uptime, and connected device count.</p> | |
| <h3>POST /api/v1/hub/reboot</h3> | |
| <p>Reboots the Hub. Requires admin token. The Hub will be unavailable for ~30 seconds.</p> | |
| <h2>Webhooks</h2> | |
| <p>Configure webhooks in Settings β Developer β Webhooks. | |
| The Hub will POST a JSON payload to your URL whenever a device state changes.</p> | |
| <p>Payload format:</p> | |
| <p><code>{ "event": "device_state_changed", "device_id": "d001", "state": "off", "timestamp": 1712345678 }</code></p> | |
| <h2>Rate Limits</h2> | |
| <p>Local API: 60 requests per minute per token. Exceeding this returns HTTP 429.</p> | |
| <p>Cloud API: 1000 requests per day per account.</p> | |
| <footer>Β© 2024 SmartHome Pro Inc. β All rights reserved.</footer> | |
| </body> | |
| </html> | |