mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Add flow rate sensor to acaia (#131254)
This commit is contained in:
parent
430a47138a
commit
ce46bac245
@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
|
|||||||
SensorExtraStoredData,
|
SensorExtraStoredData,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import PERCENTAGE, UnitOfMass
|
from homeassistant.const import PERCENTAGE, UnitOfMass, UnitOfVolumeFlowRate
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
@ -49,6 +49,14 @@ SENSORS: tuple[AcaiaSensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
value_fn=lambda scale: scale.weight,
|
value_fn=lambda scale: scale.weight,
|
||||||
),
|
),
|
||||||
|
AcaiaDynamicUnitSensorEntityDescription(
|
||||||
|
key="flow_rate",
|
||||||
|
device_class=SensorDeviceClass.VOLUME_FLOW_RATE,
|
||||||
|
native_unit_of_measurement=UnitOfVolumeFlowRate.MILLILITERS_PER_SECOND,
|
||||||
|
suggested_display_precision=1,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
value_fn=lambda scale: scale.flow_rate,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
RESTORE_SENSORS: tuple[AcaiaSensorEntityDescription, ...] = (
|
RESTORE_SENSORS: tuple[AcaiaSensorEntityDescription, ...] = (
|
||||||
AcaiaSensorEntityDescription(
|
AcaiaSensorEntityDescription(
|
||||||
|
@ -80,4 +80,5 @@ def mock_scale() -> Generator[MagicMock]:
|
|||||||
)
|
)
|
||||||
scale.weight = 123.45
|
scale.weight = 123.45
|
||||||
scale.timer = 23
|
scale.timer = 23
|
||||||
|
scale.flow_rate = 1.23
|
||||||
yield scale
|
yield scale
|
||||||
|
@ -50,6 +50,60 @@
|
|||||||
'state': '42',
|
'state': '42',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
# name: test_sensors[sensor.lunar_ddeeff_volume_flow_rate-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': dict({
|
||||||
|
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||||
|
}),
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'sensor',
|
||||||
|
'entity_category': None,
|
||||||
|
'entity_id': 'sensor.lunar_ddeeff_volume_flow_rate',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
'sensor': dict({
|
||||||
|
'suggested_display_precision': 1,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'original_device_class': <SensorDeviceClass.VOLUME_FLOW_RATE: 'volume_flow_rate'>,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': 'Volume flow rate',
|
||||||
|
'platform': 'acaia',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'supported_features': 0,
|
||||||
|
'translation_key': None,
|
||||||
|
'unique_id': 'aa:bb:cc:dd:ee:ff_flow_rate',
|
||||||
|
'unit_of_measurement': <UnitOfVolumeFlowRate.MILLILITERS_PER_SECOND: 'mL/s'>,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_sensors[sensor.lunar_ddeeff_volume_flow_rate-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'volume_flow_rate',
|
||||||
|
'friendly_name': 'LUNAR-DDEEFF Volume flow rate',
|
||||||
|
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||||
|
'unit_of_measurement': <UnitOfVolumeFlowRate.MILLILITERS_PER_SECOND: 'mL/s'>,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.lunar_ddeeff_volume_flow_rate',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '1.23',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
# name: test_sensors[sensor.lunar_ddeeff_weight-entry]
|
# name: test_sensors[sensor.lunar_ddeeff_weight-entry]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user