Skip to content

Conversation

@bouwew
Copy link
Contributor

@bouwew bouwew commented Jun 12, 2025

Via this update, set_switch_state() in plugwise doesn't raise an error when a locked switch is toggled.

This corrects the behavior in the frontend: when a locked switch is toggled it will return to it's previous state after a few seconds.

At present, the switch toggles to the opposite state when clicked and stays in that state, which is wrong. Only after a browser-refresh the correct switch state is shown.

Summary by CodeRabbit

  • Bug Fixes

    • Improved switch state handling to ensure accurate status updates when turning switches on or off.
  • Tests

    • Added a test to verify correct behavior when attempting to turn off a locked switch, ensuring the state remains unchanged but the command is still issued.
  • Chores

    • Updated the integration dependency to use a newer alpha version of the underlying package.

@bouwew bouwew changed the title Adapt to plugwise v.1.7.0 Adapt to plugwise v.1.7.5 Jun 12, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 13, 2025

Walkthrough

This update increments the required "plugwise" backend package version from 1.7.4 to 1.7.6, updates the integration version to 0.57.4 in both the manifest and project files, and revises the changelog to reflect these changes and recent release notes.

Changes

File(s) Change Summary
custom_components/plugwise/manifest.json Bumped plugwise package requirement to 1.7.6 and integration version to 0.57.4.
pyproject.toml Updated project version from 0.57.1 to 0.57.4.
CHANGELOG.md Added release notes for 0.57.4, 0.57.3, and 0.57.2; referenced plugwise backend version updates.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HomeAssistant
    participant PlugwiseIntegration
    participant PlugwiseBackend

    User->>HomeAssistant: Initiates action (e.g., toggle switch)
    HomeAssistant->>PlugwiseIntegration: Process user action
    PlugwiseIntegration->>PlugwiseBackend: Uses plugwise v1.7.6 API
    PlugwiseBackend-->>PlugwiseIntegration: Returns response (no error on locked switch)
    PlugwiseIntegration-->>HomeAssistant: Update state
    HomeAssistant-->>User: Reflect result
Loading

Possibly related PRs

Suggested labels

require-dev-pass

Suggested reviewers

  • CoMPaTech

Poem

A version hop, a changelog note,
The backend’s new, the features float.
No errors now when switches lock—
The plugwise bunny checks the clock.
With numbers bumped and bugs all gone,
We celebrate and hop along!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5716f76 and 0f65c9f.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • custom_components/plugwise/manifest.json (1 hunks)
  • pyproject.toml (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • custom_components/plugwise/manifest.json
  • pyproject.toml
  • CHANGELOG.md
✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch pw1_7_5

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Error while testing for Development HA-core:

⚠️ Warning: Incompatible while testing against dev HA-core.
Error: Incompatible while testing against released HA-core and required to pass.

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: 3

♻️ Duplicate comments (1)
custom_components/plugwise/switch.py (1)

143-148: Same instant-feedback issue for async_turn_off

Mirror the async_turn_on adjustment to keep behaviour symmetrical.

🧹 Nitpick comments (1)
custom_components/plugwise/switch.py (1)

133-138: Immediate state push missing

plugwise_command schedules a refresh, but UI feedback is delayed until the coordinator cycle finishes. Calling self.async_write_ha_state() after updating _attr_is_on gives instant feedback.

-        self._attr_is_on = await self.coordinator.api.set_switch_state(
+        self._attr_is_on = await self.coordinator.api.set_switch_state(
             ...
         )
+        self.async_write_ha_state()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f55cca and 24decb4.

📒 Files selected for processing (3)
  • custom_components/plugwise/manifest.json (1 hunks)
  • custom_components/plugwise/switch.py (2 hunks)
  • tests/components/plugwise/test_switch.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
tests/components/plugwise/test_switch.py (1)
tests/components/plugwise/conftest.py (1)
  • mock_smile_adam (118-146)
custom_components/plugwise/switch.py (2)
custom_components/plugwise/entity.py (1)
  • device (91-93)
custom_components/plugwise/util.py (1)
  • plugwise_command (21-46)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Setup for HA-core (dev)
  • GitHub Check: Setup for HA-core (release/master)

Comment on lines 10 to 12
"requirements": [
"https://test-files.pythonhosted.org/packages/36/d7/e9d82d927fbad3edd56c8da59fef08dbf1e80ff535eee1ba6e4eb649ca89/plugwise-1.7.5a1.tar.gz#plugwise==1.7.5a1"
],
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Direct-URL requirement string is not PEP 508 compliant

The fragment #plugwise==1.7.5a1 will not be recognised by pip; the canonical form is either

"plugwise @ https://…/plugwise-1.7.5a1.tar.gz"

or

"https://…/plugwise-1.7.5a1.tar.gz#egg=plugwise"

An invalid spec will break HA’s runtime dependency install.

Apply:

-"https://test-files.pythonhosted.org/.../plugwise-1.7.5a1.tar.gz#plugwise==1.7.5a1"
+"plugwise @ https://test-files.pythonhosted.org/.../plugwise-1.7.5a1.tar.gz"
🤖 Prompt for AI Agents
In custom_components/plugwise/manifest.json at lines 10 to 12, the direct URL
requirement string is not PEP 508 compliant because it uses the fragment
#plugwise==1.7.5a1 which pip does not recognize. To fix this, replace the
current string with a PEP 508 compliant format such as "plugwise @
https://.../plugwise-1.7.5a1.tar.gz" or
"https://.../plugwise-1.7.5a1.tar.gz#egg=plugwise" to ensure proper dependency
installation by Home Assistant.

@bouwew bouwew changed the title Adapt to plugwise v.1.7.5 Adapt to plugwise v.1.7.6 Jun 13, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Error while testing for Development HA-core:

⚠️ Warning: Incompatible while testing against dev HA-core.
Error: Incompatible while testing against released HA-core and required to pass.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Error while testing for Development HA-core:

⚠️ Warning: Incompatible while testing against dev HA-core.
Error: Incompatible while testing against released HA-core and required to pass.

@sonarqubecloud
Copy link

@bouwew bouwew marked this pull request as ready for review June 24, 2025 06:59
@bouwew bouwew requested a review from a team as a code owner June 24, 2025 06:59
@bouwew bouwew closed this Jun 24, 2025
@bouwew bouwew deleted the pw1_7_5 branch June 24, 2025 07:29
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