Skip to content

Code Cleanup - Remove Template Code & Fix Logger Reference #9

Description

@switch180

Problem

Two minor code quality issues need cleanup:

  1. Switch platform contains non-functional template code (Issue Zero Test Coverage - Critical Testing Infrastructure Gap #4)
  2. Configuration logger references wrong package name (Issue No Options Flow for Reconfiguration #5)

Both are low-impact but create confusion for developers and should be cleaned up.


Issue #4: Switch Platform Template Code

Current State

The switch.py file contains non-functional template code from the integration blueprint that was never removed or implemented:

Location: custom_components/riverlink/switch.py

class RiverLinkSwitch(RiverLinkEntity, SwitchEntity):
    """RiverLink Switch class."""

    def is_on(self) -> bool:
        """Return true if the switch is on."""
        return self.coordinator.data.get("title", "") == "foo"

    async def async_turn_on(self, **kwargs: Any) -> None:
        """Turn on the switch."""
        await self.coordinator.api.async_set_title("bar")

    async def async_turn_off(self, **kwargs: Any) -> None:
        """Turn off the switch."""
        await self.coordinator.api.async_set_title("foo")

Problems

  • References non-existent API method async_set_title()
  • Uses meaningless test values ("foo", "bar")
  • Switch platform is not loaded (not in PLATFORMS list in __init__.py)
  • Creates confusion for developers reading the code
  • No clear use case identified for this switch

Impact

  • Severity: Low (not loaded, doesn't affect users)
  • Developer Impact: Medium (confusing for contributors)

Resolution Options

Option 1 (Recommended): Delete the file

  • Remove custom_components/riverlink/switch.py entirely
  • No switch functionality is needed currently
  • Can be re-added later if a use case is identified

Option 2: Implement properly

  • Define actual switch use case (e.g., global power control, enable/disable routing)
  • Implement real functionality
  • Add to PLATFORMS list
  • Add tests

Option 3: Keep as placeholder

  • Document as placeholder for future use
  • Add clear comments explaining it's not functional
  • Keep excluded from PLATFORMS

Recommendation: Option 1 - Delete the file. No use case has been identified, and it can easily be recreated if needed.


Issue #5: Configuration Logger Reference

Current State

The development configuration file references the wrong package name:

Location: config/configuration.yaml

logger:
  logs:
    custom_components.integration_blueprint: debug  # ❌ WRONG

Should Be

logger:
  logs:
    custom_components.riverlink: debug  # ✅ CORRECT

Impact

  • Severity: Low (only affects development)
  • Developer Impact: Medium (debug logging doesn't work)
  • Debug logs don't appear when configuration.yaml is used
  • Developers must manually correct to see integration logs
  • Confusing for new contributors

Fix

Simple one-line change in config/configuration.yaml:

logger:
  logs:
-   custom_components.integration_blueprint: debug
+   custom_components.riverlink: debug

Combined Implementation

Both issues can be resolved together in a single PR:

Changes Required

  1. Delete custom_components/riverlink/switch.py
  2. Update config/configuration.yaml logger reference
  3. Optional: Add comment in README about proper debug logging

Testing

  • Verify switch.py removal doesn't affect integration loading
  • Verify debug logging works with corrected configuration
  • Run linting to ensure no issues
  • Test integration setup still works

Effort

  • Combined Effort: Trivial (< 30 minutes)
  • Complexity: Trivial
  • Good First Issue: Yes - Perfect for new contributors

Benefits

  • Cleaner Codebase: Remove confusing template code
  • Better Developer Experience: Debug logging works correctly
  • Less Confusion: Clear what code is active vs placeholder
  • Easier Onboarding: New contributors see clean, production code

References

  • See OPEN_ISSUES.md section "Known Bugs" for detailed context
  • Current switch.py file for removal
  • Current config/configuration.yaml for correction

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions