Remove elevation warning from sun (#80239)
This commit is contained in:
parent
4c3097a157
commit
dd266b7119
5 changed files with 9 additions and 29 deletions
|
@ -9,7 +9,6 @@ from astral.location import Elevation, Location
|
||||||
|
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_ELEVATION,
|
|
||||||
EVENT_CORE_CONFIG_UPDATE,
|
EVENT_CORE_CONFIG_UPDATE,
|
||||||
SUN_EVENT_SUNRISE,
|
SUN_EVENT_SUNRISE,
|
||||||
SUN_EVENT_SUNSET,
|
SUN_EVENT_SUNSET,
|
||||||
|
@ -82,11 +81,6 @@ _PHASE_UPDATES = {
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Track the state of the sun."""
|
"""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.async_create_task(
|
||||||
hass.config_entries.flow.async_init(
|
hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
|
|
@ -18,9 +18,7 @@ async def test_setting_rising(hass):
|
||||||
"""Test retrieving sun setting and rising."""
|
"""Test retrieving sun setting and rising."""
|
||||||
utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC)
|
utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC)
|
||||||
with freeze_time(utc_now):
|
with freeze_time(utc_now):
|
||||||
await async_setup_component(
|
await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}})
|
||||||
hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}}
|
|
||||||
)
|
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
state = hass.states.get(sun.ENTITY_ID)
|
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."""
|
"""Test if the state changes at next setting/rising."""
|
||||||
now = datetime(2016, 6, 1, 8, 0, 0, tzinfo=dt_util.UTC)
|
now = datetime(2016, 6, 1, 8, 0, 0, tzinfo=dt_util.UTC)
|
||||||
with freeze_time(now):
|
with freeze_time(now):
|
||||||
await async_setup_component(
|
await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}})
|
||||||
hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}}
|
|
||||||
)
|
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
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)
|
june = datetime(2016, 6, 1, tzinfo=dt_util.UTC)
|
||||||
|
|
||||||
with patch("homeassistant.helpers.condition.dt_util.utcnow", return_value=june):
|
with patch("homeassistant.helpers.condition.dt_util.utcnow", return_value=june):
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}})
|
||||||
hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}}
|
|
||||||
)
|
|
||||||
|
|
||||||
state = hass.states.get(sun.ENTITY_ID)
|
state = hass.states.get(sun.ENTITY_ID)
|
||||||
assert state is not None
|
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)
|
now = datetime(2016, 6, 1, tzinfo=dt_util.UTC)
|
||||||
|
|
||||||
with freeze_time(now):
|
with freeze_time(now):
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}})
|
||||||
hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}}
|
|
||||||
)
|
|
||||||
|
|
||||||
events = []
|
events = []
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ def setup_comp(hass):
|
||||||
"""Initialize components."""
|
"""Initialize components."""
|
||||||
mock_component(hass, "group")
|
mock_component(hass, "group")
|
||||||
hass.loop.run_until_complete(
|
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: {}})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ def setup_comp(hass):
|
||||||
"""Initialize components."""
|
"""Initialize components."""
|
||||||
hass.config.set_time_zone(hass.config.time_zone)
|
hass.config.set_time_zone(hass.config.time_zone)
|
||||||
hass.loop.run_until_complete(
|
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: {}})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3333,9 +3333,7 @@ async def test_track_sunrise(hass):
|
||||||
# Setup sun component
|
# Setup sun component
|
||||||
hass.config.latitude = latitude
|
hass.config.latitude = latitude
|
||||||
hass.config.longitude = longitude
|
hass.config.longitude = longitude
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}})
|
||||||
hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}}
|
|
||||||
)
|
|
||||||
|
|
||||||
location = LocationInfo(
|
location = LocationInfo(
|
||||||
latitude=hass.config.latitude, longitude=hass.config.longitude
|
latitude=hass.config.latitude, longitude=hass.config.longitude
|
||||||
|
@ -3400,9 +3398,7 @@ async def test_track_sunrise_update_location(hass):
|
||||||
# Setup sun component
|
# Setup sun component
|
||||||
hass.config.latitude = 32.87336
|
hass.config.latitude = 32.87336
|
||||||
hass.config.longitude = 117.22743
|
hass.config.longitude = 117.22743
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}})
|
||||||
hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}}
|
|
||||||
)
|
|
||||||
|
|
||||||
location = LocationInfo(
|
location = LocationInfo(
|
||||||
latitude=hass.config.latitude, longitude=hass.config.longitude
|
latitude=hass.config.latitude, longitude=hass.config.longitude
|
||||||
|
@ -3476,9 +3472,7 @@ async def test_track_sunset(hass):
|
||||||
# Setup sun component
|
# Setup sun component
|
||||||
hass.config.latitude = latitude
|
hass.config.latitude = latitude
|
||||||
hass.config.longitude = longitude
|
hass.config.longitude = longitude
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(hass, sun.DOMAIN, {sun.DOMAIN: {}})
|
||||||
hass, sun.DOMAIN, {sun.DOMAIN: {sun.CONF_ELEVATION: 0}}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get next sunrise/sunset
|
# Get next sunrise/sunset
|
||||||
utc_now = datetime(2014, 5, 24, 12, 0, 0, tzinfo=dt_util.UTC)
|
utc_now = datetime(2014, 5, 24, 12, 0, 0, tzinfo=dt_util.UTC)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue