Skip to main content

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.

Firmware Requirements

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:

  • Firmware 1.4.6 and later: 1 request every 0.5 seconds
  • Firmware before 1.4.6: 1 request every 3 seconds
  • Requests exceeding the limit will be rejected
Respect Rate Limiting

Ensure your application doesn't send requests more than once every 0.5 seconds (firmware before 1.4.6: every 3 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​

FieldTypeDescription
device_idStringUnique device ID of the Gasleser
timestampStringUnix timestamp of the measurement
total_consumptionFloatTotal consumption in cubic meters (the big number on the gas meter)
current_flow_rateFloatCurrent 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
Usage Purpose

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(0.5) # Wait 0.5 seconds (firmware before 1.4.6: 3 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 0.5 seconds (firmware before 1.4.6: 3 seconds)
  • 404 Not Found: API endpoint not available (firmware < 1.0.21)
  • Timeout: Device unreachable, check network connection

Troubleshooting​

  1. Check firmware version: Ensure version 1.0.21+ is installed
  2. Test network connection: Ping the device
  3. Verify IP address: Use correct device IP
  4. Respect rate limiting: Wait at least 0.5 seconds between requests (firmware before 1.4.6: 3 seconds)

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