From ac3c5db989a2867ff1d6cb612711a16026497029 Mon Sep 17 00:00:00 2001 From: Aidan Timson Date: Sun, 13 Feb 2022 14:37:18 +0000 Subject: [PATCH] Handle NoneType error in OVO integration (#66439) --- homeassistant/components/ovo_energy/sensor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/ovo_energy/sensor.py b/homeassistant/components/ovo_energy/sensor.py index 8f9a18d1f11..532bb25cbc8 100644 --- a/homeassistant/components/ovo_energy/sensor.py +++ b/homeassistant/components/ovo_energy/sensor.py @@ -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",