File size: 2,203 Bytes
b7d2428
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<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 &lt;your-api-token&gt;</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>