mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Minor tweaks for sensor device automations (#27829)
* Minor tweaks for sensor device automations * Change unit_of_measurement to suffix in extra_fields * Address review comment
This commit is contained in:
parent
04dbe5bc84
commit
4700d647b0
@ -11,7 +11,6 @@ from homeassistant.const import (
|
||||
CONF_ENTITY_ID,
|
||||
CONF_FOR,
|
||||
CONF_TYPE,
|
||||
CONF_UNIT_OF_MEASUREMENT,
|
||||
DEVICE_CLASS_BATTERY,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
@ -73,11 +72,6 @@ TRIGGER_SCHEMA = vol.All(
|
||||
),
|
||||
vol.Optional(CONF_BELOW): vol.Any(vol.Coerce(float)),
|
||||
vol.Optional(CONF_ABOVE): vol.Any(vol.Coerce(float)),
|
||||
vol.Optional(CONF_FOR): vol.Any(
|
||||
vol.All(cv.time_period, cv.positive_timedelta),
|
||||
cv.template,
|
||||
cv.template_complex,
|
||||
),
|
||||
vol.Optional(CONF_FOR): cv.positive_time_period_dict,
|
||||
}
|
||||
),
|
||||
@ -159,12 +153,10 @@ async def async_get_trigger_capabilities(hass, config):
|
||||
"extra_fields": vol.Schema(
|
||||
{
|
||||
vol.Optional(
|
||||
CONF_ABOVE,
|
||||
description={CONF_UNIT_OF_MEASUREMENT: unit_of_measurement},
|
||||
CONF_ABOVE, description={"suffix": unit_of_measurement}
|
||||
): vol.Coerce(float),
|
||||
vol.Optional(
|
||||
CONF_BELOW,
|
||||
description={CONF_UNIT_OF_MEASUREMENT: unit_of_measurement},
|
||||
CONF_BELOW, description={"suffix": unit_of_measurement}
|
||||
): vol.Coerce(float),
|
||||
vol.Optional(CONF_FOR): cv.positive_time_period_dict,
|
||||
}
|
||||
|
@ -1,26 +1,26 @@
|
||||
{
|
||||
"device_automation": {
|
||||
"condition_type": {
|
||||
"is_battery_level": "{entity_name} battery level",
|
||||
"is_humidity": "{entity_name} humidity",
|
||||
"is_illuminance": "{entity_name} illuminance",
|
||||
"is_power": "{entity_name} power",
|
||||
"is_pressure": "{entity_name} pressure",
|
||||
"is_signal_strength": "{entity_name} signal strength",
|
||||
"is_temperature": "{entity_name} temperature",
|
||||
"is_timestamp": "{entity_name} timestamp",
|
||||
"is_value": "{entity_name} value"
|
||||
"is_battery_level": "Current {entity_name} battery level",
|
||||
"is_humidity": "Current {entity_name} humidity",
|
||||
"is_illuminance": "Current {entity_name} illuminance",
|
||||
"is_power": "Current {entity_name} power",
|
||||
"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_value": "Current {entity_name} value"
|
||||
},
|
||||
"trigger_type": {
|
||||
"battery_level": "{entity_name} battery level",
|
||||
"humidity": "{entity_name} humidity",
|
||||
"illuminance": "{entity_name} illuminance",
|
||||
"power": "{entity_name} power",
|
||||
"pressure": "{entity_name} pressure",
|
||||
"signal_strength": "{entity_name} signal strength",
|
||||
"temperature": "{entity_name} temperature",
|
||||
"timestamp": "{entity_name} timestamp",
|
||||
"value": "{entity_name} value"
|
||||
"battery_level": "{entity_name} battery level changes",
|
||||
"humidity": "{entity_name} humidity changes",
|
||||
"illuminance": "{entity_name} illuminance changes",
|
||||
"power": "{entity_name} power changes",
|
||||
"pressure": "{entity_name} pressure changes",
|
||||
"signal_strength": "{entity_name} signal strength changes",
|
||||
"temperature": "{entity_name} temperature changes",
|
||||
"timestamp": "{entity_name} timestamp changes",
|
||||
"value": "{entity_name} value changes"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,13 +101,13 @@ async def test_get_trigger_capabilities(hass, device_reg, entity_reg):
|
||||
expected_capabilities = {
|
||||
"extra_fields": [
|
||||
{
|
||||
"description": {"unit_of_measurement": "%"},
|
||||
"description": {"suffix": "%"},
|
||||
"name": "above",
|
||||
"optional": True,
|
||||
"type": "float",
|
||||
},
|
||||
{
|
||||
"description": {"unit_of_measurement": "%"},
|
||||
"description": {"suffix": "%"},
|
||||
"name": "below",
|
||||
"optional": True,
|
||||
"type": "float",
|
||||
|
Loading…
x
Reference in New Issue
Block a user