Remove device class timestamp from device condition and trigger (#48431)

* Remove unit from garmin connect

* Remove unit from hvv departures

* Remove device class timestamp from device condition and trigger

* Remove unit from systemmonitor

* Use device class constant for timestamp in ring
pull/48593/head
Martin Hjelmare 2021-04-01 15:05:10 +02:00 committed by GitHub
parent efa6079c62
commit fdbef90a57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 26 additions and 25 deletions

View File

@ -42,14 +42,14 @@ GARMIN_ENTITY_LIST = {
],
"wellnessStartTimeLocal": [
"Wellness Start Time",
"",
None,
"mdi:clock",
DEVICE_CLASS_TIMESTAMP,
False,
],
"wellnessEndTimeLocal": [
"Wellness End Time",
"",
None,
"mdi:clock",
DEVICE_CLASS_TIMESTAMP,
False,
@ -299,7 +299,7 @@ GARMIN_ENTITY_LIST = {
"latestSpo2": ["Latest SPO2", PERCENTAGE, "mdi:diabetes", None, True],
"latestSpo2ReadingTimeLocal": [
"Latest SPO2 Time",
"",
None,
"mdi:diabetes",
DEVICE_CLASS_TIMESTAMP,
False,
@ -334,7 +334,7 @@ GARMIN_ENTITY_LIST = {
],
"latestRespirationTimeGMT": [
"Latest Respiration Update",
"",
None,
"mdi:progress-clock",
DEVICE_CLASS_TIMESTAMP,
False,
@ -348,5 +348,5 @@ GARMIN_ENTITY_LIST = {
"physiqueRating": ["Physique Rating", "", "mdi:numeric", None, False],
"visceralFat": ["Visceral Fat", "", "mdi:food", None, False],
"metabolicAge": ["Metabolic Age", "", "mdi:calendar-heart", None, False],
"nextAlarm": ["Next Alarm Time", "", "mdi:alarm", DEVICE_CLASS_TIMESTAMP, True],
"nextAlarm": ["Next Alarm Time", None, "mdi:alarm", DEVICE_CLASS_TIMESTAMP, True],
}

View File

@ -18,7 +18,6 @@ MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=1)
MAX_LIST = 20
MAX_TIME_OFFSET = 360
ICON = "mdi:bus"
UNIT_OF_MEASUREMENT = "min"
ATTR_DEPARTURE = "departure"
ATTR_LINE = "line"

View File

@ -1,6 +1,10 @@
"""This component provides HA sensor support for Ring Door Bell/Chimes."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT
from homeassistant.const import (
DEVICE_CLASS_TIMESTAMP,
PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
)
from homeassistant.core import callback
from homeassistant.helpers.icon import icon_for_battery_level
@ -210,7 +214,7 @@ SENSOR_TYPES = {
None,
"history",
None,
"timestamp",
DEVICE_CLASS_TIMESTAMP,
HistoryRingSensor,
],
"last_ding": [
@ -219,7 +223,7 @@ SENSOR_TYPES = {
None,
"history",
"ding",
"timestamp",
DEVICE_CLASS_TIMESTAMP,
HistoryRingSensor,
],
"last_motion": [
@ -228,7 +232,7 @@ SENSOR_TYPES = {
None,
"history",
"motion",
"timestamp",
DEVICE_CLASS_TIMESTAMP,
HistoryRingSensor,
],
"volume": [

View File

@ -25,7 +25,6 @@ from homeassistant.const import (
DEVICE_CLASS_PRESSURE,
DEVICE_CLASS_SIGNAL_STRENGTH,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_TIMESTAMP,
DEVICE_CLASS_VOLTAGE,
)
from homeassistant.core import HomeAssistant, callback
@ -54,7 +53,6 @@ CONF_IS_POWER_FACTOR = "is_power_factor"
CONF_IS_PRESSURE = "is_pressure"
CONF_IS_SIGNAL_STRENGTH = "is_signal_strength"
CONF_IS_TEMPERATURE = "is_temperature"
CONF_IS_TIMESTAMP = "is_timestamp"
CONF_IS_VOLTAGE = "is_voltage"
CONF_IS_VALUE = "is_value"
@ -71,7 +69,6 @@ ENTITY_CONDITIONS = {
DEVICE_CLASS_PRESSURE: [{CONF_TYPE: CONF_IS_PRESSURE}],
DEVICE_CLASS_SIGNAL_STRENGTH: [{CONF_TYPE: CONF_IS_SIGNAL_STRENGTH}],
DEVICE_CLASS_TEMPERATURE: [{CONF_TYPE: CONF_IS_TEMPERATURE}],
DEVICE_CLASS_TIMESTAMP: [{CONF_TYPE: CONF_IS_TIMESTAMP}],
DEVICE_CLASS_VOLTAGE: [{CONF_TYPE: CONF_IS_VOLTAGE}],
DEVICE_CLASS_NONE: [{CONF_TYPE: CONF_IS_VALUE}],
}
@ -94,7 +91,6 @@ CONDITION_SCHEMA = vol.All(
CONF_IS_PRESSURE,
CONF_IS_SIGNAL_STRENGTH,
CONF_IS_TEMPERATURE,
CONF_IS_TIMESTAMP,
CONF_IS_VOLTAGE,
CONF_IS_VALUE,
]

View File

@ -28,7 +28,6 @@ from homeassistant.const import (
DEVICE_CLASS_PRESSURE,
DEVICE_CLASS_SIGNAL_STRENGTH,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_TIMESTAMP,
DEVICE_CLASS_VOLTAGE,
)
from homeassistant.helpers import config_validation as cv
@ -52,7 +51,6 @@ CONF_POWER_FACTOR = "power_factor"
CONF_PRESSURE = "pressure"
CONF_SIGNAL_STRENGTH = "signal_strength"
CONF_TEMPERATURE = "temperature"
CONF_TIMESTAMP = "timestamp"
CONF_VOLTAGE = "voltage"
CONF_VALUE = "value"
@ -69,7 +67,6 @@ ENTITY_TRIGGERS = {
DEVICE_CLASS_PRESSURE: [{CONF_TYPE: CONF_PRESSURE}],
DEVICE_CLASS_SIGNAL_STRENGTH: [{CONF_TYPE: CONF_SIGNAL_STRENGTH}],
DEVICE_CLASS_TEMPERATURE: [{CONF_TYPE: CONF_TEMPERATURE}],
DEVICE_CLASS_TIMESTAMP: [{CONF_TYPE: CONF_TIMESTAMP}],
DEVICE_CLASS_VOLTAGE: [{CONF_TYPE: CONF_VOLTAGE}],
DEVICE_CLASS_NONE: [{CONF_TYPE: CONF_VALUE}],
}
@ -93,7 +90,6 @@ TRIGGER_SCHEMA = vol.All(
CONF_PRESSURE,
CONF_SIGNAL_STRENGTH,
CONF_TEMPERATURE,
CONF_TIMESTAMP,
CONF_VOLTAGE,
CONF_VALUE,
]

View File

@ -11,7 +11,6 @@
"is_pressure": "Current {entity_name} pressure",
"is_signal_strength": "Current {entity_name} signal strength",
"is_temperature": "Current {entity_name} temperature",
"is_timestamp": "Current {entity_name} timestamp",
"is_current": "Current {entity_name} current",
"is_energy": "Current {entity_name} energy",
"is_power_factor": "Current {entity_name} power factor",
@ -28,7 +27,6 @@
"pressure": "{entity_name} pressure changes",
"signal_strength": "{entity_name} signal strength changes",
"temperature": "{entity_name} temperature changes",
"timestamp": "{entity_name} timestamp changes",
"current": "{entity_name} current changes",
"energy": "{entity_name} energy changes",
"power_factor": "{entity_name} power factor changes",

View File

@ -14,6 +14,7 @@ from homeassistant.const import (
DATA_GIBIBYTES,
DATA_MEBIBYTES,
DATA_RATE_MEGABYTES_PER_SECOND,
DEVICE_CLASS_TIMESTAMP,
PERCENTAGE,
STATE_OFF,
STATE_ON,
@ -47,7 +48,7 @@ SENSOR_TYPES = {
],
"ipv4_address": ["IPv4 address", "", "mdi:server-network", None, True],
"ipv6_address": ["IPv6 address", "", "mdi:server-network", None, True],
"last_boot": ["Last boot", "", "mdi:clock", "timestamp", False],
"last_boot": ["Last boot", None, "mdi:clock", DEVICE_CLASS_TIMESTAMP, False],
"load_15m": ["Load (15m)", " ", CPU_ICON, None, False],
"load_1m": ["Load (1m)", " ", CPU_ICON, None, False],
"load_5m": ["Load (5m)", " ", CPU_ICON, None, False],

View File

@ -17,7 +17,10 @@ from tests.common import (
mock_registry,
)
from tests.components.blueprint.conftest import stub_blueprint_populate # noqa: F401
from tests.testing_config.custom_components.test.sensor import DEVICE_CLASSES
from tests.testing_config.custom_components.test.sensor import (
DEVICE_CLASSES,
UNITS_OF_MEASUREMENT,
)
@pytest.fixture
@ -69,6 +72,7 @@ async def test_get_conditions(hass, device_reg, entity_reg):
"entity_id": platform.ENTITIES[device_class].entity_id,
}
for device_class in DEVICE_CLASSES
if device_class in UNITS_OF_MEASUREMENT
for condition in ENTITY_CONDITIONS[device_class]
if device_class != "none"
]

View File

@ -21,7 +21,10 @@ from tests.common import (
mock_registry,
)
from tests.components.blueprint.conftest import stub_blueprint_populate # noqa: F401
from tests.testing_config.custom_components.test.sensor import DEVICE_CLASSES
from tests.testing_config.custom_components.test.sensor import (
DEVICE_CLASSES,
UNITS_OF_MEASUREMENT,
)
@pytest.fixture
@ -73,11 +76,12 @@ async def test_get_triggers(hass, device_reg, entity_reg):
"entity_id": platform.ENTITIES[device_class].entity_id,
}
for device_class in DEVICE_CLASSES
if device_class in UNITS_OF_MEASUREMENT
for trigger in ENTITY_TRIGGERS[device_class]
if device_class != "none"
]
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
assert len(triggers) == 14
assert len(triggers) == 13
assert triggers == expected_triggers

View File

@ -24,7 +24,6 @@ UNITS_OF_MEASUREMENT = {
sensor.DEVICE_CLASS_ILLUMINANCE: "lm", # current light level (lx/lm)
sensor.DEVICE_CLASS_SIGNAL_STRENGTH: SIGNAL_STRENGTH_DECIBELS, # signal strength (dB/dBm)
sensor.DEVICE_CLASS_TEMPERATURE: "C", # temperature (C/F)
sensor.DEVICE_CLASS_TIMESTAMP: "hh:mm:ss", # timestamp (ISO8601)
sensor.DEVICE_CLASS_PRESSURE: PRESSURE_HPA, # pressure (hPa/mbar)
sensor.DEVICE_CLASS_POWER: "kW", # power (W/kW)
sensor.DEVICE_CLASS_CURRENT: "A", # current (A)