1 """Silicon Labs Multiprotocol support."""
3 from __future__
import annotations
16 ZHA_CHANNEL_CHANGE_TIME_S = 10.27
20 """Return the ZHA radio path, or None if there's no ZHA config entry."""
21 with contextlib.suppress(ValueError):
22 return api.async_get_radio_path(hass)
27 """Get ZHA channel, or None if there's no ZHA config entry."""
28 zha_network_settings: api.NetworkBackup |
None
29 with contextlib.suppress(ValueError):
30 zha_network_settings = await api.async_get_network_settings(hass)
31 if not zha_network_settings:
33 channel: int = zha_network_settings.network_info.channel
35 return channel
or None
39 hass: HomeAssistant, channel: int, delay: float = 0
40 ) -> asyncio.Task |
None:
41 """Set the channel to be used.
43 Does nothing if not configured.
50 async
def finish_migration() -> None:
51 """Finish the channel migration."""
52 await asyncio.sleep(
max(0, delay - ZHA_CHANNEL_CHANGE_TIME_S))
53 return await api.async_change_channel(hass, channel)
55 return hass.async_create_task(finish_migration())
59 """Return the channel.
61 Returns None if not configured.
72 """Return if the multiprotocol device is used.
74 Returns False if not configured.
bool is_multiprotocol_url(str url)
bool async_using_multipan(HomeAssistant hass)
str|None _get_zha_url(HomeAssistant hass)
asyncio.Task|None async_change_channel(HomeAssistant hass, int channel, float delay=0)
int|None _get_zha_channel(HomeAssistant hass)
int|None async_get_channel(HomeAssistant hass)