Skip to content

Commit

Permalink
Set suggested_display_precision to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
rikroe committed Apr 10, 2024
1 parent d66af6f commit fb0c603
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 9 additions & 0 deletions homeassistant/components/bmw_connected_drive/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class BMWSensorEntityDescription(SensorEntityDescription):
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
entity_registry_enabled_default=False,
suggested_display_precision=0,
is_available=lambda v: v.is_lsc_enabled and v.has_electric_drivetrain,
),
BMWSensorEntityDescription(
Expand Down Expand Up @@ -78,6 +79,7 @@ class BMWSensorEntityDescription(SensorEntityDescription):
key_class="fuel_and_battery",
device_class=SensorDeviceClass.BATTERY,
native_unit_of_measurement=PERCENTAGE,
suggested_display_precision=0,
is_available=lambda v: v.is_lsc_enabled and v.has_electric_drivetrain,
),
BMWSensorEntityDescription(
Expand All @@ -87,6 +89,7 @@ class BMWSensorEntityDescription(SensorEntityDescription):
device_class=SensorDeviceClass.BATTERY,
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
is_available=lambda v: v.is_lsc_enabled and v.has_electric_drivetrain,
),
# --- Specific ---
Expand All @@ -96,6 +99,7 @@ class BMWSensorEntityDescription(SensorEntityDescription):
device_class=SensorDeviceClass.DISTANCE,
native_unit_of_measurement=UnitOfLength.KILOMETERS,
state_class=SensorStateClass.TOTAL_INCREASING,
suggested_display_precision=0,
),
BMWSensorEntityDescription(
key="remaining_range_total",
Expand All @@ -104,6 +108,7 @@ class BMWSensorEntityDescription(SensorEntityDescription):
device_class=SensorDeviceClass.DISTANCE,
native_unit_of_measurement=UnitOfLength.KILOMETERS,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
),
BMWSensorEntityDescription(
key="remaining_range_electric",
Expand All @@ -112,6 +117,7 @@ class BMWSensorEntityDescription(SensorEntityDescription):
device_class=SensorDeviceClass.DISTANCE,
native_unit_of_measurement=UnitOfLength.KILOMETERS,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
is_available=lambda v: v.is_lsc_enabled and v.has_electric_drivetrain,
),
BMWSensorEntityDescription(
Expand All @@ -121,6 +127,7 @@ class BMWSensorEntityDescription(SensorEntityDescription):
device_class=SensorDeviceClass.DISTANCE,
native_unit_of_measurement=UnitOfLength.KILOMETERS,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
is_available=lambda v: v.is_lsc_enabled and v.has_combustion_drivetrain,
),
BMWSensorEntityDescription(
Expand All @@ -130,6 +137,7 @@ class BMWSensorEntityDescription(SensorEntityDescription):
device_class=SensorDeviceClass.VOLUME,
native_unit_of_measurement=UnitOfVolume.LITERS,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
is_available=lambda v: v.is_lsc_enabled and v.has_combustion_drivetrain,
),
BMWSensorEntityDescription(
Expand All @@ -138,6 +146,7 @@ class BMWSensorEntityDescription(SensorEntityDescription):
key_class="fuel_and_battery",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=0,
is_available=lambda v: v.is_lsc_enabled and v.has_combustion_drivetrain,
),
]
Expand Down
10 changes: 5 additions & 5 deletions tests/components/bmw_connected_drive/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ async def test_entity_state_attrs(
("entity_id", "unit_system", "value", "unit_of_measurement"),
[
("sensor.i3_rex_remaining_range_total", METRIC, "279", "km"),
("sensor.i3_rex_remaining_range_total", IMPERIAL, "173", "mi"),
("sensor.i3_rex_remaining_range_total", IMPERIAL, "173.362562634216", "mi"),
("sensor.i3_rex_mileage", METRIC, "137009", "km"),
("sensor.i3_rex_mileage", IMPERIAL, "85133", "mi"),
("sensor.i3_rex_mileage", IMPERIAL, "85133.4456772449", "mi"),
("sensor.i3_rex_remaining_battery_percent", METRIC, "82", "%"),
("sensor.i3_rex_remaining_battery_percent", IMPERIAL, "82", "%"),
("sensor.i3_rex_remaining_range_electric", METRIC, "174", "km"),
("sensor.i3_rex_remaining_range_electric", IMPERIAL, "108", "mi"),
("sensor.i3_rex_remaining_range_electric", IMPERIAL, "108.118587449296", "mi"),
("sensor.i3_rex_remaining_fuel", METRIC, "6", "L"),
("sensor.i3_rex_remaining_fuel", IMPERIAL, "2", "gal"),
("sensor.i3_rex_remaining_fuel", IMPERIAL, "1.58503231414889", "gal"),
("sensor.i3_rex_remaining_range_fuel", METRIC, "105", "km"),
("sensor.i3_rex_remaining_range_fuel", IMPERIAL, "65", "mi"),
("sensor.i3_rex_remaining_range_fuel", IMPERIAL, "65.2439751849201", "mi"),
("sensor.m340i_xdrive_remaining_fuel_percent", METRIC, "80", "%"),
("sensor.m340i_xdrive_remaining_fuel_percent", IMPERIAL, "80", "%"),
],
Expand Down

0 comments on commit fb0c603

Please sign in to comment.