Bump ZHA library to 0.0.29 (#123464)

* Bump zha to 0.0.29

* Pass the Core timezone to ZHA

* Add a unit test
This commit is contained in:
puddly 2024-08-09 10:31:55 -04:00 committed by GitHub
parent e6e985af24
commit 97410474f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 44 additions and 6 deletions

View File

@ -2,6 +2,7 @@
import contextlib import contextlib
import logging import logging
from zoneinfo import ZoneInfo
import voluptuous as vol import voluptuous as vol
from zha.application.const import BAUD_RATES, RadioType from zha.application.const import BAUD_RATES, RadioType
@ -12,8 +13,13 @@ from zigpy.config import CONF_DATABASE, CONF_DEVICE, CONF_DEVICE_PATH
from zigpy.exceptions import NetworkSettingsInconsistent, TransientConnectionError from zigpy.exceptions import NetworkSettingsInconsistent, TransientConnectionError
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_TYPE, EVENT_HOMEASSISTANT_STOP, Platform from homeassistant.const import (
from homeassistant.core import Event, HomeAssistant CONF_TYPE,
EVENT_CORE_CONFIG_UPDATE,
EVENT_HOMEASSISTANT_STOP,
Platform,
)
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryError, ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryError, ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -204,6 +210,15 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, async_shutdown) hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, async_shutdown)
) )
@callback
def update_config(event: Event) -> None:
"""Handle Core config update."""
zha_gateway.config.local_timezone = ZoneInfo(hass.config.time_zone)
config_entry.async_on_unload(
hass.bus.async_listen(EVENT_CORE_CONFIG_UPDATE, update_config)
)
await ha_zha_data.gateway_proxy.async_initialize_devices_and_entities() await ha_zha_data.gateway_proxy.async_initialize_devices_and_entities()
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS) await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
async_dispatcher_send(hass, SIGNAL_ADD_ENTITIES) async_dispatcher_send(hass, SIGNAL_ADD_ENTITIES)

View File

@ -15,6 +15,7 @@ import re
import time import time
from types import MappingProxyType from types import MappingProxyType
from typing import TYPE_CHECKING, Any, Concatenate, NamedTuple, ParamSpec, TypeVar, cast from typing import TYPE_CHECKING, Any, Concatenate, NamedTuple, ParamSpec, TypeVar, cast
from zoneinfo import ZoneInfo
import voluptuous as vol import voluptuous as vol
from zha.application.const import ( from zha.application.const import (
@ -1273,6 +1274,7 @@ def create_zha_config(hass: HomeAssistant, ha_zha_data: HAZHAData) -> ZHAData:
quirks_configuration=quirks_config, quirks_configuration=quirks_config,
device_overrides=overrides_config, device_overrides=overrides_config,
), ),
local_timezone=ZoneInfo(hass.config.time_zone),
) )

View File

@ -21,7 +21,7 @@
"zha", "zha",
"universal_silabs_flasher" "universal_silabs_flasher"
], ],
"requirements": ["universal-silabs-flasher==0.0.22", "zha==0.0.28"], "requirements": ["universal-silabs-flasher==0.0.22", "zha==0.0.29"],
"usb": [ "usb": [
{ {
"vid": "10C4", "vid": "10C4",

View File

@ -2989,7 +2989,7 @@ zeroconf==0.132.2
zeversolar==0.3.1 zeversolar==0.3.1
# homeassistant.components.zha # homeassistant.components.zha
zha==0.0.28 zha==0.0.29
# homeassistant.components.zhong_hong # homeassistant.components.zhong_hong
zhong-hong-hvac==1.0.12 zhong-hong-hvac==1.0.12

View File

@ -2366,7 +2366,7 @@ zeroconf==0.132.2
zeversolar==0.3.1 zeversolar==0.3.1
# homeassistant.components.zha # homeassistant.components.zha
zha==0.0.28 zha==0.0.29
# homeassistant.components.zwave_js # homeassistant.components.zwave_js
zwave-js-server-python==0.57.0 zwave-js-server-python==0.57.0

View File

@ -3,6 +3,7 @@
import asyncio import asyncio
import typing import typing
from unittest.mock import AsyncMock, Mock, patch from unittest.mock import AsyncMock, Mock, patch
import zoneinfo
import pytest import pytest
from zigpy.application import ControllerApplication from zigpy.application import ControllerApplication
@ -16,7 +17,7 @@ from homeassistant.components.zha.const import (
CONF_USB_PATH, CONF_USB_PATH,
DOMAIN, DOMAIN,
) )
from homeassistant.components.zha.helpers import get_zha_data from homeassistant.components.zha.helpers import get_zha_data, get_zha_gateway
from homeassistant.const import ( from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
MAJOR_VERSION, MAJOR_VERSION,
@ -288,3 +289,23 @@ async def test_shutdown_on_ha_stop(
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(mock_shutdown.mock_calls) == 1 assert len(mock_shutdown.mock_calls) == 1
async def test_timezone_update(
hass: HomeAssistant,
config_entry: MockConfigEntry,
mock_zigpy_connect: ControllerApplication,
) -> None:
"""Test that the ZHA gateway timezone is updated when HA timezone changes."""
config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id)
gateway = get_zha_gateway(hass)
assert hass.config.time_zone == "US/Pacific"
assert gateway.config.local_timezone == zoneinfo.ZoneInfo("US/Pacific")
await hass.config.async_update(time_zone="America/New_York")
assert hass.config.time_zone == "America/New_York"
assert gateway.config.local_timezone == zoneinfo.ZoneInfo("America/New_York")