Skip to content

Commit 47e8e7c

Browse files
author
Tom Lasswell
committed
fix: Clean up unused imports and format code
- Remove unused SEGMENT_MODE_DISABLED import from __init__.py - Remove unused SEGMENT_MODE_DISABLED import from light.py - Remove unused enable_segments_old variable from __init__.py - Fix indentation issue in config_flow.py logging - Update tests to remove unused CONF_SEGMENT_MODE imports - Update test expectations for per-device-only configuration
1 parent 7af985c commit 47e8e7c

File tree

4 files changed

+10
-25
lines changed

4 files changed

+10
-25
lines changed

custom_components/govee/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
DOMAIN,
3434
KEY_IOT_CREDENTIALS,
3535
KEY_IOT_LOGIN_FAILED,
36-
SEGMENT_MODE_DISABLED,
3736
SEGMENT_MODE_GROUPED,
3837
SEGMENT_MODE_INDIVIDUAL,
3938
SUFFIX_DIY_SCENE_SELECT,
@@ -260,8 +259,6 @@ async def _async_cleanup_orphaned_entities(
260259
# Get current options
261260
options = entry.options
262261
device_modes = options.get("segment_mode_by_device", {})
263-
# For backward compatibility, check old enable_segments boolean
264-
enable_segments_old = options.get(CONF_ENABLE_SEGMENTS, DEFAULT_ENABLE_SEGMENTS)
265262
enable_scenes = options.get(CONF_ENABLE_SCENES, DEFAULT_ENABLE_SCENES)
266263
enable_diy_scenes = options.get(CONF_ENABLE_DIY_SCENES, DEFAULT_ENABLE_DIY_SCENES)
267264

custom_components/govee/config_flow.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,11 @@ async def async_step_select_segment_devices(
507507
if user_input is not None:
508508
# User selected devices to configure
509509
self._selected_devices = user_input.get("devices", list(rgbic_devices.keys()))
510-
_LOGGER.debug("Selected %d devices for per-device configuration: %s",
511-
len(self._selected_devices), self._selected_devices)
510+
_LOGGER.debug(
511+
"Selected %d devices for per-device configuration: %s",
512+
len(self._selected_devices),
513+
self._selected_devices,
514+
)
512515

513516
if self._selected_devices:
514517
return await self.async_step_configure_device_modes()

custom_components/govee/light.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from homeassistant.helpers.restore_state import RestoreEntity
2727

2828
from .const import (
29-
SEGMENT_MODE_DISABLED,
3029
SEGMENT_MODE_GROUPED,
3130
SEGMENT_MODE_INDIVIDUAL,
3231
)

tests/test_config_flow.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ class TestPerDeviceSegmentMode:
494494
def test_device_mode_structure(self):
495495
"""Test per-device segment mode data structure."""
496496
from custom_components.govee.const import (
497-
CONF_SEGMENT_MODE,
498497
SEGMENT_MODE_DISABLED,
499498
SEGMENT_MODE_GROUPED,
500499
SEGMENT_MODE_INDIVIDUAL,
@@ -517,7 +516,6 @@ def test_device_mode_structure(self):
517516
def test_device_mode_fallback_to_global(self):
518517
"""Test fallback to global mode when device not in per-device config."""
519518
from custom_components.govee.const import (
520-
CONF_SEGMENT_MODE,
521519
SEGMENT_MODE_INDIVIDUAL,
522520
)
523521

@@ -606,7 +604,6 @@ def test_segment_suffix_matching_grouped_vs_individual(self):
606604
def test_empty_device_modes_uses_global(self):
607605
"""Test empty per-device dict falls back to global for all devices."""
608606
from custom_components.govee.const import (
609-
CONF_SEGMENT_MODE,
610607
DEFAULT_SEGMENT_MODE,
611608
)
612609

@@ -624,37 +621,26 @@ def test_empty_device_modes_uses_global(self):
624621
def test_migration_preserves_existing_devices(self):
625622
"""Test migration from global to per-device preserves existing config."""
626623
from custom_components.govee.const import (
627-
CONF_SEGMENT_MODE,
628624
SEGMENT_MODE_GROUPED,
629625
SEGMENT_MODE_INDIVIDUAL,
630626
)
631627

632-
# Original entry with global setting
633-
old_options = {
634-
CONF_SEGMENT_MODE: SEGMENT_MODE_GROUPED,
635-
}
636-
637-
# After adding per-device config
628+
# Options with per-device config
638629
new_options = {
639-
**old_options,
640630
"segment_mode_by_device": {
641631
"AA:BB:CC:DD:EE:FF:00:01": SEGMENT_MODE_INDIVIDUAL,
642632
},
643633
}
644634

645-
# Devices not in per-device config should use global
646-
global_mode = new_options[CONF_SEGMENT_MODE]
647-
assert global_mode == SEGMENT_MODE_GROUPED
648-
649635
# Device with specific config should use that
650636
device_modes = new_options.get("segment_mode_by_device", {})
651637
device_mode = device_modes.get(
652-
"AA:BB:CC:DD:EE:FF:00:01", global_mode
638+
"AA:BB:CC:DD:EE:FF:00:01", SEGMENT_MODE_GROUPED
653639
)
654640
assert device_mode == SEGMENT_MODE_INDIVIDUAL
655641

656-
# Unknown device should use global
642+
# Unknown device should use default (individual)
657643
unknown_mode = device_modes.get(
658-
"AA:BB:CC:DD:EE:FF:00:99", global_mode
644+
"AA:BB:CC:DD:EE:FF:00:99", SEGMENT_MODE_INDIVIDUAL
659645
)
660-
assert unknown_mode == SEGMENT_MODE_GROUPED
646+
assert unknown_mode == SEGMENT_MODE_INDIVIDUAL

0 commit comments

Comments
 (0)