Handle NoneType error in OVO integration (#66439)

This commit is contained in:
Aidan Timson 2022-02-13 14:37:18 +00:00 committed by GitHub
parent b4c487376f
commit ac3c5db989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,7 +54,9 @@ SENSOR_TYPES_ELECTRICITY: tuple[OVOEnergySensorEntityDescription, ...] = (
name="OVO Last Electricity Cost",
device_class=SensorDeviceClass.MONETARY,
state_class=SensorStateClass.TOTAL_INCREASING,
value=lambda usage: usage.electricity[-1].cost.amount,
value=lambda usage: usage.electricity[-1].cost.amount
if usage.electricity[-1].cost is not None
else None,
),
OVOEnergySensorEntityDescription(
key="last_electricity_start_time",
@ -88,7 +90,9 @@ SENSOR_TYPES_GAS: tuple[OVOEnergySensorEntityDescription, ...] = (
device_class=SensorDeviceClass.MONETARY,
state_class=SensorStateClass.TOTAL_INCREASING,
icon="mdi:cash-multiple",
value=lambda usage: usage.gas[-1].cost.amount,
value=lambda usage: usage.gas[-1].cost.amount
if usage.gas[-1].cost is not None
else None,
),
OVOEnergySensorEntityDescription(
key="last_gas_start_time",