Fix round typing [homewizard] (#82628)

This commit is contained in:
Marc Mueller 2022-11-24 13:46:39 +01:00 committed by GitHub
parent 4c38a5d773
commit 072bbcf203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,8 @@
"""Creates HomeWizard Number entities."""
from __future__ import annotations
from typing import Optional, cast
from homeassistant.components.number import NumberEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE
@ -60,6 +62,7 @@ class HWEnergyNumberEntity(
@property
def native_value(self) -> float | None:
"""Return the current value."""
if self.coordinator.data["state"].brightness is None:
brightness = cast(Optional[float], self.coordinator.data["state"].brightness)
if brightness is None:
return None
return round(self.coordinator.data["state"].brightness * (100 / 255))
return round(brightness * (100 / 255))