From 867cbeedb98c666cda686d213ba8dc6eb9778599 Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Sun, 19 Dec 2021 07:30:16 -0500 Subject: [PATCH] Use enums in zwave (#62131) Co-authored-by: Franck Nijhof --- homeassistant/components/zwave/binary_sensor.py | 2 +- homeassistant/components/zwave/cover.py | 5 +++-- homeassistant/components/zwave/sensor.py | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/zwave/binary_sensor.py b/homeassistant/components/zwave/binary_sensor.py index 094279c4e7a..e85daffec3c 100644 --- a/homeassistant/components/zwave/binary_sensor.py +++ b/homeassistant/components/zwave/binary_sensor.py @@ -59,7 +59,7 @@ class ZWaveBinarySensor(BinarySensorEntity, ZWaveDeviceEntity): @property def device_class(self): - """Return the class of this sensor, from DEVICE_CLASSES.""" + """Return the class of this sensor, from BinarySensorDeviceClass.""" return self._sensor_type diff --git a/homeassistant/components/zwave/cover.py b/homeassistant/components/zwave/cover.py index 688ee666676..fc88db56ae7 100644 --- a/homeassistant/components/zwave/cover.py +++ b/homeassistant/components/zwave/cover.py @@ -6,6 +6,7 @@ from homeassistant.components.cover import ( DOMAIN, SUPPORT_CLOSE, SUPPORT_OPEN, + CoverDeviceClass, CoverEntity, ) from homeassistant.core import callback @@ -156,8 +157,8 @@ class ZwaveGarageDoorBase(ZWaveDeviceEntity, CoverEntity): @property def device_class(self): - """Return the class of this device, from component DEVICE_CLASSES.""" - return "garage" + """Return the class of this device, from CoverDeviceClass.""" + return CoverDeviceClass.GARAGE @property def supported_features(self): diff --git a/homeassistant/components/zwave/sensor.py b/homeassistant/components/zwave/sensor.py index 75046c2f9d8..894bac8a292 100644 --- a/homeassistant/components/zwave/sensor.py +++ b/homeassistant/components/zwave/sensor.py @@ -1,6 +1,6 @@ """Support for Z-Wave sensors.""" -from homeassistant.components.sensor import DEVICE_CLASS_BATTERY, DOMAIN, SensorEntity -from homeassistant.const import DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT +from homeassistant.components.sensor import DOMAIN, SensorDeviceClass, SensorEntity +from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -83,7 +83,7 @@ class ZWaveMultilevelSensor(ZWaveSensor): def device_class(self): """Return the class of this device.""" if self._units in ["C", "F"]: - return DEVICE_CLASS_TEMPERATURE + return SensorDeviceClass.TEMPERATURE return None @property @@ -115,4 +115,4 @@ class ZWaveBatterySensor(ZWaveSensor): @property def device_class(self): """Return the class of this device.""" - return DEVICE_CLASS_BATTERY + return SensorDeviceClass.BATTERY