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