Gasleser Local API
The Gasleser local API provides direct access to your gas consumption data over the local network. This API is only available locally and cannot be accessed over the internet.
The local API feature is only available with Gasleser firmware version 1.0.21 and higher.
API Endpoint
The API is accessible via the following URL:
http://[DEVICE_IP]/v1/data
Example:
http://192.168.2.132/v1/data
Rate Limiting
The API has rate limiting implemented:
- 1 request every 10 seconds
- Requests exceeding the limit will be rejected
Ensure your application doesn't send requests more than once every 10 seconds.
API Response
The API returns JSON data in the following format:
{
"device_id": "GAS_2329790123",
"timestamp": "1758798550",
"total_consumption": 12345.8,
"current_flow_rate": 0.0
}
Response Fields
| Field | Type | Description |
|---|---|---|
device_id | String | Unique device ID of the Gasleser |
timestamp | String | Unix timestamp of the measurement |
total_consumption | Float | Total consumption in cubic meters (the big number on the gas meter) |
current_flow_rate | Float | Current flow rate in m�/h |
Flow Rate Details
The current_flow_rate is a calculated value with the following properties:
- Unit: Cubic meters per hour (m�/h)
- Purpose: Live visualization of current gas consumption
- Algorithm: Uses a gradual drop algorithm for a smooth curve
- Note: For illustration and visual representation purposes only
The current_flow_rate value is primarily intended for live visualization and shows a smoothed representation of current consumption.
Example Integration
Python Example
import requests
import time
def get_gasleser_data(device_ip):
try:
response = requests.get(f"http://{device_ip}/v1/data", timeout=5)
if response.status_code == 200:
return response.json()
else:
print(f"Error: HTTP {response.status_code}")
return None
except requests.exceptions.RequestException as e:
print(f"Connection error: {e}")
return None
# Example usage
device_ip = "192.168.2.132"
data = get_gasleser_data(device_ip)
if data:
print(f"Device: {data['device_id']}")
print(f"Total consumption: {data['total_consumption']} m�")
print(f"Current flow rate: {data['current_flow_rate']} m�/h")
# Respect rate limiting
time.sleep(10) # Wait 10 seconds
curl Example
curl -X GET http://192.168.2.132/v1/data
Error Handling
Common Errors
- 429 Too Many Requests: Rate limit exceeded, wait 10 seconds
- 404 Not Found: API endpoint not available (firmware < 1.0.21)
- Timeout: Device unreachable, check network connection
Troubleshooting
- Check firmware version: Ensure version 1.0.21+ is installed
- Test network connection: Ping the device
- Verify IP address: Use correct device IP
- Respect rate limiting: Wait at least 10 seconds between requests
Integration with Home Assistant
For Home Assistant integration, see Gasleser Home Assistant Integration.
Security Notes
- API is only available on local network
- No authentication required
- Ensure your network is secure
- Use firewall rules if needed