mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use HAs configured timezone for KNX expose time (#140158)
* Use HAs configured timezone for KNX expose time * use `hass.config.async_set_time_zone` in tests
This commit is contained in:
parent
be67f320b5
commit
62c025fd12
@ -30,6 +30,7 @@ from homeassistant.exceptions import TemplateError
|
|||||||
from homeassistant.helpers.event import async_track_state_change_event
|
from homeassistant.helpers.event import async_track_state_change_event
|
||||||
from homeassistant.helpers.template import Template
|
from homeassistant.helpers.template import Template
|
||||||
from homeassistant.helpers.typing import ConfigType, StateType
|
from homeassistant.helpers.typing import ConfigType, StateType
|
||||||
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from .const import CONF_RESPOND_TO_READ, KNX_ADDRESS
|
from .const import CONF_RESPOND_TO_READ, KNX_ADDRESS
|
||||||
from .schema import ExposeSchema
|
from .schema import ExposeSchema
|
||||||
@ -217,7 +218,7 @@ class KNXExposeTime:
|
|||||||
self.device = xknx_device_cls(
|
self.device = xknx_device_cls(
|
||||||
self.xknx,
|
self.xknx,
|
||||||
name=expose_type.capitalize(),
|
name=expose_type.capitalize(),
|
||||||
localtime=True,
|
localtime=dt_util.get_default_time_zone(),
|
||||||
group_address=config[KNX_ADDRESS],
|
group_address=config[KNX_ADDRESS],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -348,19 +348,20 @@ async def test_expose_conversion_exception(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@freeze_time("2022-1-7 9:13:14")
|
@freeze_time("2022-1-7 9:13:14") # UTC -> +1h = Vienna in winter (9 -> 0xA)
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("time_type", "raw"),
|
("time_type", "raw"),
|
||||||
[
|
[
|
||||||
("time", (0xA9, 0x0D, 0x0E)), # localtime includes day of week
|
("time", (0xAA, 0x0D, 0x0E)), # localtime includes day of week
|
||||||
("date", (0x07, 0x01, 0x16)),
|
("date", (0x07, 0x01, 0x16)),
|
||||||
("datetime", (0x7A, 0x1, 0x7, 0xA9, 0xD, 0xE, 0x20, 0xC0)),
|
("datetime", (0x7A, 0x1, 0x7, 0xAA, 0xD, 0xE, 0x20, 0xC0)),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_expose_with_date(
|
async def test_expose_with_date(
|
||||||
hass: HomeAssistant, knx: KNXTestKit, time_type: str, raw: tuple[int, ...]
|
hass: HomeAssistant, knx: KNXTestKit, time_type: str, raw: tuple[int, ...]
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test an expose with a date."""
|
"""Test an expose with a date."""
|
||||||
|
await hass.config.async_set_time_zone("Europe/Vienna")
|
||||||
await knx.setup_integration(
|
await knx.setup_integration(
|
||||||
{
|
{
|
||||||
CONF_KNX_EXPOSE: {
|
CONF_KNX_EXPOSE: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user