mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 01:11:51 -04:00
Do not log the tracked location in NWS (#182350)
This commit is contained in:
@@ -115,12 +115,7 @@ class NWSObservationDataUpdateCoordinator(TimestampDataUpdateCoordinator[None]):
|
||||
self._location_entity_id,
|
||||
)
|
||||
return
|
||||
_LOGGER.info(
|
||||
"NWS API updated: station %s at (%.4f, %.4f)",
|
||||
new_nws.station,
|
||||
coordinates.latitude,
|
||||
coordinates.longitude,
|
||||
)
|
||||
_LOGGER.info("NWS API updated: station %s", new_nws.station)
|
||||
self.nws = new_nws
|
||||
self.name = f"NWS observation station {new_nws.station}"
|
||||
runtime_data = self.config_entry.runtime_data
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"""Tests for init module."""
|
||||
|
||||
import logging
|
||||
|
||||
from pynws import NwsNoDataError
|
||||
import pytest
|
||||
|
||||
@@ -195,6 +197,40 @@ async def test_location_change_updates_coordinates(
|
||||
assert coordinator.name == f"NWS observation station {new_station}"
|
||||
|
||||
|
||||
async def test_location_change_does_not_log_coordinates(
|
||||
hass: HomeAssistant,
|
||||
mock_simple_nws,
|
||||
location_entity_config: dict,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test that the tracked location is not written to the log."""
|
||||
caplog.set_level(logging.INFO)
|
||||
entity = location_entity_config["entry"]
|
||||
hass.states.async_set(
|
||||
entity.entity_id,
|
||||
"home",
|
||||
{ATTR_LATITUDE: 40.0, ATTR_LONGITUDE: -80.0},
|
||||
)
|
||||
|
||||
config_entry = MockConfigEntry(domain=DOMAIN, data=location_entity_config["config"])
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
caplog.clear()
|
||||
hass.states.async_set(
|
||||
entity.entity_id,
|
||||
"away",
|
||||
{ATTR_LATITUDE: 41.0, ATTR_LONGITUDE: -81.0},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "NWS API updated: station" in caplog.text
|
||||
assert "41.0000" not in caplog.text
|
||||
assert "-81.0000" not in caplog.text
|
||||
|
||||
|
||||
async def test_location_change_resets_api_success_time(
|
||||
hass: HomeAssistant, mock_simple_nws, location_entity_config: dict
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user