Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dmulcahey committed Mar 20, 2024
1 parent 8054dbf commit 937742d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
3 changes: 1 addition & 2 deletions tests/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,7 @@ async def test_zha_group_light_entity(
assert device_3_light_entity is not None

assert (
device_1_entity_id != device_2_entity_id
and device_1_entity_id != device_3_entity_id
device_1_entity_id not in (device_2_entity_id, device_3_entity_id)
)
assert device_2_entity_id != device_3_entity_id

Expand Down
2 changes: 1 addition & 1 deletion tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ async def test_unsupported_attributes_sensor(
find_entity_ids(Platform.SENSOR, zha_device, omit=["lqi", "rssi"])
)
assert present_entity_ids == entity_ids
assert missing_entity_ids not in present_entity_ids
assert missing_entity_ids not in present_entity_ids # type: ignore[comparison-overlap]


@pytest.mark.parametrize(
Expand Down
6 changes: 3 additions & 3 deletions zha/application/platforms/light/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ async def async_update(self) -> None:
)
# check if transition started whilst waiting for polled state
if self.is_transitioning:
return
return # type: ignore #TODO figure this out

if state is not None:
self._state = state
Expand All @@ -910,7 +910,7 @@ async def async_update(self) -> None:
)
# check if transition started whilst waiting for polled state
if self.is_transitioning:
return
return # type: ignore #TODO figure this out
if level is not None:
self._brightness = level

Expand Down Expand Up @@ -946,7 +946,7 @@ async def async_update(self) -> None:
# for the polled attributes, so abort if we are transitioning,
# as that state will not be accurate
if self.is_transitioning:
return
return # type: ignore #TODO figure this out

if (color_mode := results.get("color_mode")) is not None:
if color_mode == Color.ColorMode.Color_temperature:
Expand Down
13 changes: 5 additions & 8 deletions zha/application/platforms/light/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,22 +357,19 @@ def color_xy_brightness_to_RGB(
b = X * 0.051713 - Y * 0.121364 + Z * 1.011530

# Apply reverse gamma correction.
r, g, b = map(
lambda x: (12.92 * x)
r, g, b = ((12.92 * x)
if (x <= 0.0031308)
else ((1.0 + 0.055) * cast(float, pow(x, (1.0 / 2.4))) - 0.055),
[r, g, b],
)
else ((1.0 + 0.055) * cast(float, pow(x, (1.0 / 2.4))) - 0.055) for x in [r, g, b])

# Bring all negative components to zero.
r, g, b = map(lambda x: max(0, x), [r, g, b])
r, g, b = (max(0, x) for x in [r, g, b])

# If one component is greater than 1, weight components by that value.
max_component = max(r, g, b)
if max_component > 1:
r, g, b = map(lambda x: x / max_component, [r, g, b])
r, g, b = (x / max_component for x in [r, g, b])

ir, ig, ib = map(lambda x: int(x * 255), [r, g, b])
ir, ig, ib = (int(x * 255) for x in [r, g, b])

return (ir, ig, ib)

Expand Down
1 change: 1 addition & 0 deletions zha/application/platforms/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class ZHAFirmwareUpdateEntity(
| UpdateEntityFeature.PROGRESS
| UpdateEntityFeature.SPECIFIC_VERSION
)
_attr_in_progress: bool | int = False

def __init__(
self,
Expand Down

0 comments on commit 937742d

Please sign in to comment.