From dd266b7119d8bc3dcf58fd5ab9b766ee73d89530 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Fri, 14 Oct 2022 15:23:44 +0200 Subject: [PATCH] Remove elevation warning from sun (#80239) --- homeassistant/components/sun/__init__.py | 6 ------ tests/components/sun/test_init.py | 16 ++++------------ tests/components/sun/test_trigger.py | 2 +- tests/helpers/test_condition.py | 2 +- tests/helpers/test_event.py | 12 +++--------- 5 files changed, 9 insertions(+), 29 deletions(-) diff --git a/homeassistant/components/sun/__init__.py b/homeassistant/components/sun/__init__.py index 256df2f8971d..65836e0c619d 100644 --- a/homeassistant/components/sun/__init__.py +++ b/homeassistant/components/sun/__init__.py @@ -9,7 +9,6 @@ from astral.location import Elevation, Location from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ( - CONF_ELEVATION, EVENT_CORE_CONFIG_UPDATE, SUN_EVENT_SUNRISE, SUN_EVENT_SUNSET, @@ -82,11 +81,6 @@ _PHASE_UPDATES = { async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Track the state of the sun.""" - if config.get(CONF_ELEVATION) is not None: - _LOGGER.warning( - "Elevation is now configured in Home Assistant core. " - "See https://www.home-assistant.io/docs/configuration/basic/" - ) hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/sun/test_init.py b/tests/components/sun/test_init.py index 13aa6d487919..6f0f26f5f7ab 100644 --- a/tests/components/sun/test_init.py +++ b/tests/components/sun/test_init.py @@ -18,9 +18,7 @@ async def test_setting_rising(hass): """Test retrieving sun setting and rising.""" utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC) with freeze_time(utc_now): - await async_setup_component( - hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}} - ) + await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}}) await hass.async_block_till_done() state = hass.states.get(sun.ENTITY_ID) @@ -112,9 +110,7 @@ async def test_state_change(hass, caplog): """Test if the state changes at next setting/rising.""" now = datetime(2016, 6, 1, 8, 0, 0, tzinfo=dt_util.UTC) with freeze_time(now): - await async_setup_component( - hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}} - ) + await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}}) await hass.async_block_till_done() @@ -167,9 +163,7 @@ async def test_norway_in_june(hass): june = datetime(2016, 6, 1, tzinfo=dt_util.UTC) with patch("homeassistant.helpers.condition.dt_util.utcnow", return_value=june): - assert await async_setup_component( - hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}} - ) + assert await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}}) state = hass.states.get(sun.ENTITY_ID) assert state is not None @@ -195,9 +189,7 @@ async def test_state_change_count(hass): now = datetime(2016, 6, 1, tzinfo=dt_util.UTC) with freeze_time(now): - assert await async_setup_component( - hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}} - ) + assert await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}}) events = [] diff --git a/tests/components/sun/test_trigger.py b/tests/components/sun/test_trigger.py index 5f2275dca343..a2f0fca8b7e7 100644 --- a/tests/components/sun/test_trigger.py +++ b/tests/components/sun/test_trigger.py @@ -32,7 +32,7 @@ def setup_comp(hass): """Initialize components.""" mock_component(hass, "group") hass.loop.run_until_complete( - async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}}) + async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}}) ) diff --git a/tests/helpers/test_condition.py b/tests/helpers/test_condition.py index e31899559128..65db1291f9db 100644 --- a/tests/helpers/test_condition.py +++ b/tests/helpers/test_condition.py @@ -42,7 +42,7 @@ def setup_comp(hass): """Initialize components.""" hass.config.set_time_zone(hass.config.time_zone) hass.loop.run_until_complete( - async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}}) + async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}}) ) diff --git a/tests/helpers/test_event.py b/tests/helpers/test_event.py index 57b89e64cce4..536ccaaac680 100644 --- a/tests/helpers/test_event.py +++ b/tests/helpers/test_event.py @@ -3333,9 +3333,7 @@ async def test_track_sunrise(hass): # Setup sun component hass.config.latitude = latitude hass.config.longitude = longitude - assert await async_setup_component( - hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}} - ) + assert await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}}) location = LocationInfo( latitude=hass.config.latitude, longitude=hass.config.longitude @@ -3400,9 +3398,7 @@ async def test_track_sunrise_update_location(hass): # Setup sun component hass.config.latitude = 32.87336 hass.config.longitude = 117.22743 - assert await async_setup_component( - hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}} - ) + assert await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}}) location = LocationInfo( latitude=hass.config.latitude, longitude=hass.config.longitude @@ -3476,9 +3472,7 @@ async def test_track_sunset(hass): # Setup sun component hass.config.latitude = latitude hass.config.longitude = longitude - assert await async_setup_component( - hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}} - ) + assert await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}}) # Get next sunrise/sunset utc_now = datetime(2014, 5, 24, 12, 0, 0, tzinfo=dt_util.UTC)