mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Don't import google calendar user pref for disabling new entities (#72652)
This commit is contained in:
parent
afcc8679dd
commit
79340f85d2
@ -199,11 +199,18 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Configuration of Google Calendar in YAML in configuration.yaml is "
|
"Configuration of Google Calendar in YAML in configuration.yaml is "
|
||||||
"is deprecated and will be removed in a future release; Your existing "
|
"is deprecated and will be removed in a future release; Your existing "
|
||||||
"OAuth Application Credentials and other settings have been imported "
|
"OAuth Application Credentials and access settings have been imported "
|
||||||
"into the UI automatically and can be safely removed from your "
|
"into the UI automatically and can be safely removed from your "
|
||||||
"configuration.yaml file"
|
"configuration.yaml file"
|
||||||
)
|
)
|
||||||
|
if conf.get(CONF_TRACK_NEW) is False:
|
||||||
|
# The track_new as False would previously result in new entries
|
||||||
|
# in google_calendars.yaml with track set to Fasle which is
|
||||||
|
# handled at calendar entity creation time.
|
||||||
|
_LOGGER.warning(
|
||||||
|
"You must manually set the integration System Options in the "
|
||||||
|
"UI to disable newly discovered entities going forward"
|
||||||
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -260,23 +267,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
def async_upgrade_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
def async_upgrade_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
"""Upgrade the config entry if needed."""
|
"""Upgrade the config entry if needed."""
|
||||||
if DATA_CONFIG not in hass.data[DOMAIN] and entry.options:
|
if entry.options:
|
||||||
return
|
return
|
||||||
|
|
||||||
options = (
|
|
||||||
entry.options
|
|
||||||
if entry.options
|
|
||||||
else {
|
|
||||||
CONF_CALENDAR_ACCESS: get_feature_access(hass).name,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
disable_new_entities = (
|
|
||||||
not hass.data[DOMAIN].get(DATA_CONFIG, {}).get(CONF_TRACK_NEW, True)
|
|
||||||
)
|
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
entry,
|
entry,
|
||||||
options=options,
|
options={
|
||||||
pref_disable_new_entities=disable_new_entities,
|
CONF_CALENDAR_ACCESS: get_feature_access(hass).name,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,57 +154,6 @@ async def test_calendar_yaml_error(
|
|||||||
assert hass.states.get(TEST_API_ENTITY)
|
assert hass.states.get(TEST_API_ENTITY)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
"google_config_track_new,calendars_config,expected_state",
|
|
||||||
[
|
|
||||||
(
|
|
||||||
None,
|
|
||||||
[],
|
|
||||||
State(
|
|
||||||
TEST_API_ENTITY,
|
|
||||||
STATE_OFF,
|
|
||||||
attributes={
|
|
||||||
"offset_reached": False,
|
|
||||||
"friendly_name": TEST_API_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
True,
|
|
||||||
[],
|
|
||||||
State(
|
|
||||||
TEST_API_ENTITY,
|
|
||||||
STATE_OFF,
|
|
||||||
attributes={
|
|
||||||
"offset_reached": False,
|
|
||||||
"friendly_name": TEST_API_ENTITY_NAME,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(False, [], None),
|
|
||||||
],
|
|
||||||
ids=["default", "True", "False"],
|
|
||||||
)
|
|
||||||
async def test_track_new(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
component_setup: ComponentSetup,
|
|
||||||
mock_calendars_list: ApiResult,
|
|
||||||
test_api_calendar: dict[str, Any],
|
|
||||||
mock_events_list: ApiResult,
|
|
||||||
mock_calendars_yaml: None,
|
|
||||||
expected_state: State,
|
|
||||||
setup_config_entry: MockConfigEntry,
|
|
||||||
) -> None:
|
|
||||||
"""Test behavior of configuration.yaml settings for tracking new calendars not in the config."""
|
|
||||||
|
|
||||||
mock_calendars_list({"items": [test_api_calendar]})
|
|
||||||
mock_events_list({})
|
|
||||||
assert await component_setup()
|
|
||||||
|
|
||||||
state = hass.states.get(TEST_API_ENTITY)
|
|
||||||
assert_state(state, expected_state)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("calendars_config", [[]])
|
@pytest.mark.parametrize("calendars_config", [[]])
|
||||||
async def test_found_calendar_from_api(
|
async def test_found_calendar_from_api(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -263,7 +212,7 @@ async def test_load_application_credentials(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"calendars_config_track,expected_state",
|
"calendars_config_track,expected_state,google_config_track_new",
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
True,
|
True,
|
||||||
@ -275,8 +224,35 @@ async def test_load_application_credentials(
|
|||||||
"friendly_name": TEST_YAML_ENTITY_NAME,
|
"friendly_name": TEST_YAML_ENTITY_NAME,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
None,
|
||||||
),
|
),
|
||||||
(False, None),
|
(
|
||||||
|
True,
|
||||||
|
State(
|
||||||
|
TEST_YAML_ENTITY,
|
||||||
|
STATE_OFF,
|
||||||
|
attributes={
|
||||||
|
"offset_reached": False,
|
||||||
|
"friendly_name": TEST_YAML_ENTITY_NAME,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
True,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
True,
|
||||||
|
State(
|
||||||
|
TEST_YAML_ENTITY,
|
||||||
|
STATE_OFF,
|
||||||
|
attributes={
|
||||||
|
"offset_reached": False,
|
||||||
|
"friendly_name": TEST_YAML_ENTITY_NAME,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
False, # Has no effect
|
||||||
|
),
|
||||||
|
(False, None, None),
|
||||||
|
(False, None, True),
|
||||||
|
(False, None, False),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_calendar_config_track_new(
|
async def test_calendar_config_track_new(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user