Query TeslaMate data through Grafana's /api/ds/query endpoint using the PostgreSQL datasource.
Grafana address is stored in ~/.openclaw/workspace/memory/teslamate-grafana-config.json:
json
{
"grafana_url": "http://192.168.31.218:3000",
"datasource_id": 1
}
To update address:
bash
echo '{"grafana_url": "http://YOUR-GRAFANA:3000", "datasource_id": 1}' > ~/.openclaw/workspace/memory/teslamate-grafana-config.json
bash
python3 scripts/query_teslamate.py --status
# Output: Battery: 85% | Range: 420 km | State: online | Today: 45 km
bash
python3 scripts/query_teslamate.py --drives 5
# Recent 5 drives with address lookup
bash
python3 scripts/query_teslamate.py --route "广州珠江新城"
# Output: Distance, duration, energy needed, arrival range
CommandDescription--statusQuick status: battery, range, state, today distance--drives [N]Recent N drives with address lookup--route <addr>Plan route to destination--reportWeekly report--monthlyMonthly statistics--trendEnergy efficiency trend (30 days)--scoreDriving score based on speed--milestonesAchievement milestones--chargingCharging statistics (30 days)--efficiencyEnergy efficiency stats--costCharging cost (default 1.5 CNY/kWh)--rangeRange prediction--healthBattery health estimation--placesTop 10 most visited places--drainVampire drain analysis--statesVehicle state statistics--alertsCheck for anomalies--tempTemperature monitoring--locationCurrent car location--fullComplete status dashboard
battery_level (0-100%), ideal_battery_range_kmdistance (km), duration_min (minutes), speed_max, power_maxcharge_energy_added (kWh), charger_power (kW), charger_voltage (V)state = 'online'|'offline'|'driving'|'charging'|'asleep'|'updating'{grafana_url}/api/ds/queryRequest body:
json
{
"queries": [{
"refId": "A",
"datasourceId": 1,
"rawSql": "YOUR SQL QUERY",
"format": "table"
}]
}
Response contains results in results.A.data.values.