mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
Initialize Shelly runtime_data in async_setup_entry (#141315)
This commit is contained in:
parent
3775f15461
commit
05ead4d1f5
@ -111,6 +111,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ShellyConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ShellyConfigEntry) -> bool:
|
||||||
"""Set up Shelly from a config entry."""
|
"""Set up Shelly from a config entry."""
|
||||||
|
entry.runtime_data = ShellyEntryData([])
|
||||||
|
|
||||||
# The custom component for Shelly devices uses shelly domain as well as core
|
# 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
|
# 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
|
# 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
|
device_entry = None
|
||||||
|
|
||||||
sleep_period = entry.data.get(CONF_SLEEP_PERIOD)
|
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.
|
# Some old firmware have a wrong sleep period hardcoded value.
|
||||||
# Following code block will force the right value for affected devices
|
# 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
|
device_entry = None
|
||||||
|
|
||||||
sleep_period = entry.data.get(CONF_SLEEP_PERIOD)
|
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:
|
if sleep_period == 0:
|
||||||
# Not a sleeping device, finish setup
|
# Not a sleeping device, finish setup
|
||||||
|
Loading…
x
Reference in New Issue
Block a user