Skip to content

Conversation

@frenck
Copy link
Owner

@frenck frenck commented May 20, 2024

Proposed Changes

🚨 As of this PR WLED 0.14.0 is the minimum version required for this library.

SSIA

  • Cleans up a lot
  • Use orjson for faster parsing
  • Adds in mashumaro for data serialization
  • Bunch of new CLI commands
  • Splits out GitHub versions checking into a separate class (decoupling it from the device updates).

Note: There is still a lot to do, optimize and clean up. This PR is large enough and shippable. Next iterations can be done in smaller PRs.

Summary by CodeRabbit

  • New Features

    • Added new commands in the CLI for fetching and displaying WLED device information such as effects, palettes, playlists, presets, and releases.
    • Introduced a network scan command in the CLI to discover WLED devices.
  • Improvements

    • Enhanced the control script to toggle WLED device power states automatically.
    • Updated the upgrade script to fetch and utilize the latest stable version of WLED for upgrades.
  • Bug Fixes

    • Improved JSON handling using orjson for better performance and reliability.
  • New Dependencies

    • Added mashumaro and orjson dependencies.
  • Documentation

    • Updated the configuration to adjust the coverage report threshold and pylint settings.
  • Tests

    • Refactored and enhanced test functions for better coverage and reliability, including new tests for WLED device states and live override modes.

@coderabbitai
Copy link

coderabbitai bot commented May 20, 2024

Warning

Review failed

The pull request is closed.

Walkthrough

The updates broadly enhance the WLED control and upgrade functionality. Key changes include toggling device power, fetching and applying the latest firmware versions, integrating new dependencies, and revising enumerations and model classes. Various improvements were made to handling device states, error management, and test refactoring to maintain robustness.

Changes

Files Change Summaries
examples/control.py Updated device control logic: toggling power based on state, IP update, and output adjustments.
examples/upgrade.py Enhanced upgrade process: fetch latest versions, handle stable version check, and refactor code.
pyproject.toml Added dependencies mashumaro and orjson, adjusted coverage fail_under, and configured pylint.
src/wled/__init__.py, const.py, exceptions.py, utils.py, cli/__init__.py Added new models (Releases, WLEDReleases, etc.), removed some (Live, Sync), introduced WLEDUnsupportedVersionError and utility functions.
src/wled/wled.py Major refactor: replaced json with orjson, overhauled update, improved methods for segment control, presets, and playlists. Added new methods for live data handling, resets, session management, and version releases.
tests/test_wled.py Refactored tests: removed obsolete fixtures, updated tests for device states and new methods, adjusted mock data and assertions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Script as control.py
    participant WLEDDevice

    User->>Script: Execute script
    Script->>WLEDDevice: Fetch current state
    WLEDDevice-->>Script: Return state
    alt Device is ON
        Script->>WLEDDevice: Turn OFF
    else Device is OFF
        Script->>WLEDDevice: Turn ON
    end
    Script->>WLEDDevice: Fetch updated state
    WLEDDevice-->>Script: Return updated state
    Script->>User: Print updated state
Loading
sequenceDiagram
    participant User
    participant Script as upgrade.py
    participant WLEDReleases as ReleaseAPI
    participant WLEDDevice

    User->>Script: Execute upgrade
    Script->>ReleaseAPI: Fetch latest versions
    ReleaseAPI-->>Script: Return versions
    alt Stable version available
        Script->>WLEDDevice: Upgrade to stable version
    else No stable version
        Script->>User: Inform about unavailability
    end
    Script->>WLEDDevice: Update device info
    WLEDDevice-->>Script: Return updated info
    Script->>User: Print updated info
Loading

Poem

Amid circuits bright and lights all aglow,
A rabbit's delight in new scripts to show,
Devices now toggle with a simple command,
Upgraded, they sparkle, firmware so grand.
Oh, what a joy, in code's dance to partake,
Of WLED wonders, new dreams now awake.
🌟🐰💡


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.

@frenck frenck mentioned this pull request May 23, 2024
@frenck frenck force-pushed the frenck-2024-0342 branch from 3545809 to 1f16058 Compare June 18, 2024 20:06
@frenck frenck added refactor Improvement of existing code, not introducing new features. performance Improving performance, not introducing new features. labels Jun 18, 2024
@codecov
Copy link

codecov bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 81.93980% with 54 lines in your changes missing coverage. Please review.

Project coverage is 57.09%. Comparing base (52a001f) to head (d1056dd).
Report is 3 commits behind head on main.

Current head d1056dd differs from pull request most recent head 698a6e2

Please upload reports for the commit 698a6e2 to get more accurate results.

Files Patch % Lines
src/wled/models.py 83.77% 37 Missing ⚠️
src/wled/wled.py 52.94% 15 Missing and 1 partial ⚠️
src/wled/utils.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1334      +/-   ##
==========================================
- Coverage   58.56%   57.09%   -1.47%     
==========================================
  Files           4        6       +2     
  Lines         613      641      +28     
  Branches      139      128      -11     
==========================================
+ Hits          359      366       +7     
- Misses        233      271      +38     
+ Partials       21        4      -17     

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

@sonarqubecloud
Copy link

@frenck frenck marked this pull request as ready for review June 19, 2024 18:00
@frenck frenck added the breaking-change A breaking change for existing users. label Jun 19, 2024
@frenck frenck merged commit 57d046c into main Jun 19, 2024
@frenck frenck deleted the frenck-2024-0342 branch June 19, 2024 18:03
MIN_REQUIRED_VERSION = AwesomeVersion("0.14.0")


class LightCapability(IntFlag):
Copy link
Contributor

Choose a reason for hiding this comment

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

@frenck
The values seem incorrect (https://kno.wled.ge/interfaces/json-api/#light-capabilities), can you check?

Copy link
Owner Author

Choose a reason for hiding this comment

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

This was already there and not part of this PR. If you find an issue, please create an issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right, I'm going to do that, ty

@github-actions github-actions bot locked and limited conversation to collaborators Jun 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

breaking-change A breaking change for existing users. performance Improving performance, not introducing new features. refactor Improvement of existing code, not introducing new features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants