Fix SAJ Solar inverter RecursionError (#71157)

This commit is contained in:
Zoltán Tóth 2022-05-02 16:42:23 +02:00 committed by GitHub
parent f35e7d1129
commit a74f035ae7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -209,14 +209,11 @@ class SAJsensor(SensorEntity):
@property
def device_class(self):
"""Return the device class the sensor belongs to."""
if self.unit_of_measurement == POWER_WATT:
if self.native_unit_of_measurement == POWER_WATT:
return SensorDeviceClass.POWER
if self.unit_of_measurement == ENERGY_KILO_WATT_HOUR:
if self.native_unit_of_measurement == ENERGY_KILO_WATT_HOUR:
return SensorDeviceClass.ENERGY
if (
self.unit_of_measurement == TEMP_CELSIUS
or self._sensor.unit == TEMP_FAHRENHEIT
):
if self.native_unit_of_measurement in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
return SensorDeviceClass.TEMPERATURE
@property