Skip to content

Commit cf6800c

Browse files
committed
Reviews
1 parent 3a107ff commit cf6800c

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

homeassistant/components/eheimdigital/coordinator.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from eheimdigital.types import EheimDeviceType
1111

1212
from homeassistant.config_entries import ConfigEntry
13-
from homeassistant.const import CONF_HOST, Platform
13+
from homeassistant.const import CONF_HOST
1414
from homeassistant.core import HomeAssistant
1515
from homeassistant.helpers.aiohttp_client import async_get_clientsession
1616
from homeassistant.helpers.entity_component import DEFAULT_SCAN_INTERVAL
@@ -26,7 +26,7 @@ class EheimDigitalUpdateCoordinator(
2626
):
2727
"""The EHEIM Digital data update coordinator."""
2828

29-
platform_callbacks: dict[Platform, AsyncSetupDeviceEntitiesCallback]
29+
platform_callbacks: set[AsyncSetupDeviceEntitiesCallback]
3030
config_entry: ConfigEntry
3131
hub: EheimDigitalHub
3232
known_devices: set[str]
@@ -44,16 +44,14 @@ def __init__(self, hass: HomeAssistant) -> None:
4444
device_found_callback=self._async_device_found,
4545
)
4646
self.known_devices = set()
47-
self.platform_callbacks = {}
47+
self.platform_callbacks = set()
4848

4949
def add_platform_callback(
5050
self,
51-
platform: Platform,
5251
async_setup_device_entities: AsyncSetupDeviceEntitiesCallback,
5352
) -> None:
5453
"""Add the setup callbacks from a specific platform."""
55-
if platform not in self.platform_callbacks:
56-
self.platform_callbacks[platform] = async_setup_device_entities
54+
self.platform_callbacks.add(async_setup_device_entities)
5755

5856
async def _async_device_found(
5957
self, device_address: str, device_type: EheimDeviceType
@@ -64,7 +62,7 @@ async def _async_device_found(
6462
"""
6563

6664
if device_address not in self.known_devices:
67-
for platform_callback in self.platform_callbacks.values():
65+
for platform_callback in self.platform_callbacks:
6866
await platform_callback(device_address)
6967

7068
async def _async_receive_callback(self) -> None:

homeassistant/components/eheimdigital/light.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
LightEntity,
1414
LightEntityFeature,
1515
)
16-
from homeassistant.const import Platform
1716
from homeassistant.core import HomeAssistant
1817
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1918
from homeassistant.util.color import brightness_to_value, value_to_brightness
@@ -48,7 +47,10 @@ async def async_setup_device_entities(device_address: str) -> None:
4847
coordinator.known_devices.add(device.mac_address)
4948
async_add_entities(entities)
5049

51-
coordinator.add_platform_callback(Platform.LIGHT, async_setup_device_entities)
50+
coordinator.add_platform_callback(async_setup_device_entities)
51+
52+
for device_address in entry.runtime_data.hub.devices:
53+
await async_setup_device_entities(device_address)
5254

5355

5456
class EheimDigitalClassicLEDControlLight(

tests/components/eheimdigital/test_light.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ async def test_setup_classic_led_ctrl(
5353

5454
with patch("homeassistant.components.eheimdigital.PLATFORMS", [Platform.LIGHT]):
5555
await hass.config_entries.async_setup(mock_config_entry.entry_id)
56-
await mock_config_entry.runtime_data._async_device_found(
56+
57+
await eheimdigital_hub_mock.call_args.kwargs["device_found_callback"](
5758
"00:00:00:00:00:01", EheimDeviceType.VERSION_EHEIM_CLASSIC_LED_CTRL_PLUS_E
5859
)
5960
await hass.async_block_till_done()
@@ -143,7 +144,7 @@ async def test_turn_on_brightness(
143144

144145
with patch("homeassistant.components.eheimdigital.PLATFORMS", [Platform.LIGHT]):
145146
await hass.config_entries.async_setup(mock_config_entry.entry_id)
146-
await mock_config_entry.runtime_data._async_device_found(
147+
await eheimdigital_hub_mock.call_args.kwargs["device_found_callback"](
147148
"00:00:00:00:00:01", EheimDeviceType.VERSION_EHEIM_CLASSIC_LED_CTRL_PLUS_E
148149
)
149150
await hass.async_block_till_done()
@@ -180,7 +181,7 @@ async def test_turn_on_effect(
180181

181182
with patch("homeassistant.components.eheimdigital.PLATFORMS", [Platform.LIGHT]):
182183
await hass.config_entries.async_setup(mock_config_entry.entry_id)
183-
await mock_config_entry.runtime_data._async_device_found(
184+
await eheimdigital_hub_mock.call_args.kwargs["device_found_callback"](
184185
"00:00:00:00:00:01", EheimDeviceType.VERSION_EHEIM_CLASSIC_LED_CTRL_PLUS_E
185186
)
186187
await hass.async_block_till_done()
@@ -216,7 +217,7 @@ async def test_state_update(
216217

217218
with patch("homeassistant.components.eheimdigital.PLATFORMS", [Platform.LIGHT]):
218219
await hass.config_entries.async_setup(mock_config_entry.entry_id)
219-
await mock_config_entry.runtime_data._async_device_found(
220+
await eheimdigital_hub_mock.call_args.kwargs["device_found_callback"](
220221
"00:00:00:00:00:01", EheimDeviceType.VERSION_EHEIM_CLASSIC_LED_CTRL_PLUS_E
221222
)
222223
await hass.async_block_till_done()

0 commit comments

Comments
 (0)