Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/zha/core/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def group_removed(self, zigpy_group):

def _send_group_gateway_message(self, zigpy_group, gateway_message_type):
"""Send the gareway event for a zigpy group event."""
zha_group = self._groups.get(zigpy_group.group_id, None)
zha_group = self._groups.get(zigpy_group.group_id)
if zha_group is not None:
async_dispatcher_send(
self._hass,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/zha/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ async def async_get_state(self, from_cache=True):
):
self._color_temp = results["color_temperature"]

color_x = results.get("color_x", None)
color_y = results.get("color_y", None)
color_x = results.get("color_x")
color_y = results.get("color_y")
if color_x is not None and color_y is not None:
self._hs_color = color_util.color_xy_to_hs(
float(color_x / 65535), float(color_y / 65535)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/zha/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ async def async_state_attr_provider(self):
state_attrs = {}
attributes = ["battery_size", "battery_quantity"]
results = await self._channel.get_attributes(attributes)
battery_size = results.get("battery_size", None)
battery_size = results.get("battery_size")
if battery_size is not None:
state_attrs["battery_size"] = BATTERY_SIZES.get(battery_size, "Unknown")
battery_quantity = results.get("battery_quantity", None)
battery_quantity = results.get("battery_quantity")
if battery_quantity is not None:
state_attrs["battery_quantity"] = battery_quantity
return state_attrs
Expand Down
1 change: 0 additions & 1 deletion tests/components/zha/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ async def _zha_device(zigpy_dev):
zigpy_app_controller.devices[zigpy_dev.ieee] = zigpy_dev
await setup_zha()
zha_gateway = hass.data[zha_const.DATA_ZHA][zha_const.DATA_ZHA_GATEWAY]
await zha_gateway.async_load_devices()
return zha_gateway.get_device(zigpy_dev.ieee)

return _zha_device
Expand Down
22 changes: 10 additions & 12 deletions tests/components/zha/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import timedelta
from unittest.mock import MagicMock, call, sentinel

import asynctest
from asynctest import CoroutineMock, patch
import pytest
import zigpy.profiles.zha
import zigpy.types
Expand Down Expand Up @@ -67,9 +67,7 @@
}


@asynctest.mock.patch(
"zigpy.zcl.clusters.general.OnOff.read_attributes", new=MagicMock()
)
@patch("zigpy.zcl.clusters.general.OnOff.read_attributes", new=MagicMock())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@MartinHjelmare is this what you meant in the other PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, thanks. 👍

async def test_light_refresh(hass, zigpy_device_mock, zha_device_joined_restored):
"""Test zha light platform refresh."""

Expand Down Expand Up @@ -107,21 +105,21 @@ async def test_light_refresh(hass, zigpy_device_mock, zha_device_joined_restored
assert hass.states.get(entity_id).state == STATE_OFF


@asynctest.patch(
@patch(
"zigpy.zcl.clusters.lighting.Color.request",
new=asynctest.CoroutineMock(return_value=[sentinel.data, zcl_f.Status.SUCCESS]),
new=CoroutineMock(return_value=[sentinel.data, zcl_f.Status.SUCCESS]),
)
@asynctest.patch(
@patch(
"zigpy.zcl.clusters.general.Identify.request",
new=asynctest.CoroutineMock(return_value=[sentinel.data, zcl_f.Status.SUCCESS]),
new=CoroutineMock(return_value=[sentinel.data, zcl_f.Status.SUCCESS]),
)
@asynctest.patch(
@patch(
"zigpy.zcl.clusters.general.LevelControl.request",
new=asynctest.CoroutineMock(return_value=[sentinel.data, zcl_f.Status.SUCCESS]),
new=CoroutineMock(return_value=[sentinel.data, zcl_f.Status.SUCCESS]),
)
@asynctest.patch(
@patch(
"zigpy.zcl.clusters.general.OnOff.request",
new=asynctest.CoroutineMock(return_value=[sentinel.data, zcl_f.Status.SUCCESS]),
new=CoroutineMock(return_value=[sentinel.data, zcl_f.Status.SUCCESS]),
)
@pytest.mark.parametrize(
"device, reporting",
Expand Down