A Grafana datasource plugin for integrating and visualizing data from the WAGO Energy Management System (WEMS). This plugin enables users to query, monitor, and analyze energy data directly within Grafana dashboards with a user-friendly interface.
- Hierarchical Data Structure: Navigate through Endpoints → Appliances → Services → Data Points
- Multiple Aggregation Functions: Mean, median, min, max, sum, count, first, last, derivative
- Unit Mapping: Automatic conversion of WEMS units to Grafana-friendly formats
- Grafana: Version 10.4.0 or higher
- WEMS API: Client ID and Client Secret for authentication
- Network Access: Connection to WEMS API endpoint (default:
https://c1.api.wago.com/wems
)
-
Build the plugin:
npm run build mage -v build:linux
-
Deploy to Grafana:
# Create plugin directory sudo mkdir -p /var/lib/grafana/plugins/wago-wemsgrafanaplugin-datasource # Copy plugin files sudo cp -r dist/* /var/lib/grafana/plugins/wago-wemsgrafanaplugin-datasource/
-
Configure Grafana: Add the following line to
/etc/grafana/grafana.ini
:allow_loading_unsigned_plugins = wago-wemsgrafanaplugin-datasource
-
Restart Grafana:
sudo systemctl restart grafana-server
-
Clone and setup:
git clone <repository-url> cd wago-wemsgrafanaplugin-datasource npm install
-
Start development environment:
npm run server
-
Add WEMS Datasource in Grafana
-
Configure Connection:
- Client ID: Your WEMS API client ID
- Client Secret: Your WEMS API client secret
- Base URL: WEMS API endpoint (optional, defaults to
https://c1.api.wago.com/wems
)
-
Test Connection using the "Save & Test" button
The plugin provides a hierarchical query builder:
- Select Endpoint: Choose from available WEMS endpoints
- Select Appliance: Pick an appliance from the selected endpoint
- Select Service: Choose a service from the appliance
- Select Data Point: Pick the specific data point to query
- Configure Aggregation: Choose aggregation function (mean, max, etc.)
- Optional Settings: Enable "Create Empty Values" if needed
{
endpoint_id: string; // WEMS endpoint identifier
appliance_id: string; // Appliance identifier
service_uri: string; // Service URI path
data_point: string; // Specific data point name
aggregate_function?: string; // Aggregation method (default: 'mean')
create_empty_values?: boolean; // Fill gaps in data
}
- Numeric Values: Voltage, current, power, energy, temperature, etc.
- Boolean Values: Binary states, alarms, switches
- Enumerated Values: Status indicators with predefined labels
- Units: Automatic mapping (VOLTS → V, WATTS → W, AMPERES → A, etc.)
- Node.js: Version 22 or higher
- Go: For backend development
- Mage: Build tool for Go
-
Install dependencies:
npm install go mod tidy
-
Start development server:
npm run dev # Frontend development with watch mode npm run server # Start Grafana development environment
-
Build for production:
npm run build # Build frontend mage -v # Build backend for all platforms mage -v build:linux # Build backend for Linux only
- Unit Tests:
npm run test
ornpm run test:ci
- E2E Tests:
npm run e2e
(requiresnpm run server
first) - Linting:
npm run lint
ornpm run lint:fix
- Type Checking:
npm run typecheck
The backend is built with Go using the Grafana Plugin SDK:
- Authentication: OAuth2-style token management with auto-refresh
- API Integration: RESTful communication with WEMS API
- Data Processing: Time series data transformation and aggregation
- Resource Handlers: Dynamic loading of endpoints, appliances, services, and data points
The frontend uses React with Grafana UI components:
- ConfigEditor: Datasource configuration interface
- QueryEditor: Interactive query builder with cascading dropdowns
- Type Definitions: TypeScript interfaces for type safety
The plugin exposes several resource endpoints for dynamic data loading:
/resources/endpoint-list
- List available WEMS endpoints/resources/appliance-list?endpointId=<id>
- List appliances for an endpoint/resources/service-list?endpointId=<id>&applianceId=<id>
- List services for an appliance/resources/datapoint-list?endpointId=<id>&applianceId=<id>&serviceUri=<uri>
- List data points/resources/datapoint-unit?endpointId=<id>&applianceId=<id>&serviceUri=<uri>&datapoint=<name>
- Get unit and valid values
Enable debug logging in Grafana configuration:
[log]
level = debug
- Outbound HTTPS: Port 443 to WEMS API endpoint
- Authentication: Valid WEMS API credentials
- Firewall: Allow Grafana server to reach WEMS API
Apache License 2.0 - see LICENSE file for details.