diff --git a/homeassistant/components/goodwe/sensor.py b/homeassistant/components/goodwe/sensor.py index 7e9abec4b2e..abb29ef080f 100644 --- a/homeassistant/components/goodwe/sensor.py +++ b/homeassistant/components/goodwe/sensor.py @@ -106,7 +106,7 @@ _DESCRIPTIONS: dict[str, GoodweSensorEntityDescription] = { device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, - value=lambda prev, val: prev if not val else val, + value=lambda prev, val: val if val else prev, available=lambda entity: entity.coordinator.data is not None, ), "C": GoodweSensorEntityDescription( diff --git a/pyproject.toml b/pyproject.toml index e57592e9f99..63b5d17ab21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -251,6 +251,7 @@ select = [ "SIM117", # Merge with-statements that use the same scope "SIM118", # Use {key} in {dict} instead of {key} in {dict}.keys() "SIM201", # Use {left} != {right} instead of not {left} == {right} + "SIM212", # Use {a} if {a} else {b} instead of {b} if not {a} else {a} "SIM300", # Yoda conditions. Use 'age == 42' instead of '42 == age'. "SIM401", # Use get from dict with default instead of an if block "T20", # flake8-print