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:
parent
e6e985af24
commit
97410474f5
6 changed files with 44 additions and 6 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
import contextlib
|
||||
import logging
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
import voluptuous as vol
|
||||
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 homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_TYPE, EVENT_HOMEASSISTANT_STOP, Platform
|
||||
from homeassistant.core import Event, HomeAssistant
|
||||
from homeassistant.const import (
|
||||
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.helpers import device_registry as dr
|
||||
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)
|
||||
)
|
||||
|
||||
@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 hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
|
||||
async_dispatcher_send(hass, SIGNAL_ADD_ENTITIES)
|
||||
|
|
|
@ -15,6 +15,7 @@ import re
|
|||
import time
|
||||
from types import MappingProxyType
|
||||
from typing import TYPE_CHECKING, Any, Concatenate, NamedTuple, ParamSpec, TypeVar, cast
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
import voluptuous as vol
|
||||
from zha.application.const import (
|
||||
|
@ -1273,6 +1274,7 @@ def create_zha_config(hass: HomeAssistant, ha_zha_data: HAZHAData) -> ZHAData:
|
|||
quirks_configuration=quirks_config,
|
||||
device_overrides=overrides_config,
|
||||
),
|
||||
local_timezone=ZoneInfo(hass.config.time_zone),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"zha",
|
||||
"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": [
|
||||
{
|
||||
"vid": "10C4",
|
||||
|
|
|
@ -2989,7 +2989,7 @@ zeroconf==0.132.2
|
|||
zeversolar==0.3.1
|
||||
|
||||
# homeassistant.components.zha
|
||||
zha==0.0.28
|
||||
zha==0.0.29
|
||||
|
||||
# homeassistant.components.zhong_hong
|
||||
zhong-hong-hvac==1.0.12
|
||||
|
|
|
@ -2366,7 +2366,7 @@ zeroconf==0.132.2
|
|||
zeversolar==0.3.1
|
||||
|
||||
# homeassistant.components.zha
|
||||
zha==0.0.28
|
||||
zha==0.0.29
|
||||
|
||||
# homeassistant.components.zwave_js
|
||||
zwave-js-server-python==0.57.0
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import asyncio
|
||||
import typing
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
import zoneinfo
|
||||
|
||||
import pytest
|
||||
from zigpy.application import ControllerApplication
|
||||
|
@ -16,7 +17,7 @@ from homeassistant.components.zha.const import (
|
|||
CONF_USB_PATH,
|
||||
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 (
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
MAJOR_VERSION,
|
||||
|
@ -288,3 +289,23 @@ async def test_shutdown_on_ha_stop(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
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")
|
||||
|
|
Loading…
Add table
Reference in a new issue