Remove precision in streamlabs water (#107096)

This commit is contained in:
Joost Lekkerkerker 2024-01-04 21:41:45 +01:00 committed by GitHub
parent 11170c6345
commit eee6693855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 6 deletions

View File

@ -50,8 +50,8 @@ class StreamlabsCoordinator(DataUpdateCoordinator[dict[str, StreamlabsData]]):
res[location_id] = StreamlabsData(
is_away=location["homeAway"] == "away",
name=location["name"],
daily_usage=round(water_usage["today"], 1),
monthly_usage=round(water_usage["thisMonth"], 1),
yearly_usage=round(water_usage["thisYear"], 1),
daily_usage=water_usage["today"],
monthly_usage=water_usage["thisMonth"],
yearly_usage=water_usage["thisYear"],
)
return res

View File

@ -35,6 +35,7 @@ SENSORS: tuple[StreamlabsWaterSensorEntityDescription, ...] = (
translation_key="daily_usage",
native_unit_of_measurement=UnitOfVolume.GALLONS,
device_class=SensorDeviceClass.WATER,
suggested_display_precision=1,
value_fn=lambda data: data.daily_usage,
),
StreamlabsWaterSensorEntityDescription(
@ -42,6 +43,7 @@ SENSORS: tuple[StreamlabsWaterSensorEntityDescription, ...] = (
translation_key="monthly_usage",
native_unit_of_measurement=UnitOfVolume.GALLONS,
device_class=SensorDeviceClass.WATER,
suggested_display_precision=1,
value_fn=lambda data: data.monthly_usage,
),
StreamlabsWaterSensorEntityDescription(
@ -49,6 +51,7 @@ SENSORS: tuple[StreamlabsWaterSensorEntityDescription, ...] = (
translation_key="yearly_usage",
native_unit_of_measurement=UnitOfVolume.GALLONS,
device_class=SensorDeviceClass.WATER,
suggested_display_precision=1,
value_fn=lambda data: data.yearly_usage,
),
)

View File

@ -18,6 +18,9 @@
'id': <ANY>,
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.WATER: 'water'>,
'original_icon': None,
@ -41,7 +44,7 @@
'entity_id': 'sensor.water_monitor_daily_usage',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': '200.4',
'state': '200.44691536',
})
# ---
# name: test_all_entities[sensor.water_monitor_monthly_usage-entry]
@ -63,6 +66,9 @@
'id': <ANY>,
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.WATER: 'water'>,
'original_icon': None,
@ -86,7 +92,7 @@
'entity_id': 'sensor.water_monitor_monthly_usage',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': '420.5',
'state': '420.514099294',
})
# ---
# name: test_all_entities[sensor.water_monitor_yearly_usage-entry]
@ -108,6 +114,9 @@
'id': <ANY>,
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.WATER: 'water'>,
'original_icon': None,
@ -131,6 +140,6 @@
'entity_id': 'sensor.water_monitor_yearly_usage',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': '65432.4',
'state': '65432.389256934',
})
# ---