mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Use single list for Shelly non-sleeping platforms (#119540)
This commit is contained in:
parent
87ddb02828
commit
efa7240ac5
@ -54,9 +54,10 @@ from .utils import (
|
|||||||
get_ws_context,
|
get_ws_context,
|
||||||
)
|
)
|
||||||
|
|
||||||
BLOCK_PLATFORMS: Final = [
|
PLATFORMS: Final = [
|
||||||
Platform.BINARY_SENSOR,
|
Platform.BINARY_SENSOR,
|
||||||
Platform.BUTTON,
|
Platform.BUTTON,
|
||||||
|
Platform.CLIMATE,
|
||||||
Platform.COVER,
|
Platform.COVER,
|
||||||
Platform.EVENT,
|
Platform.EVENT,
|
||||||
Platform.LIGHT,
|
Platform.LIGHT,
|
||||||
@ -72,17 +73,6 @@ BLOCK_SLEEPING_PLATFORMS: Final = [
|
|||||||
Platform.SENSOR,
|
Platform.SENSOR,
|
||||||
Platform.SWITCH,
|
Platform.SWITCH,
|
||||||
]
|
]
|
||||||
RPC_PLATFORMS: Final = [
|
|
||||||
Platform.BINARY_SENSOR,
|
|
||||||
Platform.BUTTON,
|
|
||||||
Platform.CLIMATE,
|
|
||||||
Platform.COVER,
|
|
||||||
Platform.EVENT,
|
|
||||||
Platform.LIGHT,
|
|
||||||
Platform.SENSOR,
|
|
||||||
Platform.SWITCH,
|
|
||||||
Platform.UPDATE,
|
|
||||||
]
|
|
||||||
RPC_SLEEPING_PLATFORMS: Final = [
|
RPC_SLEEPING_PLATFORMS: Final = [
|
||||||
Platform.BINARY_SENSOR,
|
Platform.BINARY_SENSOR,
|
||||||
Platform.SENSOR,
|
Platform.SENSOR,
|
||||||
@ -194,7 +184,7 @@ async def _async_setup_block_entry(
|
|||||||
shelly_entry_data.block = ShellyBlockCoordinator(hass, entry, device)
|
shelly_entry_data.block = ShellyBlockCoordinator(hass, entry, device)
|
||||||
shelly_entry_data.block.async_setup()
|
shelly_entry_data.block.async_setup()
|
||||||
shelly_entry_data.rest = ShellyRestCoordinator(hass, device, entry)
|
shelly_entry_data.rest = ShellyRestCoordinator(hass, device, entry)
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, BLOCK_PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
elif sleep_period is None or device_entry is None:
|
elif sleep_period is None or device_entry is None:
|
||||||
# Need to get sleep info or first time sleeping device setup, wait for device
|
# Need to get sleep info or first time sleeping device setup, wait for device
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
@ -264,7 +254,7 @@ async def _async_setup_rpc_entry(hass: HomeAssistant, entry: ShellyConfigEntry)
|
|||||||
shelly_entry_data.rpc = ShellyRpcCoordinator(hass, entry, device)
|
shelly_entry_data.rpc = ShellyRpcCoordinator(hass, entry, device)
|
||||||
shelly_entry_data.rpc.async_setup()
|
shelly_entry_data.rpc.async_setup()
|
||||||
shelly_entry_data.rpc_poll = ShellyRpcPollingCoordinator(hass, entry, device)
|
shelly_entry_data.rpc_poll = ShellyRpcPollingCoordinator(hass, entry, device)
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, RPC_PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
elif sleep_period is None or device_entry is None:
|
elif sleep_period is None or device_entry is None:
|
||||||
# Need to get sleep info or first time sleeping device setup, wait for device
|
# Need to get sleep info or first time sleeping device setup, wait for device
|
||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
@ -290,12 +280,12 @@ async def _async_setup_rpc_entry(hass: HomeAssistant, entry: ShellyConfigEntry)
|
|||||||
async def async_unload_entry(hass: HomeAssistant, entry: ShellyConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ShellyConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
shelly_entry_data = entry.runtime_data
|
shelly_entry_data = entry.runtime_data
|
||||||
|
platforms = PLATFORMS
|
||||||
platforms = RPC_SLEEPING_PLATFORMS
|
|
||||||
if not entry.data.get(CONF_SLEEP_PERIOD):
|
|
||||||
platforms = RPC_PLATFORMS
|
|
||||||
|
|
||||||
if get_device_entry_gen(entry) in RPC_GENERATIONS:
|
if get_device_entry_gen(entry) in RPC_GENERATIONS:
|
||||||
|
if entry.data.get(CONF_SLEEP_PERIOD):
|
||||||
|
platforms = RPC_SLEEPING_PLATFORMS
|
||||||
|
|
||||||
if unload_ok := await hass.config_entries.async_unload_platforms(
|
if unload_ok := await hass.config_entries.async_unload_platforms(
|
||||||
entry, platforms
|
entry, platforms
|
||||||
):
|
):
|
||||||
@ -312,11 +302,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ShellyConfigEntry) -> b
|
|||||||
hass, DOMAIN, PUSH_UPDATE_ISSUE_ID.format(unique=entry.unique_id)
|
hass, DOMAIN, PUSH_UPDATE_ISSUE_ID.format(unique=entry.unique_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
platforms = BLOCK_SLEEPING_PLATFORMS
|
if entry.data.get(CONF_SLEEP_PERIOD):
|
||||||
|
platforms = BLOCK_SLEEPING_PLATFORMS
|
||||||
if not entry.data.get(CONF_SLEEP_PERIOD):
|
|
||||||
shelly_entry_data.rest = None
|
|
||||||
platforms = BLOCK_PLATFORMS
|
|
||||||
|
|
||||||
if unload_ok := await hass.config_entries.async_unload_platforms(entry, platforms):
|
if unload_ok := await hass.config_entries.async_unload_platforms(entry, platforms):
|
||||||
if shelly_entry_data.block:
|
if shelly_entry_data.block:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user