mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Improve Vizio fix to avoid KeyError (#32163)
* dont set default volume_step on import check * ensure config entry data['volume_step'] is set * consolidate entry update during entry setup
This commit is contained in:
parent
71a6ea1c10
commit
4236d62b44
@ -180,11 +180,8 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
if entry.data[CONF_NAME] != import_config[CONF_NAME]:
|
if entry.data[CONF_NAME] != import_config[CONF_NAME]:
|
||||||
updated_name[CONF_NAME] = import_config[CONF_NAME]
|
updated_name[CONF_NAME] = import_config[CONF_NAME]
|
||||||
|
|
||||||
import_volume_step = import_config.get(
|
if entry.data.get(CONF_VOLUME_STEP) != import_config[CONF_VOLUME_STEP]:
|
||||||
CONF_VOLUME_STEP, DEFAULT_VOLUME_STEP
|
updated_options[CONF_VOLUME_STEP] = import_config[CONF_VOLUME_STEP]
|
||||||
)
|
|
||||||
if entry.data.get(CONF_VOLUME_STEP) != import_volume_step:
|
|
||||||
updated_options[CONF_VOLUME_STEP] = import_volume_step
|
|
||||||
|
|
||||||
if updated_options or updated_name:
|
if updated_options or updated_name:
|
||||||
new_data = entry.data.copy()
|
new_data = entry.data.copy()
|
||||||
|
@ -56,10 +56,18 @@ async def async_setup_entry(
|
|||||||
volume_step = config_entry.options.get(
|
volume_step = config_entry.options.get(
|
||||||
CONF_VOLUME_STEP, config_entry.data.get(CONF_VOLUME_STEP, DEFAULT_VOLUME_STEP),
|
CONF_VOLUME_STEP, config_entry.data.get(CONF_VOLUME_STEP, DEFAULT_VOLUME_STEP),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
params = {}
|
||||||
if not config_entry.options:
|
if not config_entry.options:
|
||||||
hass.config_entries.async_update_entry(
|
params["options"] = {CONF_VOLUME_STEP: volume_step}
|
||||||
config_entry, options={CONF_VOLUME_STEP: volume_step}
|
|
||||||
)
|
if not config_entry.data.get(CONF_VOLUME_STEP):
|
||||||
|
new_data = config_entry.data.copy()
|
||||||
|
new_data.update({CONF_VOLUME_STEP: volume_step})
|
||||||
|
params["data"] = new_data
|
||||||
|
|
||||||
|
if params:
|
||||||
|
hass.config_entries.async_update_entry(config_entry, **params)
|
||||||
|
|
||||||
device = VizioAsync(
|
device = VizioAsync(
|
||||||
DEVICE_ID,
|
DEVICE_ID,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user