Add Shelly Cloud receiver for OpenTelemetry Collector#154
Merged
Conversation
Implements an OTel metrics receiver that polls the Shelly Cloud API at a configurable interval (default 60s) to collect power, energy, voltage, current, frequency, switch state, and temperature metrics from all registered Shelly devices. Key design decisions: - Supports both Gen1 (meters/relays) and Gen2 (switch:N) device formats detected automatically from the API response structure - Enriches each ResourceMetrics with device name, model, and room from Shelly Cloud metadata — no static IP or device list required - Offline devices are skipped gracefully each scrape cycle https://claude.ai/code/session_01GUUhdyzy1c1GYyN4LuDeZ5
Correct the device list endpoint and response structure based on the real API response observed with curl: - Use GET /interface/device/list instead of POST /interface/device/collection - Parse data.devices (not data.devices_status) - Add Gen, Channel, ChannelsCount, BaseID, CloudOnline to DeviceInfo Also redesign the scraper and marshaler to handle multi-channel devices properly: the device list already exposes one entry per channel (e.g. 98a3167ba5d8_1, _2, _3 for a 4-channel strip), each with its own name and room. The scraper now fetches status once per physical device (by BaseID) and the marshaler selects the right channel data using info.Gen and info.Channel. https://claude.ai/code/session_01GUUhdyzy1c1GYyN4LuDeZ5
Surface the 'errors' field from the Shelly Cloud response so failures are actionable without needing to curl manually. https://claude.ai/code/session_01GUUhdyzy1c1GYyN4LuDeZ5
- Add request_delay config (default 500ms) between device status calls to avoid hitting Shelly Cloud rate limits when polling many devices - Check data.online in the device status response and skip gracefully when a device is reported offline at fetch time https://claude.ai/code/session_01GUUhdyzy1c1GYyN4LuDeZ5
Parses wifi_sta (Gen1) and wifi (Gen2+) from device status: - shelly.wifi.rssi → Gauge metric (dBm), emitted per channel - shelly.wifi.ssid → resource attribute - shelly.wifi.ip → resource attribute https://claude.ai/code/session_01GUUhdyzy1c1GYyN4LuDeZ5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new OpenTelemetry Collector receiver for Shelly Cloud smart home devices. The receiver integrates with the Shelly Cloud API to collect metrics from Shelly smart switches and relays, supporting both Gen1 and Gen2 device formats.
Key Changes
New Shelly Cloud Receiver Module (
receiver/shellycloudreceiver/)client.go: Implements the Shelly Cloud API client with methods to list devices, fetch device status, and parse both Gen1 and Gen2 device formatsconfig.go: Configuration schema with validation forserver_url,auth_key, andcollection_intervalsettingsfactory.go: Receiver factory implementation following OpenTelemetry Collector patternsscraper.go: Scraper implementation that orchestrates device discovery and metric collectionmarshaler.go: Converts device status data into OpenTelemetry metrics with proper resource attributes and metric typesMetrics Exported
Device Support
switch:Ncomponents with comprehensive metricsmetersandrelaysarrays with legacy format supportResource Attributes
Reliability & Rate Limiting
Integration
collector/go.modto include the new receiver modulecollector/components.goto register the Shelly Cloud receiver factorygo.workto include the receiver module in the workspaceImplementation Details
https://claude.ai/code/session_01GUUhdyzy1c1GYyN4LuDeZ5