Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lower connection-timeout for actual devices after initial connect #576

Merged
merged 12 commits into from
Jun 5, 2024

Conversation

bouwew
Copy link
Contributor

@bouwew bouwew commented Jun 5, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new constant for legacy timeout settings to enhance connection handling for legacy devices.
  • Bug Fixes

    • Adjusted default timeout values to improve connection reliability and performance.
  • Documentation

    • Updated version in pyproject.toml to 0.38.2.
  • Tests

    • Added assertions for timeout settings in device tests to ensure correct behavior.

Copy link
Contributor

coderabbitai bot commented Jun 5, 2024

Walkthrough

The recent updates primarily address timeout configurations across the plugwise package. A new constant DEFAULT_LEGACY_TIMEOUT was introduced, and timeout values were adjusted for legacy and non-legacy devices. Additionally, the version in pyproject.toml was updated from "0.38.1" to "0.38.2". These changes ensure better handling of connection timeouts, especially for legacy devices, improving overall stability.

Changes

File Change Summary
plugwise/__init__.py Updated default timeout values and adjusted timeout parameters in methods.
plugwise/constants.py Modified DEFAULT_TIMEOUT and added DEFAULT_LEGACY_TIMEOUT.
plugwise/legacy/smile.py Added timeout parameter to the Smile class constructor.
plugwise/smile.py Removed DEFAULT_TIMEOUT and added timeout parameter to the constructor.
tests/test_init.py Added assertions for _timeout attribute in device_test function.
CHANGELOG.md Documented the reduction of connection timeout for devices post-initial connection.
pyproject.toml (existing) Updated version from "0.38.1" to "0.38.2a0".
pyproject.toml (new) Updated version from "0.38.1" to "0.38.2".

Poem

In the realm of code so bright,
Timeouts adjusted, just right.
Legacy devices now breathe with ease,
As connections flow like a breeze.
Version numbers climb anew,
With changes that enhance the view.
Plugwise dances in the light,
Stability in every byte! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

codecov bot commented Jun 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (dba5d57) to head (773b296).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #576   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines         3309      3316    +7     
=========================================
+ Hits          3309      3316    +7     

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

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dba5d57 and 10e9e2a.

Files selected for processing (5)
  • plugwise/init.py (6 hunks)
  • plugwise/constants.py (1 hunks)
  • plugwise/legacy/smile.py (4 hunks)
  • plugwise/smile.py (4 hunks)
  • tests/test_init.py (1 hunks)
Additional comments not posted (9)
plugwise/legacy/smile.py (2)

43-43: The addition of the timeout parameter to the constructor is well-implemented and aligns with the PR's objectives to manage timeouts effectively.


79-79: Setting the _timeout attribute directly from the timeout parameter is clear and effective.

plugwise/constants.py (2)

35-35: Reducing the DEFAULT_TIMEOUT from 30 to 10 is a sensible change that should improve responsiveness without compromising functionality.


36-36: Introducing DEFAULT_LEGACY_TIMEOUT as a separate constant for legacy devices is a prudent decision to accommodate devices that may need longer connection times.

plugwise/__init__.py (2)

50-50: Setting the default timeout in the constructor to DEFAULT_LEGACY_TIMEOUT aligns with the updated timeout strategy and ensures backward compatibility with legacy devices.


197-197: Dynamically setting _timeout based on device type in _smile_detect is an effective way to handle the varying needs of different devices.

plugwise/smile.py (2)

Line range hint 49-88: The addition of the timeout parameter in the constructor is consistent with the PR's objective to manage timeouts more effectively. This change allows for dynamic timeout settings, which can be crucial for different network conditions or device responsiveness.


88-88: Correctly setting self._timeout to the passed timeout parameter ensures that the timeout behavior is consistent across the class methods that rely on this setting.

tests/test_init.py (1)

555-558: The added assertions for smile._timeout are crucial for ensuring that the timeout settings are correctly applied based on the device type (legacy or not). This is a good practice to confirm that the system behaves as expected under different configurations.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 10e9e2a and dde95b5.

Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • pyproject.toml (1 hunks)
Files skipped from review due to trivial changes (1)
  • pyproject.toml
Additional context used
LanguageTool
CHANGELOG.md

[style] ~295-~295: Consider using just “revert”. (RETURN_BACK)
Context: .../issues/81672) - _full_update_device(): revert back to v0.21.4 logic - async_update(): not ...


[style] ~299-~299: Consider an alternative to strengthen your wording. (IMPROVEMENTS_REFINEMENTS)
Context: ... Core #81712 ## v0.25.10: Thermostats: more improvements - Anna + Elga: hide cooling_enable swi...


[style] ~366-~366: Consider using just “reverted”. (RETURN_BACK)
Context: ...g a heating and a cooling setpoint, was reverted back to providing a single setpoint. ## v0....


[style] ~407-~407: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...rovide the collected schedules as input in order to find the last-modified valid schedule. ...


[uncategorized] ~408-~408: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...ied valid schedule. - _rule_ids_by_x(): replace None by NONE, allowing for simp...


[grammar] ~456-~456: An apostrophe ‘s’ denotes possession. Did you mean to use the plural form of the noun (no apostrophe)? (NOUN_APOSTROPHE_S_VERB)
Context: ...dule_state() to handle multi thermostat scenario's - Improve tracking of the last used sch...


[style] ~482-~482: Consider an alternative to strengthen your wording. (CHANGES_ADJUSTMENTS)
Context: ...for #158 ## v0.16.7 - Smile: Bugfixes, more changes and improvements - Fix for #158: error...


[duplication] ~484-~484: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...ror setting up for systems with an Anna and and Elga (heatpump). - Block connecting to ...


[style] ~521-~521: ‘off of’ might be wordy. Consider a shorter alternative. (EN_WORDINESS_PREMIUM_OFF_OF)
Context: ...upport (representation and switching on/off of a schedule has changed) - Anna: Fix coo...


[uncategorized] ~629-~629: Do not mix variants of the same word (‘initialisation’ and ‘initialization’) within a single text. (EN_WORD_COHERENCY)
Context: ...hat is needed: full_update_device() for initialisation, update-device() for updating of live d...


[uncategorized] ~637-~637: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE_2)
Context: ... state - Improvement: Prioritize request so requests like switching a relay get sen...


[grammar] ~637-~637: Double-check that this verb is correct. Did you mean to use the past participle or the infinitive form here? (GET_VBN)
Context: ... so requests like switching a relay get send out before power measurement requests. ...


[uncategorized] ~658-~658: This expression is usually spelled with a hyphen. (BASED_HYPHEN)
Context: ...urement - name (string) - Name of device based om hardware model and MAC address -...


[grammar] ~920-~920: The singular proper name ‘Version’ must be used with a third-person or a past tense verb. (HE_VERB_AGR)
Context: ....16 - Fix central components - Version skip to align with -beta-component ### 0....


[grammar] ~946-~946: The singular proper name ‘Version’ must be used with a third-person or a past tense verb. (HE_VERB_AGR)
Context: ...s - Tests updated accordingly - Version skip to align with -beta-component ### 0....


[typographical] ~989-~989: Unpaired symbol: ‘'’ seems to be missing (EN_UNPAIRED_QUOTES)
Context: ...unctionality - Add individual Smiles as 'hub'-components ### 0.0.26 - Add relay ...

Additional comments not posted (1)
CHANGELOG.md (1)

3-6: The changelog entry for version 0.38.2 succinctly captures the essence of the PR, which is to lower the connection timeout for actual devices after the initial connect. This aligns well with the PR objectives and the modifications described in the AI-generated summary.

@bouwew bouwew marked this pull request as ready for review June 5, 2024 14:40
@bouwew bouwew requested a review from a team as a code owner June 5, 2024 14:40
@bouwew bouwew requested a review from CoMPaTech June 5, 2024 17:32
Copy link

sonarqubecloud bot commented Jun 5, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dde95b5 and 773b296.

Files selected for processing (1)
  • pyproject.toml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • pyproject.toml

@bouwew bouwew merged commit 411551c into main Jun 5, 2024
16 checks passed
@bouwew bouwew deleted the timeout branch June 5, 2024 17:38
@coderabbitai coderabbitai bot mentioned this pull request Sep 25, 2024
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