Initialize Shelly runtime_data in async_setup_entry (#141315)

This commit is contained in:
Shay Levy 2025-03-25 16:43:48 +02:00 committed by GitHub
parent 3775f15461
commit 05ead4d1f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,6 +111,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ShellyConfigEntry) -> bool:
"""Set up Shelly from a config entry."""
entry.runtime_data = ShellyEntryData([])
# The custom component for Shelly devices uses shelly domain as well as core
# integration. If the user removes the custom component but doesn't remove the
# config entry, core integration will try to configure that config entry with an
@ -162,7 +164,8 @@ async def _async_setup_block_entry(
device_entry = None
sleep_period = entry.data.get(CONF_SLEEP_PERIOD)
runtime_data = entry.runtime_data = ShellyEntryData(BLOCK_SLEEPING_PLATFORMS)
runtime_data = entry.runtime_data
runtime_data.platforms = BLOCK_SLEEPING_PLATFORMS
# Some old firmware have a wrong sleep period hardcoded value.
# Following code block will force the right value for affected devices
@ -273,7 +276,8 @@ async def _async_setup_rpc_entry(hass: HomeAssistant, entry: ShellyConfigEntry)
device_entry = None
sleep_period = entry.data.get(CONF_SLEEP_PERIOD)
runtime_data = entry.runtime_data = ShellyEntryData(RPC_SLEEPING_PLATFORMS)
runtime_data = entry.runtime_data
runtime_data.platforms = RPC_SLEEPING_PLATFORMS
if sleep_period == 0:
# Not a sleeping device, finish setup