Add energy and power sensor tests & fix device_class (#45122)

This commit is contained in:
Petro31 2021-01-13 15:37:54 -05:00 committed by GitHub
parent eca6bc6a73
commit 3ebc5d45a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 6 deletions

View file

@ -65,11 +65,9 @@ class ZwaveSensorBase(ZWaveBaseEntity):
if self.info.primary_value.command_class == CommandClass.BATTERY:
return DEVICE_CLASS_BATTERY
if self.info.primary_value.command_class == CommandClass.METER:
if self.info.primary_value.property_key_name == "kWh_Consumed":
return DEVICE_CLASS_ENERGY
return DEVICE_CLASS_POWER
if self.info.primary_value.property_key_name == "W_Consumed":
return DEVICE_CLASS_POWER
if self.info.primary_value.property_key_name == "kWh_Consumed":
return DEVICE_CLASS_ENERGY
if self.info.primary_value.property_ == "Air temperature":
return DEVICE_CLASS_TEMPERATURE
return None