Skip to content

Commit 528b50d

Browse files
committed
docs: comprehensive API reference and cleanup
- Socket API: Document all 7 commands with request/response examples - list_devices, get_instantaneous_demand, get_device_data - get_network_info, get_history_data, plus unsupported commands - Add field-by-field explanations and unit conversion formulas - HTTP API: Expand documentation with complete endpoint details - Authentication (HTTP Basic Auth) with curl examples - Document get_usage_data, get_device_list, get_instantaneous_demand - Include request/response examples in XML and JSON - Clients API: Add comprehensive usage guide - Full Python examples for both Socket and HTTP clients - Comparison table: Socket vs HTTP (protocol, auth, speed, features) - Clear recommendations for when to use each approach - Data Models: Complete reference with all fields documented - Document all 6 models: DeviceInfo, DeviceList, InstantaneousDemand - CurrentSummation, UsageData, NetworkInfo - Include JSON response examples and usage patterns - Explain computed properties and unit conversions - Remove embedded agent reasoning from socket_api.md - Clean up parenthetical authentication discussion - Professional reference manual format throughout Expands documentation from ~130 lines to 838 lines with 35+ code examples.
1 parent 3182226 commit 528b50d

4 files changed

Lines changed: 704 additions & 52 deletions

File tree

docs/api/clients.md

Lines changed: 104 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
# Clients API
22

3-
The `meter_reader` library provides two client implementations for the Eagle Gateway.
3+
The `meter_reader` library provides two client implementations for the EAGLE Gateway, each suited to different deployment scenarios and authentication requirements.
44

5-
## Base Client
5+
## Overview
6+
7+
Both clients inherit from the abstract `EagleClient` base class, which defines the common interface for interacting with the gateway. Choose based on your gateway's network configuration and authentication setup:
8+
9+
* **Socket API**: Fast, low-overhead XML-based communication (Port 5002)
10+
* **HTTP API**: Standard HTTP with JSON responses and authentication support (Port 80)
11+
12+
## Base Client Interface
613

714
::: meter_reader.clients.base.EagleClient
815
handler: python
@@ -14,9 +21,46 @@ The `meter_reader` library provides two client implementations for the Eagle Gat
1421
- get_network_info
1522
- get_current_summation
1623

24+
All implementations must provide these methods, ensuring consistent behavior across protocols.
25+
1726
## Socket Client
1827

19-
The `EagleSocketClient` communicates via the local XML API on port 5002. This is the traditional method for most integrations.
28+
The `EagleSocketClient` communicates via the raw TCP socket API on port 5002. This is the fastest and lowest-latency option, making it ideal for real-time monitoring and historical data queries.
29+
30+
### Usage Example
31+
32+
```python
33+
from meter_reader import EagleSocketClient
34+
35+
# Connect to the gateway
36+
client = EagleSocketClient("192.168.1.100")
37+
38+
# Get real-time demand
39+
demand = client.get_instantaneous_demand()
40+
print(f"Current Demand: {demand.panic_demand:.2f} kW")
41+
42+
# Get total consumption
43+
summation = client.get_current_summation()
44+
print(f"Delivered: {summation.delivered_kwh:.2f} kWh")
45+
46+
# List connected devices
47+
devices = client.list_devices()
48+
for device in devices.device_info:
49+
print(f"Device: {device.device_mac_id}")
50+
51+
# Get network status
52+
network = client.get_network_info()
53+
print(f"Link Strength: {network.link_strength}%")
54+
55+
# Get historical data (last hour, 15-minute intervals)
56+
from datetime import datetime, timedelta, timezone
57+
history = client.get_history_data(
58+
start_time=datetime.now(timezone.utc) - timedelta(hours=1),
59+
frequency=0x384 # 15 minutes in seconds (900)
60+
)
61+
for entry in history:
62+
print(f"{entry.timestamp}: {entry.delivered_kwh:.2f} kWh")
63+
```
2064

2165
::: meter_reader.clients.socket.EagleSocketClient
2266
handler: python
@@ -25,16 +69,71 @@ The `EagleSocketClient` communicates via the local XML API on port 5002. This is
2569
- __init__
2670
- list_devices
2771
- get_instantaneous_demand
72+
- get_current_summation
73+
- get_usage_data
74+
- get_network_info
2875
- get_history_data
2976

3077
## HTTP Client
3178

32-
The `EagleHttpClient` communicates via the local web interface API (`cgi_manager`) on port 80. This method uses JSON responses where possible and supports username/password authentication.
79+
The `EagleHttpClient` communicates via HTTP POST requests to the `/cgi-bin/cgi_manager` endpoint on port 80. Responses are returned as JSON. This client supports username/password authentication and is useful for deployments where HTTP is preferred over raw sockets.
80+
81+
### Usage Example
82+
83+
```python
84+
from meter_reader import EagleHttpClient
85+
86+
# Connect with credentials
87+
client = EagleHttpClient(
88+
"192.168.1.100",
89+
username="admin",
90+
password="password"
91+
)
92+
93+
# Get usage data (combines demand and summation)
94+
usage = client.get_usage_data()
95+
print(f"Demand: {usage.demand} {usage.demand_units}")
96+
print(f"Delivered: {usage.summation_delivered} {usage.summation_units}")
97+
print(f"Meter Status: {usage.meter_status}")
98+
99+
# List connected devices
100+
devices = client.list_devices()
101+
for device in devices.device_info:
102+
print(f"Device MAC: {device.device_mac_id}")
103+
print(f"Model ID: {device.model_id}")
104+
105+
# Get demand (synthesized from usage data)
106+
demand = client.get_instantaneous_demand()
107+
print(f"Demand: {demand.demand:.2f}")
108+
109+
# Get summation (synthesized from usage data)
110+
summation = client.get_current_summation()
111+
print(f"Total Delivered: {summation.delivered_kwh:.2f} kWh")
112+
```
33113

34114
::: meter_reader.clients.http.EagleHttpClient
35115
handler: python
36116
options:
37117
members:
38118
- __init__
39-
- get_usage_data
40119
- list_devices
120+
- get_usage_data
121+
- get_instantaneous_demand
122+
- get_current_summation
123+
124+
## Choosing Between Socket and HTTP
125+
126+
| Feature | Socket | HTTP |
127+
|---------|--------|------|
128+
| Protocol | TCP on port 5002 | HTTP POST on port 80 |
129+
| Data Format | XML | JSON |
130+
| Authentication | Optional, in XML payload | HTTP Basic Auth |
131+
| Speed | Fastest | Slightly higher latency |
132+
| Firewall Friendly | May require port 5002 | Standard HTTP port |
133+
| Real-time Monitoring | Excellent | Good |
134+
| Historical Queries | Native support | Limited |
135+
136+
### Recommendation
137+
138+
* Use **Socket API** if you need the lowest latency, historical data queries, or the device has port 5002 open
139+
* Use **HTTP API** if you need standard HTTP authentication, prefer JSON, or must operate within strict firewall rules

0 commit comments

Comments
 (0)