Fix zwave_js sensor device class attribute error (#45863)

This commit is contained in:
Martin Hjelmare 2021-02-02 16:25:43 +01:00 committed by GitHub
parent 811bbb7acb
commit c93fec34b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -73,7 +73,10 @@ class ZwaveSensorBase(ZWaveBaseEntity):
if self.info.primary_value.metadata.unit == "kWh":
return DEVICE_CLASS_ENERGY
return DEVICE_CLASS_POWER
if "temperature" in self.info.primary_value.property_.lower():
if (
isinstance(self.info.primary_value.property_, str)
and "temperature" in self.info.primary_value.property_.lower()
):
return DEVICE_CLASS_TEMPERATURE
if self.info.primary_value.metadata.unit == "W":
return DEVICE_CLASS_POWER