Round imperial values to two decimals in bmw_connected_drive (#62531)

Co-authored-by: rikroe <rikroe@users.noreply.github.com>
This commit is contained in:
rikroe 2021-12-22 12:27:36 +01:00 committed by GitHub
parent 89526fe86c
commit f40870b4d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,7 +73,7 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
unit_metric=LENGTH_KILOMETERS, unit_metric=LENGTH_KILOMETERS,
unit_imperial=LENGTH_MILES, unit_imperial=LENGTH_MILES,
value=lambda x, hass: round( value=lambda x, hass: round(
hass.config.units.length(x[0], UNIT_MAP.get(x[1], x[1])) hass.config.units.length(x[0], UNIT_MAP.get(x[1], x[1])), 2
), ),
), ),
"remaining_range_total": BMWSensorEntityDescription( "remaining_range_total": BMWSensorEntityDescription(
@ -82,7 +82,7 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
unit_metric=LENGTH_KILOMETERS, unit_metric=LENGTH_KILOMETERS,
unit_imperial=LENGTH_MILES, unit_imperial=LENGTH_MILES,
value=lambda x, hass: round( value=lambda x, hass: round(
hass.config.units.length(x[0], UNIT_MAP.get(x[1], x[1])) hass.config.units.length(x[0], UNIT_MAP.get(x[1], x[1])), 2
), ),
), ),
"remaining_range_electric": BMWSensorEntityDescription( "remaining_range_electric": BMWSensorEntityDescription(
@ -91,7 +91,7 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
unit_metric=LENGTH_KILOMETERS, unit_metric=LENGTH_KILOMETERS,
unit_imperial=LENGTH_MILES, unit_imperial=LENGTH_MILES,
value=lambda x, hass: round( value=lambda x, hass: round(
hass.config.units.length(x[0], UNIT_MAP.get(x[1], x[1])) hass.config.units.length(x[0], UNIT_MAP.get(x[1], x[1])), 2
), ),
), ),
"remaining_range_fuel": BMWSensorEntityDescription( "remaining_range_fuel": BMWSensorEntityDescription(
@ -100,7 +100,7 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
unit_metric=LENGTH_KILOMETERS, unit_metric=LENGTH_KILOMETERS,
unit_imperial=LENGTH_MILES, unit_imperial=LENGTH_MILES,
value=lambda x, hass: round( value=lambda x, hass: round(
hass.config.units.length(x[0], UNIT_MAP.get(x[1], x[1])) hass.config.units.length(x[0], UNIT_MAP.get(x[1], x[1])), 2
), ),
), ),
"remaining_fuel": BMWSensorEntityDescription( "remaining_fuel": BMWSensorEntityDescription(
@ -109,7 +109,7 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
unit_metric=VOLUME_LITERS, unit_metric=VOLUME_LITERS,
unit_imperial=VOLUME_GALLONS, unit_imperial=VOLUME_GALLONS,
value=lambda x, hass: round( value=lambda x, hass: round(
hass.config.units.volume(x[0], UNIT_MAP.get(x[1], x[1])) hass.config.units.volume(x[0], UNIT_MAP.get(x[1], x[1])), 2
), ),
), ),
"fuel_percent": BMWSensorEntityDescription( "fuel_percent": BMWSensorEntityDescription(