mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Use the timezone defined in Home Assistant when making the API call (#23284)
* Use HA defined timezone * Cleanup * Use homeassistant.util.dt.now to get the correct time. * Update homeassistant/components/vasttrafik/sensor.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
1282370ccb
commit
ff867a7d57
@ -1,5 +1,4 @@
|
|||||||
"""Support for Västtrafik public transport."""
|
"""Support for Västtrafik public transport."""
|
||||||
from datetime import datetime
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -10,6 +9,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA
|
|||||||
from homeassistant.const import CONF_NAME, ATTR_ATTRIBUTION
|
from homeassistant.const import CONF_NAME, ATTR_ATTRIBUTION
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
from homeassistant.util.dt import now
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ class VasttrafikDepartureSensor(Entity):
|
|||||||
self._departureboard = self._planner.departureboard(
|
self._departureboard = self._planner.departureboard(
|
||||||
self._departure['id'],
|
self._departure['id'],
|
||||||
direction=self._heading['id'] if self._heading else None,
|
direction=self._heading['id'] if self._heading else None,
|
||||||
date=datetime.now()+self._delay)
|
date=now()+self._delay)
|
||||||
except self._vasttrafik.Error:
|
except self._vasttrafik.Error:
|
||||||
_LOGGER.debug("Unable to read departure board, updating token")
|
_LOGGER.debug("Unable to read departure board, updating token")
|
||||||
self._planner.update_token()
|
self._planner.update_token()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user