mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix workday timezone (#119148)
This commit is contained in:
parent
a64d6e548c
commit
fff2c1115d
@ -269,7 +269,7 @@ class IsWorkdaySensor(BinarySensorEntity):
|
||||
|
||||
def _update_state_and_setup_listener(self) -> None:
|
||||
"""Update state and setup listener for next interval."""
|
||||
now = dt_util.utcnow()
|
||||
now = dt_util.now()
|
||||
self.update_data(now)
|
||||
self.unsub = async_track_point_in_utc_time(
|
||||
self.hass, self.point_in_time_listener, self.get_next_interval(now)
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Tests the Home Assistant workday binary sensor."""
|
||||
|
||||
from datetime import date, datetime, timedelta
|
||||
from datetime import date, datetime, timedelta, timezone
|
||||
from typing import Any
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
@ -68,7 +68,9 @@ async def test_setup(
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test setup from various configs."""
|
||||
freezer.move_to(datetime(2022, 4, 15, 12, tzinfo=UTC)) # Friday
|
||||
# Start on a Friday
|
||||
await hass.config.async_set_time_zone("Europe/Paris")
|
||||
freezer.move_to(datetime(2022, 4, 15, 0, tzinfo=timezone(timedelta(hours=1))))
|
||||
await init_integration(hass, config)
|
||||
|
||||
state = hass.states.get("binary_sensor.workday_sensor")
|
||||
|
Loading…
x
Reference in New Issue
Block a user