Use default None for voltage property of FritzDevice in Fritz!Smarthome (#73141)
use default None for device.voltage
This commit is contained in:
parent
d587e4769a
commit
eca6768016
1 changed files with 4 additions and 2 deletions
|
@ -96,7 +96,9 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
|
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
|
||||||
native_value=lambda device: device.voltage / 1000 if device.voltage else 0.0,
|
native_value=lambda device: device.voltage / 1000
|
||||||
|
if getattr(device, "voltage", None)
|
||||||
|
else 0.0,
|
||||||
),
|
),
|
||||||
FritzSensorEntityDescription(
|
FritzSensorEntityDescription(
|
||||||
key="electric_current",
|
key="electric_current",
|
||||||
|
@ -106,7 +108,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
|
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
|
||||||
native_value=lambda device: device.power / device.voltage
|
native_value=lambda device: device.power / device.voltage
|
||||||
if device.power and device.voltage
|
if device.power and getattr(device, "voltage", None)
|
||||||
else 0.0,
|
else 0.0,
|
||||||
),
|
),
|
||||||
FritzSensorEntityDescription(
|
FritzSensorEntityDescription(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue