Fix ZeroDivisionError on freebox/sensor (#57077)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
pull/58594/head
Dave Lowper 2021-10-28 09:30:06 +02:00 committed by GitHub
parent f28de7891d
commit 892df608e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -177,6 +177,9 @@ class FreeboxDiskSensor(FreeboxSensor):
@callback @callback
def async_update_state(self) -> None: def async_update_state(self) -> None:
"""Update the Freebox disk sensor.""" """Update the Freebox disk sensor."""
self._attr_native_value = round( value = None
self._partition["free_bytes"] * 100 / self._partition["total_bytes"], 2 if self._partition.get("total_bytes"):
) value = round(
self._partition["free_bytes"] * 100 / self._partition["total_bytes"], 2
)
self._attr_native_value = value