Skip to content

Add devices.statistics for Control Tower device counters - #72

Merged
FabianoEger merged 2 commits into
mainfrom
feat/device-statistics
Oct 5, 2026
Merged

FabianoEger merged 2 commits into
mainfrom
feat/device-statistics

Conversation

@FabianoEger

@FabianoEger FabianoEger commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds resources.devices.statistics(deviceID, queryParams=None), which wraps GET /device/:device_id/statistics. That Control Tower route returns a device's device_input and device_output counters over time, and the SDK had no method for it. The PR also adds the DeviceStatisticsQuery and DeviceStatistic TypedDicts, parses time into a datetime, and documents the method and types in the Sphinx docs.

Bumps the version to 5.1.8 in pyproject.toml and uv.lock.

Test plan

  • testStatistics and testStatisticsWithoutQuery in tests/Resources/test_devices.py
  • uv run pytest tests (224 passed)
  • uv run ruff check src passes
  • sphinx-build renders the new section, and the DeviceStatisticsQuery / DeviceStatistic refs resolve

Risk (CIA)

Likelihood: 🟢 Low | Impact: 🟢 Low | Exposure: 🟢 Low

Related

Wrap GET /device/:device_id/statistics, the Control Tower route that
returns the input and output counters of a device over time. Adds the
DeviceStatisticsQuery and DeviceStatistic types, parses time into a
datetime, and documents the method in the Sphinx docs.
@FabianoEger

Copy link
Copy Markdown
Member Author

Approve
devices.statistics calls the route correctly, forwards the query, and parses time into a naive datetime through dateParserList, the same way as its sibling methods. The Sphinx docs and doc comment match the contract documented in tago-io/docs#169. CI is green, and the branch is current with main.

Improvements

  • src/tagoio_sdk/modules/Resources/Device_Type.py:677: total=False also makes time optional, even though the API always returns it and the JS SDK types it as required. Pyright reports item["time"] as a not-required key access. Consider time: Required[datetime], which Python 3.11 supports.
  • src/tagoio_sdk/modules/Resources/Devices.py:626: the @see link to https://docs.tago.io/docs/api/device-statistics returns 404 today and will keep failing until tago-io/docs#169 is deployed. This applies to docs/source/Resources/Devices/index.rst:614 too. Consider merging the docs PR before you publish the 5.1.8 release.
  • src/tagoio_sdk/modules/Resources/Devices.py:622: "Requires the Control Tower add-on" suggests that the call fails without the add-on. According to tago-io/docs#169, the route returns an empty list for a profile that does not have it. Consider saying that here and in docs/source/Resources/Devices/index.rst:609.

Risk (CIA)

Likelihood: 🟢 Low | Impact: 🟢 Low | Exposure: 🟢 Low.
Confirmed. This adds a read-only GET wrapper and two TypedDicts. No existing method changes.

@FabianoEger
FabianoEger merged commit 9c42451 into main Oct 5, 2026
6 checks passed
@FabianoEger
FabianoEger deleted the feat/device-statistics branch October 5, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants