mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Update yr.py
This commit is contained in:
parent
618ebfe43c
commit
15770ff90f
@ -37,6 +37,7 @@ sensor:
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import datetime
|
import datetime
|
||||||
|
import homeassistant.util.dt as dt_util
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import xmltodict
|
import xmltodict
|
||||||
|
|
||||||
@ -158,7 +159,7 @@ class YrSensor(Entity):
|
|||||||
# pylint: disable=too-many-branches, too-many-return-statements
|
# pylint: disable=too-many-branches, too-many-return-statements
|
||||||
def update(self):
|
def update(self):
|
||||||
""" Gets the latest data from yr.no and updates the states. """
|
""" Gets the latest data from yr.no and updates the states. """
|
||||||
now = datetime.datetime.now()
|
now = dt_util.utcnow()
|
||||||
if now > self._nextrun:
|
if now > self._nextrun:
|
||||||
try:
|
try:
|
||||||
response = urllib.request.urlopen(self._url)
|
response = urllib.request.urlopen(self._url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user