Skip to content

Commit 4f4c515

Browse files
authored
Refactor Shelly setup to use async_setup_entry_block for block entities (home-assistant#157517)
1 parent b031a08 commit 4f4c515

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

homeassistant/components/shelly/binary_sensor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
ShellyRpcAttributeEntity,
3131
ShellySleepingBlockAttributeEntity,
3232
ShellySleepingRpcAttributeEntity,
33-
async_setup_entry_attribute_entities,
33+
async_setup_entry_block,
3434
async_setup_entry_rest,
3535
async_setup_entry_rpc,
3636
)
@@ -372,15 +372,15 @@ def _async_setup_block_entry(
372372
) -> None:
373373
"""Set up entities for BLOCK device."""
374374
if config_entry.data[CONF_SLEEP_PERIOD]:
375-
async_setup_entry_attribute_entities(
375+
async_setup_entry_block(
376376
hass,
377377
config_entry,
378378
async_add_entities,
379379
SENSORS,
380380
BlockSleepingBinarySensor,
381381
)
382382
else:
383-
async_setup_entry_attribute_entities(
383+
async_setup_entry_block(
384384
hass,
385385
config_entry,
386386
async_add_entities,

homeassistant/components/shelly/cover.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
RpcEntityDescription,
2828
ShellyBlockAttributeEntity,
2929
ShellyRpcAttributeEntity,
30-
async_setup_entry_attribute_entities,
30+
async_setup_entry_block,
3131
async_setup_entry_rpc,
3232
rpc_call,
3333
)
@@ -81,7 +81,7 @@ def _async_setup_block_entry(
8181
coordinator = config_entry.runtime_data.block
8282
assert coordinator
8383

84-
async_setup_entry_attribute_entities(
84+
async_setup_entry_block(
8585
hass, config_entry, async_add_entities, BLOCK_COVERS, BlockShellyCover
8686
)
8787

homeassistant/components/shelly/entity.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434

3535

3636
@callback
37-
def async_setup_entry_attribute_entities(
37+
def async_setup_entry_block(
3838
hass: HomeAssistant,
3939
config_entry: ShellyConfigEntry,
4040
async_add_entities: AddEntitiesCallback,
4141
sensors: Mapping[tuple[str, str], BlockEntityDescription],
4242
sensor_class: Callable,
4343
) -> None:
44-
"""Set up entities for attributes."""
44+
"""Set up block entities."""
4545
coordinator = config_entry.runtime_data.block
4646
assert coordinator
4747
if coordinator.device.initialized:
@@ -150,7 +150,7 @@ def async_setup_entry_rpc(
150150
sensors: Mapping[str, RpcEntityDescription],
151151
sensor_class: Callable,
152152
) -> None:
153-
"""Set up entities for RPC sensors."""
153+
"""Set up RPC entities."""
154154
coordinator = config_entry.runtime_data.rpc
155155
assert coordinator
156156

homeassistant/components/shelly/light.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
RpcEntityDescription,
4545
ShellyBlockAttributeEntity,
4646
ShellyRpcAttributeEntity,
47-
async_setup_entry_attribute_entities,
47+
async_setup_entry_block,
4848
async_setup_entry_rpc,
4949
)
5050
from .utils import (
@@ -101,7 +101,7 @@ def _async_setup_block_entry(
101101
coordinator = config_entry.runtime_data.block
102102
assert coordinator
103103

104-
async_setup_entry_attribute_entities(
104+
async_setup_entry_block(
105105
hass, config_entry, async_add_entities, BLOCK_LIGHTS, BlockShellyLight
106106
)
107107

homeassistant/components/shelly/number.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
RpcEntityDescription,
4343
ShellyRpcAttributeEntity,
4444
ShellySleepingBlockAttributeEntity,
45-
async_setup_entry_attribute_entities,
45+
async_setup_entry_block,
4646
async_setup_entry_rpc,
4747
rpc_call,
4848
)
@@ -353,7 +353,7 @@ def _async_setup_block_entry(
353353
) -> None:
354354
"""Set up entities for BLOCK device."""
355355
if config_entry.data[CONF_SLEEP_PERIOD]:
356-
async_setup_entry_attribute_entities(
356+
async_setup_entry_block(
357357
hass,
358358
config_entry,
359359
async_add_entities,

homeassistant/components/shelly/sensor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
ShellyRpcAttributeEntity,
5454
ShellySleepingBlockAttributeEntity,
5555
ShellySleepingRpcAttributeEntity,
56-
async_setup_entry_attribute_entities,
56+
async_setup_entry_block,
5757
async_setup_entry_rest,
5858
async_setup_entry_rpc,
5959
get_entity_rpc_device_info,
@@ -1736,15 +1736,15 @@ def _async_setup_block_entry(
17361736
) -> None:
17371737
"""Set up entities for BLOCK device."""
17381738
if config_entry.data[CONF_SLEEP_PERIOD]:
1739-
async_setup_entry_attribute_entities(
1739+
async_setup_entry_block(
17401740
hass,
17411741
config_entry,
17421742
async_add_entities,
17431743
SENSORS,
17441744
BlockSleepingSensor,
17451745
)
17461746
else:
1747-
async_setup_entry_attribute_entities(
1747+
async_setup_entry_block(
17481748
hass,
17491749
config_entry,
17501750
async_add_entities,

homeassistant/components/shelly/switch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
ShellyBlockAttributeEntity,
3737
ShellyRpcAttributeEntity,
3838
ShellySleepingBlockAttributeEntity,
39-
async_setup_entry_attribute_entities,
39+
async_setup_entry_block,
4040
async_setup_entry_rpc,
4141
rpc_call,
4242
)
@@ -337,11 +337,11 @@ def _async_setup_block_entry(
337337
coordinator = config_entry.runtime_data.block
338338
assert coordinator
339339

340-
async_setup_entry_attribute_entities(
340+
async_setup_entry_block(
341341
hass, config_entry, async_add_entities, BLOCK_RELAY_SWITCHES, BlockRelaySwitch
342342
)
343343

344-
async_setup_entry_attribute_entities(
344+
async_setup_entry_block(
345345
hass,
346346
config_entry,
347347
async_add_entities,

0 commit comments

Comments
 (0)