Skip to content

Conversation

@bouwew
Copy link
Contributor

@bouwew bouwew commented Nov 27, 2025

Summary by CodeRabbit

  • Refactor
    • Simplified switch control API and removed group-based switch handling; grouping logic now focuses on pumping groups only.
  • Chores
    • Added an availability gate for certain heater data checks.
  • Tests
    • Cleaned fixtures and updated tests to remove obsolete group entries and related test cases.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2025

Warning

Rate limit exceeded

@bouwew has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 26 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 69cf6e6 and 9e9474c.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • plugwise/data.py (1 hunks)

Walkthrough

This PR removes switching-group support: deletes group fixtures and test entries, drops GROUP_TYPES and switching-group helpers, and removes members-based group handling (including the members parameter from set_switch_state) across public, smile and legacy APIs; tests updated accordingly.

Changes

Cohort / File(s) Change Summary
Fixture device removals
fixtures/adam_multiple_devices_per_zone/data.json, fixtures/adam_plus_anna_new/data.json, fixtures/adam_plus_anna_new_regulation_off/data.json, fixtures/m_adam_cooling/data.json, fixtures/m_adam_heating/data.json, fixtures/m_adam_multiple_devices_per_zone/data.json, fixtures/stretch_v23/data.json, fixtures/stretch_v31/data.json
Removed top-level group device entries (switching groups, e.g., "Test") and their member references, sensors, switches and vendor metadata.
Test fixture removals
tests/data/adam/adam_multiple_devices_per_zone.json, tests/data/adam/adam_plus_anna_new.json, tests/data/adam/adam_plus_anna_new_UPDATED_DATA.json, tests/data/adam/adam_plus_anna_new_regulation_off.json, tests/data/stretch/stretch_v23.json, tests/data/stretch/stretch_v31.json, tests/data/stretch/stretch_v31_UPDATED_DATA.json
Removed corresponding group entries in test data fixtures.
Public API signature updates
plugwise/__init__.py
Removed members parameter from set_switch_state signature and updated internal call to self._smile_api.set_switch_state(appl_id, model, state).
Smile API / legacy changes
plugwise/smile.py, plugwise/legacy/smile.py
Removed members parameter from set_switch_state, deleted _set_groupswitch_member_state helper, and removed group-switch handling and group-integration logic.
Constants and common logic
plugwise/constants.py, plugwise/common.py
Deleted GROUP_TYPES / SWITCH_GROUP_TYPES constants and removed _entity_switching_group; narrowed _get_groups to collect pumping-only groups and require members.
Data processing changes
plugwise/data.py, plugwise/legacy/data.py
Removed calls/integration of switching-group processing and adjusted availability checks; group-entity enrichment steps removed.
Test updates
tests/test_adam.py, tests/test_init.py, tests/test_legacy_stretch.py
Adjusted entity-count assertions, removed group-switch test blocks, and simplified test helpers by removing members parameter from tinker_switch/tinker_switch_bad_input; updated calls to match new set_switch_state signature.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Tests / Caller
    participant API as plugwise.__init__.py (API)
    participant Smile as plugwise/smile.py (SmileAPI)

    Test->>API: await set_switch_state(appl_id, model, state)
    API->>Smile: set_switch_state(appl_id, model, state)
    Note right of Smile: group-member branches removed\n(now handles single switch only)
    Smile-->>API: bool (success/failure)
    API-->>Test: return bool
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Key attention areas:
    • Consistency of members removal across plugwise/__init__.py, plugwise/smile.py, and plugwise/legacy/smile.py.
    • Ensure no remaining references to GROUP_TYPES, SWITCH_GROUP_TYPES, _entity_switching_group, or _set_groupswitch_member_state.
    • Verify _get_groups pumping-only logic and requirement that groups have members align with intended behavior.
    • Confirm tests and fixture deletions match updated entity counts and no stale IDs remain.

Possibly related PRs

  • plugwise/python-plugwise#828 — touches same group-handling codepaths and fixtures (GROUP_TYPES, group helpers, set_switch_state).
  • plugwise/python-plugwise#765 — modifies set_switch_state and related switch-handling logic inside Smile API.
  • plugwise/python-plugwise#794 — adjusts group-switch handling and entity-counting logic in common/data processing.

Suggested labels

enhancement

Suggested reviewers

  • CoMPaTech

Poem

🐇 I hopped through fixtures, files in tow,
Pulled out a group called "Test" — away did it go.
No members to round up, no group-switching race,
Calls trimmed and tidy, a neater interface.
Thump-thump, code gleams — a carrot for grace! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Remove switch-groups' directly and concisely describes the main change: removal of switch-group functionality and related data across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (8182e8c) to head (9e9474c).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #829   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         3451      3403   -48     
=========================================
- Hits          3451      3403   -48     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
plugwise/data.py (1)

192-203: OpenTherm availability gate is reasonable; name check is a bit magic

Restricting the OpenTherm availability check to entity["name"] != "OnOff" avoids incorrectly marking pure on/off heaters unavailable on “no OpenTherm communication” messages, which matches the PR intent. The only minor concern is the hard dependency on the literal name "OnOff"; if that label ever changes, this gate will silently break. Consider tying this to a capability flag instead if you touch this area again.

plugwise/smile.py (1)

396-438: Per-switch set_switch_state implementation matches new API contract

The per-entity switch handling (including model-specific handling via model_to_switch_items, actuator lookup, and relay lock guard) is consistent with the new no-group API and with the test helpers’ expectations. The remaining assumption is that at least one matching actuator exists so switch_id is always set, which is unchanged behavior but worth remembering if new device types are added.

If you later expand device support, consider adding a defensive fallback (e.g. raising a PlugwiseError) when no matching actuator is found instead of relying on that invariant.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8182e8c and 957c9f2.

📒 Files selected for processing (25)
  • fixtures/adam_multiple_devices_per_zone/data.json (0 hunks)
  • fixtures/adam_plus_anna_new/data.json (0 hunks)
  • fixtures/adam_plus_anna_new_regulation_off/data.json (0 hunks)
  • fixtures/m_adam_cooling/data.json (0 hunks)
  • fixtures/m_adam_heating/data.json (0 hunks)
  • fixtures/m_adam_multiple_devices_per_zone/data.json (0 hunks)
  • fixtures/stretch_v23/data.json (0 hunks)
  • fixtures/stretch_v31/data.json (0 hunks)
  • plugwise/__init__.py (2 hunks)
  • plugwise/common.py (2 hunks)
  • plugwise/constants.py (0 hunks)
  • plugwise/data.py (1 hunks)
  • plugwise/legacy/data.py (0 hunks)
  • plugwise/legacy/smile.py (2 hunks)
  • plugwise/smile.py (2 hunks)
  • tests/data/adam/adam_multiple_devices_per_zone.json (0 hunks)
  • tests/data/adam/adam_plus_anna_new.json (0 hunks)
  • tests/data/adam/adam_plus_anna_new_UPDATED_DATA.json (0 hunks)
  • tests/data/adam/adam_plus_anna_new_regulation_off.json (0 hunks)
  • tests/data/stretch/stretch_v23.json (0 hunks)
  • tests/data/stretch/stretch_v31.json (0 hunks)
  • tests/data/stretch/stretch_v31_UPDATED_DATA.json (0 hunks)
  • tests/test_adam.py (2 hunks)
  • tests/test_init.py (3 hunks)
  • tests/test_legacy_stretch.py (2 hunks)
💤 Files with no reviewable changes (17)
  • tests/data/stretch/stretch_v23.json
  • fixtures/adam_multiple_devices_per_zone/data.json
  • tests/data/stretch/stretch_v31_UPDATED_DATA.json
  • tests/data/adam/adam_plus_anna_new_regulation_off.json
  • fixtures/m_adam_heating/data.json
  • plugwise/constants.py
  • tests/data/adam/adam_multiple_devices_per_zone.json
  • plugwise/legacy/data.py
  • fixtures/adam_plus_anna_new/data.json
  • fixtures/m_adam_cooling/data.json
  • fixtures/stretch_v23/data.json
  • fixtures/adam_plus_anna_new_regulation_off/data.json
  • tests/data/stretch/stretch_v31.json
  • fixtures/m_adam_multiple_devices_per_zone/data.json
  • tests/data/adam/adam_plus_anna_new_UPDATED_DATA.json
  • tests/data/adam/adam_plus_anna_new.json
  • fixtures/stretch_v31/data.json
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2024-12-13T11:26:00.100Z
Learnt from: bouwew
Repo: plugwise/python-plugwise PR: 671
File: plugwise/legacy/data.py:97-106
Timestamp: 2024-12-13T11:26:00.100Z
Learning: In `plugwise/legacy/data.py`, the legacy thermostat does not support cooling, so handling of the cooling state is unnecessary in this code.

Applied to files:

  • plugwise/data.py
📚 Learning: 2025-11-09T09:22:20.172Z
Learnt from: bouwew
Repo: plugwise/python-plugwise PR: 814
File: plugwise/constants.py:254-262
Timestamp: 2025-11-09T09:22:20.172Z
Learning: In `plugwise/constants.py`, `ACTIVE_KEYS` contains only the keys that exist as original actuators in the raw Plugwise device data. Keys like `setpoint_high` and `setpoint_low` are NOT original actuators—they are derived/translated later for Home Assistant integration, so they should not be included in `ACTIVE_KEYS` even though they appear in the `ActuatorData` TypedDict.

Applied to files:

  • plugwise/common.py
🧬 Code graph analysis (3)
plugwise/legacy/smile.py (2)
plugwise/__init__.py (1)
  • set_switch_state (411-427)
plugwise/smile.py (1)
  • set_switch_state (396-438)
tests/test_init.py (2)
plugwise/__init__.py (1)
  • set_switch_state (411-427)
plugwise/smile.py (1)
  • set_switch_state (396-438)
plugwise/__init__.py (2)
plugwise/legacy/smile.py (1)
  • set_switch_state (218-265)
plugwise/smile.py (1)
  • set_switch_state (396-438)
🔇 Additional comments (8)
plugwise/common.py (1)

176-210: Pumping-only group handling looks consistent with removal of switch-groups

Filtering on group_type != "pumping" and requiring non-empty members before adding a group keeps gw_entities aligned with real pumping groups and avoids orphaned/empty groups. The docstring matches the new behavior; no issues spotted here.

tests/test_legacy_stretch.py (1)

32-32: Adjusted entity counts align with group-removal

Lowering self.entity_items expectations in the Stretch v3.1 and v2.3 tests is consistent with removing switch-group entities from the data model. As long as the fixtures were regenerated after the group removal (which they appear to be), these new counts look correct.

If you haven’t already, please run the Stretch tests once more after any further fixture tweaks to ensure these counts stay in sync.

Also applies to: 70-72

plugwise/__init__.py (1)

411-427: Public API signature change is coherent with backend changes

The simplified set_switch_state(appl_id, model, state) wrapper and its validation look correct and line up with the new Smile/SmileLegacy implementations. The only thing to keep in mind is that this is a breaking signature change for any external callers still passing members; ensure dependent projects (e.g., HA integration) are updated in lockstep or gated via versioning.

plugwise/smile.py (1)

102-121: Group docstring now correctly reflects pumping-only behavior

Updating the comment to “Collect and add pumping-group entities” matches the narrowed _get_groups() behavior in SmileCommon; nothing else to flag here.

tests/test_adam.py (1)

35-38: Adam entity count expectations updated appropriately

The reduced self.entity_items expectations in the Adam+Anna and multi-device tests line up with the removal of switch-groups, while still validating the overall topology. As long as the fixtures behind these setups were regenerated after the group removal, these new numbers look sound.

It’s worth re-running the Adam test suite once more after any subsequent fixture tweaks to ensure these counts remain correct.

Also applies to: 222-225, 297-299

plugwise/legacy/smile.py (2)

77-85: Legacy entity collection docstring matches simplified behavior

The updated description of get_all_gateway_entities for legacy devices (no mention of groups) matches the fact that group data is no longer merged into gw_entities. No issues here.


218-265: Legacy set_switch_state aligned with new signature and behavior

The legacy set_switch_state(appl_id, model, state) keeps the previous per-relay and lock logic, while dropping group handling to match the new public API. For Stretch v2 handling (_stretch_v2) you still correctly switch actuator namespaces. This looks consistent with the tests in tests/test_legacy_stretch.py.

tests/test_init.py (1)

624-650: Test helpers now match the simplified set_switch_state API

Updating tinker_switch and tinker_switch_bad_input to call api.set_switch_state(dev_id, model, new_state) without a members argument correctly reflects the new core API and still validates both happy-path behavior and bad-input error handling. The signatures and call sites in other tests remain consistent with this change.

Also applies to: 653-665

@sonarqubecloud
Copy link

@bouwew bouwew marked this pull request as ready for review November 27, 2025 18:20
@bouwew bouwew requested a review from a team as a code owner November 27, 2025 18:20
@bouwew
Copy link
Contributor Author

bouwew commented Nov 28, 2025

Not merged to keep the present functionality in place for non-HA platforms.

@bouwew bouwew closed this Nov 28, 2025
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.

3 participants