Add and use time related constants (#32065)

* Add and use time related constants

* Sort time constants and reuse them in data rate constants

* Fix greeneyemonitor import

* Fix greeneyemonitor import V2

* Fix failing here_travel_time test

* Add TIME_MONTHS and TIME_YEARS

* Use TIME_MINUTES in opentherm_gw and isy994

* Add and use TIME_MILLISECONDS

* Change inconsistent ones

* Add TIME_MICROSECONDS and TIME_WEEKS

* Use constants in apcupsd and travisci

* Fix import error in upnp sensor.py

* Fix isy994 sensor.py using TIME_YEARS

* Fix dyson tests

* Use TIME_SECONDS in more places

* Use TIME_DAYS in google wifi
This commit is contained in:
springstan 2020-02-23 21:09:24 +01:00 committed by GitHub
parent 8dd80e0e3c
commit a85808e325
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 480 additions and 287 deletions

View file

@ -10,7 +10,7 @@ from homeassistant.components.sensor import (
DEVICE_CLASS_SIGNAL_STRENGTH,
DOMAIN as SENSOR_DOMAIN,
)
from homeassistant.const import CONF_URL, DATA_BYTES, STATE_UNKNOWN
from homeassistant.const import CONF_URL, DATA_BYTES, STATE_UNKNOWN, TIME_SECONDS
from . import HuaweiLteBaseEntity
from .const import (
@ -18,7 +18,6 @@ from .const import (
KEY_DEVICE_INFORMATION,
KEY_DEVICE_SIGNAL,
KEY_MONITORING_TRAFFIC_STATISTICS,
UNIT_SECONDS,
)
_LOGGER = logging.getLogger(__name__)
@ -122,7 +121,7 @@ SENSOR_META = {
exclude=re.compile(r"^showtraffic$", re.IGNORECASE)
),
(KEY_MONITORING_TRAFFIC_STATISTICS, "CurrentConnectTime"): dict(
name="Current connection duration", unit=UNIT_SECONDS, icon="mdi:timer"
name="Current connection duration", unit=TIME_SECONDS, icon="mdi:timer"
),
(KEY_MONITORING_TRAFFIC_STATISTICS, "CurrentDownload"): dict(
name="Current connection download", unit=DATA_BYTES, icon="mdi:download"
@ -131,7 +130,7 @@ SENSOR_META = {
name="Current connection upload", unit=DATA_BYTES, icon="mdi:upload"
),
(KEY_MONITORING_TRAFFIC_STATISTICS, "TotalConnectTime"): dict(
name="Total connected duration", unit=UNIT_SECONDS, icon="mdi:timer"
name="Total connected duration", unit=TIME_SECONDS, icon="mdi:timer"
),
(KEY_MONITORING_TRAFFIC_STATISTICS, "TotalDownload"): dict(
name="Total download", unit=DATA_BYTES, icon="mdi:download"