mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Add water flow
sensor to IMGW PIB integration (#148517)
This commit is contained in:
parent
8aaf5756e0
commit
a7e879714b
@ -1,6 +1,9 @@
|
||||
{
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"water_flow": {
|
||||
"default": "mdi:waves-arrow-right"
|
||||
},
|
||||
"water_level": {
|
||||
"default": "mdi:waves"
|
||||
},
|
||||
|
@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import UnitOfLength, UnitOfTemperature
|
||||
from homeassistant.const import UnitOfLength, UnitOfTemperature, UnitOfVolumeFlowRate
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
@ -36,6 +36,15 @@ class ImgwPibSensorEntityDescription(SensorEntityDescription):
|
||||
|
||||
|
||||
SENSOR_TYPES: tuple[ImgwPibSensorEntityDescription, ...] = (
|
||||
ImgwPibSensorEntityDescription(
|
||||
key="water_flow",
|
||||
translation_key="water_flow",
|
||||
native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_SECOND,
|
||||
device_class=SensorDeviceClass.VOLUME_FLOW_RATE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
suggested_display_precision=1,
|
||||
value=lambda data: data.water_flow.value,
|
||||
),
|
||||
ImgwPibSensorEntityDescription(
|
||||
key="water_level",
|
||||
translation_key="water_level",
|
||||
|
@ -21,6 +21,9 @@
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"water_flow": {
|
||||
"name": "Water flow"
|
||||
},
|
||||
"water_level": {
|
||||
"name": "Water level"
|
||||
},
|
||||
|
@ -1,4 +1,61 @@
|
||||
# serializer version: 1
|
||||
# name: test_sensor[sensor.river_name_station_name_water_flow-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'sensor.river_name_station_name_water_flow',
|
||||
'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': 'Water flow',
|
||||
'platform': 'imgw_pib',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'water_flow',
|
||||
'unique_id': '123_water_flow',
|
||||
'unit_of_measurement': <UnitOfVolumeFlowRate.CUBIC_METERS_PER_SECOND: 'm³/s'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensor[sensor.river_name_station_name_water_flow-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by IMGW-PIB',
|
||||
'device_class': 'volume_flow_rate',
|
||||
'friendly_name': 'River Name (Station Name) Water flow',
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
'unit_of_measurement': <UnitOfVolumeFlowRate.CUBIC_METERS_PER_SECOND: 'm³/s'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.river_name_station_name_water_flow',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '123.45',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensor[sensor.river_name_station_name_water_level-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
|
Loading…
x
Reference in New Issue
Block a user