Set suggested display precision in La Crosse View (#138355)

* Set suggested display precision in La Crosse View

* Switch to entity descriptions
This commit is contained in:
IceBotYT
2025-02-13 02:37:46 -05:00
committed by GitHub
parent 81cac25bd0
commit 1ac16f6dbf
2 changed files with 10 additions and 1 deletions

View File

@@ -64,6 +64,7 @@ SENSOR_DESCRIPTIONS = {
state_class=SensorStateClass.MEASUREMENT,
value_fn=get_value,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
suggested_display_precision=2,
),
"Humidity": LaCrosseSensorEntityDescription(
key="Humidity",
@@ -71,6 +72,7 @@ SENSOR_DESCRIPTIONS = {
state_class=SensorStateClass.MEASUREMENT,
value_fn=get_value,
native_unit_of_measurement=PERCENTAGE,
suggested_display_precision=2,
),
"HeatIndex": LaCrosseSensorEntityDescription(
key="HeatIndex",
@@ -79,6 +81,7 @@ SENSOR_DESCRIPTIONS = {
state_class=SensorStateClass.MEASUREMENT,
value_fn=get_value,
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
suggested_display_precision=2,
),
"WindSpeed": LaCrosseSensorEntityDescription(
key="WindSpeed",
@@ -86,6 +89,7 @@ SENSOR_DESCRIPTIONS = {
value_fn=get_value,
native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.WIND_SPEED,
suggested_display_precision=2,
),
"Rain": LaCrosseSensorEntityDescription(
key="Rain",
@@ -93,12 +97,14 @@ SENSOR_DESCRIPTIONS = {
value_fn=get_value,
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
device_class=SensorDeviceClass.PRECIPITATION,
suggested_display_precision=2,
),
"WindHeading": LaCrosseSensorEntityDescription(
key="WindHeading",
translation_key="wind_heading",
value_fn=get_value,
native_unit_of_measurement=DEGREE,
suggested_display_precision=2,
),
"WetDry": LaCrosseSensorEntityDescription(
key="WetDry",
@@ -117,6 +123,7 @@ SENSOR_DESCRIPTIONS = {
value_fn=get_value,
device_class=SensorDeviceClass.ATMOSPHERIC_PRESSURE,
native_unit_of_measurement=UnitOfPressure.HPA,
suggested_display_precision=2,
),
"FeelsLike": LaCrosseSensorEntityDescription(
key="FeelsLike",
@@ -125,6 +132,7 @@ SENSOR_DESCRIPTIONS = {
value_fn=get_value,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
suggested_display_precision=2,
),
"WindChill": LaCrosseSensorEntityDescription(
key="WindChill",
@@ -133,6 +141,7 @@ SENSOR_DESCRIPTIONS = {
value_fn=get_value,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
suggested_display_precision=2,
),
}
# map of API returned unit of measurement strings to their corresponding unit of measurement

View File

@@ -117,7 +117,7 @@ async def test_field_not_supported(
(TEST_STRING_SENSOR, "dry", "wet_dry"),
(TEST_ALREADY_FLOAT_SENSOR, "-16.5", "heat_index"),
(TEST_ALREADY_INT_SENSOR, "2", "wind_speed"),
(TEST_UNITS_OVERRIDE_SENSOR, "-16.6", "temperature"),
(TEST_UNITS_OVERRIDE_SENSOR, "-16.6111111111111", "temperature"),
],
)
async def test_field_types(