mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Add scan interval to config of Environment Canada sensor (#25414)
* Make refresh period configurable * Remove throttle, set SCAN_INTERVAL * Move SCAN_INTERVAL to module
This commit is contained in:
parent
fae3546910
commit
59c62a261b
@ -15,11 +15,12 @@ from homeassistant.const import (
|
|||||||
TEMP_CELSIUS, CONF_LATITUDE, CONF_LONGITUDE, ATTR_ATTRIBUTION,
|
TEMP_CELSIUS, CONF_LATITUDE, CONF_LONGITUDE, ATTR_ATTRIBUTION,
|
||||||
ATTR_LOCATION)
|
ATTR_LOCATION)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import Throttle
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
SCAN_INTERVAL = timedelta(minutes=10)
|
||||||
|
|
||||||
ATTR_UPDATED = 'updated'
|
ATTR_UPDATED = 'updated'
|
||||||
ATTR_STATION = 'station'
|
ATTR_STATION = 'station'
|
||||||
ATTR_DETAIL = 'alert detail'
|
ATTR_DETAIL = 'alert detail'
|
||||||
@ -29,8 +30,6 @@ CONF_ATTRIBUTION = "Data provided by Environment Canada"
|
|||||||
CONF_STATION = 'station'
|
CONF_STATION = 'station'
|
||||||
CONF_LANGUAGE = 'language'
|
CONF_LANGUAGE = 'language'
|
||||||
|
|
||||||
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=1)
|
|
||||||
|
|
||||||
|
|
||||||
def validate_station(station):
|
def validate_station(station):
|
||||||
"""Check that the station ID is well-formed."""
|
"""Check that the station ID is well-formed."""
|
||||||
@ -110,7 +109,6 @@ class ECSensor(Entity):
|
|||||||
"""Return the units of measurement."""
|
"""Return the units of measurement."""
|
||||||
return self._unit
|
return self._unit
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update current conditions."""
|
"""Update current conditions."""
|
||||||
self.ec_data.update()
|
self.ec_data.update()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user