diff --git a/homeassistant/components/hassio/__init__.py b/homeassistant/components/hassio/__init__.py index 3eef1c14dd0..eeeedff00bb 100644 --- a/homeassistant/components/hassio/__init__.py +++ b/homeassistant/components/hassio/__init__.py @@ -385,18 +385,20 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: ) last_timezone = None + last_country = None async def push_config(_: Event | None) -> None: """Push core config to Hass.io.""" nonlocal last_timezone + nonlocal last_country new_timezone = str(hass.config.time_zone) + new_country = str(hass.config.country) - if new_timezone == last_timezone: - return - - last_timezone = new_timezone - await hassio.update_hass_timezone(new_timezone) + if new_timezone != last_timezone or new_country != last_country: + last_timezone = new_timezone + last_country = new_country + await hassio.update_hass_config(new_timezone, new_country) hass.bus.async_listen(EVENT_CORE_CONFIG_UPDATE, push_config) diff --git a/homeassistant/components/hassio/handler.py b/homeassistant/components/hassio/handler.py index 752f535ca04..7aec0aa7a61 100644 --- a/homeassistant/components/hassio/handler.py +++ b/homeassistant/components/hassio/handler.py @@ -248,12 +248,14 @@ class HassIO: return await self.send_command("/homeassistant/options", payload=options) @_api_bool - def update_hass_timezone(self, timezone: str) -> Coroutine: + def update_hass_config(self, timezone: str, country: str | None) -> Coroutine: """Update Home-Assistant timezone data on Hass.io. This method returns a coroutine. """ - return self.send_command("/supervisor/options", payload={"timezone": timezone}) + return self.send_command( + "/supervisor/options", payload={"timezone": timezone, "country": country} + ) @_api_bool def update_diagnostics(self, diagnostics: bool) -> Coroutine: diff --git a/tests/components/hassio/test_init.py b/tests/components/hassio/test_init.py index 2ac06b46fca..d34aed608fb 100644 --- a/tests/components/hassio/test_init.py +++ b/tests/components/hassio/test_init.py @@ -404,7 +404,7 @@ async def test_setup_api_existing_hassio_user( assert aioclient_mock.mock_calls[0][2]["refresh_token"] == token.token -async def test_setup_core_push_timezone( +async def test_setup_core_push_config( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, supervisor_client: AsyncMock, @@ -421,9 +421,10 @@ async def test_setup_core_push_timezone( assert aioclient_mock.mock_calls[1][2]["timezone"] == "testzone" with patch("homeassistant.util.dt.set_default_time_zone"): - await hass.config.async_update(time_zone="America/New_York") + await hass.config.async_update(time_zone="America/New_York", country="US") await hass.async_block_till_done() assert aioclient_mock.mock_calls[-1][2]["timezone"] == "America/New_York" + assert aioclient_mock.mock_calls[-1][2]["country"] == "US" async def test_setup_hassio_no_additional_data( diff --git a/tests/conftest.py b/tests/conftest.py index efbd6f01cf7..ff4a09096e0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1942,7 +1942,7 @@ async def hassio_stubs( return_value={"result": "ok"}, ) as hass_api, patch( - "homeassistant.components.hassio.HassIO.update_hass_timezone", + "homeassistant.components.hassio.HassIO.update_hass_config", return_value={"result": "ok"}, ), patch(