Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@raman325
Copy link
Owner

@raman325 raman325 commented Jan 4, 2026

Proposed change

Maintenance PR with two changes:

  1. Clean up TODO.md - Remove completed items, fix incorrect websocket command names, and add a missing feature request
  2. Refactor websocket module - Extract reusable helper functions to reduce ~50 lines of duplicate code

TODO.md Changes

Change Details
Removed "Use both custom cards in strategy" - completed in #724
Removed "Go through zwave_reconnect_test_plan.md for PR 704" - PR merged
Removed "Refactor websocket module" - completed in this PR
Fixed Incorrect command name subscribe_lock_slot_datasubscribe_lock_codes / subscribe_code_slot
Added Schedule and Entity Condition Types feature request

Websocket Refactoring

Extracted module-level helper functions:

Helper Purpose
_get_text_state() Get text state from entity
_get_bool_state() Get boolean state (on/off)
_get_number_state() Get integer from number entity
_get_last_changed() Get timestamp as ISO string
_find_config_entry_by_title() Find config entry by slugified title
_get_slot_calendar_entity_id() Get calendar entity from slot config

Updated functions: async_get_entry, _get_slot_metadata, _serialize_slot_card_data, subscribe_code_slot, get_locks

Tests Added

Added 30 unit tests for the refactored helper functions covering:

  • Valid states, invalid states, unavailable, unknown, None entity_id
  • Edge cases like float-to-int conversion, slugified title matching
  • require_valid_state parameter behavior

Type of change

  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR is related to issue: General maintenance and code quality

🤖 Generated with Claude Code

- Remove completed items:
  - "Use both custom cards in strategy" (done in #724)
  - "Go through zwave_reconnect_test_plan.md for PR 704" (PR merged)
- Fix incorrect websocket command name (subscribe_lock_codes, not subscribe_lock_slot_data)
- Re-add schedule/entity condition types feature request

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings January 4, 2026 02:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR maintains the TODO.md file by removing completed tasks, correcting technical documentation, and adding a new feature request for alternative scheduling mechanisms.

  • Removes two completed TODO items (custom cards strategy and zwave test plan)
  • Corrects websocket command names in the documentation
  • Adds comprehensive feature request for Schedule and Entity Condition Types as calendar alternatives

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Extract module-level state helper functions for reuse:
  - _get_text_state, _get_bool_state, _get_number_state, _get_last_changed
- Extract config entry helpers:
  - _find_config_entry_by_title for config entry lookup by title
  - _get_slot_calendar_entity_id for calendar entity ID lookup from slot config
- Update _get_slot_metadata, _serialize_slot_card_data, subscribe_code_slot,
  get_locks, and async_get_entry decorator to use new helpers
- Remove ~50 lines of duplicate nested function definitions
- Update TODO.md to mark websocket refactoring as complete

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@github-actions github-actions bot added the python Pull requests that update Python code label Jan 4, 2026
@codecov
Copy link

codecov bot commented Jan 4, 2026

Codecov Report

❌ Patch coverage is 98.14815% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.25%. Comparing base (b62e276) to head (a959139).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
custom_components/lock_code_manager/websocket.py 98.14% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #729      +/-   ##
==========================================
+ Coverage   88.96%   89.25%   +0.28%     
==========================================
  Files          29       29              
  Lines        2366     2354      -12     
  Branches       78       78              
==========================================
- Hits         2105     2101       -4     
+ Misses        261      253       -8     
Flag Coverage Δ
python 88.86% <98.14%> (+0.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@raman325 raman325 changed the title Clean up TODO.md Chore: Clean up TODO.md and refactor websocket module Jan 4, 2026
@raman325 raman325 added the code-quality Pull requests that improve code quality label Jan 4, 2026
Test coverage for refactored helper functions:
- _get_text_state: valid state, unknown, unavailable, nonexistent, None
- _get_bool_state: on, off, unknown, unavailable, nonexistent, None
- _get_number_state: integer, float conversion, invalid, unknown, unavailable
- _get_last_changed: ISO timestamp, require_valid_state filtering
- _find_config_entry_by_title: exact match, slugified match, nonexistent
- _get_slot_calendar_entity_id: with calendar, without, nonexistent slot

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@raman325 raman325 merged commit 3a6153a into main Jan 4, 2026
10 checks passed
@raman325 raman325 deleted the chore/todo-cleanup branch January 4, 2026 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-quality Pull requests that improve code quality python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants