diff --git a/homeassistant/components/isy994/binary_sensor.py b/homeassistant/components/isy994/binary_sensor.py index 58997eaa579..f0645110b86 100644 --- a/homeassistant/components/isy994/binary_sensor.py +++ b/homeassistant/components/isy994/binary_sensor.py @@ -13,15 +13,8 @@ from pyisy.constants import ( from pyisy.nodes import Group, Node from homeassistant.components.binary_sensor import ( - DEVICE_CLASS_BATTERY, - DEVICE_CLASS_COLD, - DEVICE_CLASS_HEAT, - DEVICE_CLASS_LIGHT, - DEVICE_CLASS_MOISTURE, - DEVICE_CLASS_MOTION, - DEVICE_CLASS_OPENING, - DEVICE_CLASS_PROBLEM, DOMAIN as BINARY_SENSOR, + BinarySensorDeviceClass, BinarySensorEntity, ) from homeassistant.config_entries import ConfigEntry @@ -52,9 +45,9 @@ from .entity import ISYNodeEntity, ISYProgramEntity from .helpers import migrate_old_unique_ids DEVICE_PARENT_REQUIRED = [ - DEVICE_CLASS_OPENING, - DEVICE_CLASS_MOISTURE, - DEVICE_CLASS_MOTION, + BinarySensorDeviceClass.OPENING, + BinarySensorDeviceClass.MOISTURE, + BinarySensorDeviceClass.MOTION, ] @@ -94,11 +87,15 @@ async def async_setup_entry( # detected after an ISY Restart, so we assume it's off. # As soon as the ISY Event Stream connects if it has a # valid state, it will be set. - device = ISYInsteonBinarySensorEntity(node, DEVICE_CLASS_COLD, False) + device = ISYInsteonBinarySensorEntity( + node, BinarySensorDeviceClass.COLD, False + ) devices.append(device) elif subnode_id == SUBNODE_CLIMATE_HEAT: # Subnode 3 is the "Heat Control" sensor - device = ISYInsteonBinarySensorEntity(node, DEVICE_CLASS_HEAT, False) + device = ISYInsteonBinarySensorEntity( + node, BinarySensorDeviceClass.HEAT, False + ) devices.append(device) continue @@ -113,7 +110,10 @@ async def async_setup_entry( ) continue - if device_class in (DEVICE_CLASS_OPENING, DEVICE_CLASS_MOISTURE): + if device_class in ( + BinarySensorDeviceClass.OPENING, + BinarySensorDeviceClass.MOISTURE, + ): # These sensors use an optional "negative" subnode 2 to # snag all state changes if subnode_id == SUBNODE_NEGATIVE: @@ -126,7 +126,7 @@ async def async_setup_entry( devices.append(device) continue if ( - device_class == DEVICE_CLASS_MOTION + device_class == BinarySensorDeviceClass.MOTION and device_type is not None and any(device_type.startswith(t) for t in TYPE_INSTEON_MOTION) ): @@ -138,13 +138,15 @@ async def async_setup_entry( initial_state = None if parent_device.state is None else False if subnode_id == SUBNODE_DUSK_DAWN: # Subnode 2 is the Dusk/Dawn sensor - device = ISYInsteonBinarySensorEntity(node, DEVICE_CLASS_LIGHT) + device = ISYInsteonBinarySensorEntity( + node, BinarySensorDeviceClass.LIGHT + ) devices.append(device) continue if subnode_id == SUBNODE_LOW_BATTERY: # Subnode 3 is the low battery node device = ISYInsteonBinarySensorEntity( - node, DEVICE_CLASS_BATTERY, initial_state + node, BinarySensorDeviceClass.BATTERY, initial_state ) devices.append(device) continue @@ -152,7 +154,7 @@ async def async_setup_entry( # Tamper Sub-node for MS II. Sometimes reported as "A" sometimes # reported as "10", which translate from Hex to 10 and 16 resp. device = ISYInsteonBinarySensorEntity( - node, DEVICE_CLASS_PROBLEM, initial_state + node, BinarySensorDeviceClass.PROBLEM, initial_state ) devices.append(device) continue @@ -352,7 +354,7 @@ class ISYInsteonBinarySensorEntity(ISYBinarySensorEntity): # Do this first so we don't invert None on moisture sensors return None - if self.device_class == DEVICE_CLASS_MOISTURE: + if self.device_class == BinarySensorDeviceClass.MOISTURE: return not self._computed_state return self._computed_state @@ -454,7 +456,7 @@ class ISYBinarySensorHeartbeat(ISYNodeEntity, BinarySensorEntity): @property def device_class(self) -> str: """Get the class of this device.""" - return DEVICE_CLASS_BATTERY + return BinarySensorDeviceClass.BATTERY @property def extra_state_attributes(self): diff --git a/homeassistant/components/isy994/const.py b/homeassistant/components/isy994/const.py index 0a7b02c1dac..470aaa64c64 100644 --- a/homeassistant/components/isy994/const.py +++ b/homeassistant/components/isy994/const.py @@ -1,21 +1,7 @@ """Constants for the ISY994 Platform.""" import logging -from homeassistant.components.binary_sensor import ( - DEVICE_CLASS_BATTERY, - DEVICE_CLASS_COLD, - DEVICE_CLASS_DOOR, - DEVICE_CLASS_GAS, - DEVICE_CLASS_HEAT, - DEVICE_CLASS_MOISTURE, - DEVICE_CLASS_MOTION, - DEVICE_CLASS_OPENING, - DEVICE_CLASS_PROBLEM, - DEVICE_CLASS_SAFETY, - DEVICE_CLASS_SMOKE, - DEVICE_CLASS_SOUND, - DEVICE_CLASS_VIBRATION, -) +from homeassistant.components.binary_sensor import BinarySensorDeviceClass from homeassistant.components.climate.const import ( CURRENT_HVAC_COOL, CURRENT_HVAC_FAN, @@ -651,8 +637,8 @@ HA_HVAC_TO_ISY = { HA_FAN_TO_ISY = {FAN_ON: "on", FAN_AUTO: "auto"} BINARY_SENSOR_DEVICE_TYPES_ISY = { - DEVICE_CLASS_MOISTURE: ["16.8.", "16.13.", "16.14."], - DEVICE_CLASS_OPENING: [ + BinarySensorDeviceClass.MOISTURE: ["16.8.", "16.13.", "16.14."], + BinarySensorDeviceClass.OPENING: [ "16.9.", "16.6.", "16.7.", @@ -661,22 +647,22 @@ BINARY_SENSOR_DEVICE_TYPES_ISY = { "16.20.", "16.21.", ], - DEVICE_CLASS_MOTION: ["16.1.", "16.4.", "16.5.", "16.3.", "16.22."], + BinarySensorDeviceClass.MOTION: ["16.1.", "16.4.", "16.5.", "16.3.", "16.22."], } BINARY_SENSOR_DEVICE_TYPES_ZWAVE = { - DEVICE_CLASS_SAFETY: ["137", "172", "176", "177", "178"], - DEVICE_CLASS_SMOKE: ["138", "156"], - DEVICE_CLASS_PROBLEM: ["148", "149", "157", "158", "164", "174", "175"], - DEVICE_CLASS_GAS: ["150", "151"], - DEVICE_CLASS_SOUND: ["153"], - DEVICE_CLASS_COLD: ["152", "168"], - DEVICE_CLASS_HEAT: ["154", "166", "167"], - DEVICE_CLASS_MOISTURE: ["159", "169"], - DEVICE_CLASS_DOOR: ["160"], - DEVICE_CLASS_BATTERY: ["162"], - DEVICE_CLASS_MOTION: ["155"], - DEVICE_CLASS_VIBRATION: ["173"], + BinarySensorDeviceClass.SAFETY: ["137", "172", "176", "177", "178"], + BinarySensorDeviceClass.SMOKE: ["138", "156"], + BinarySensorDeviceClass.PROBLEM: ["148", "149", "157", "158", "164", "174", "175"], + BinarySensorDeviceClass.GAS: ["150", "151"], + BinarySensorDeviceClass.SOUND: ["153"], + BinarySensorDeviceClass.COLD: ["152", "168"], + BinarySensorDeviceClass.HEAT: ["154", "166", "167"], + BinarySensorDeviceClass.MOISTURE: ["159", "169"], + BinarySensorDeviceClass.DOOR: ["160"], + BinarySensorDeviceClass.BATTERY: ["162"], + BinarySensorDeviceClass.MOTION: ["155"], + BinarySensorDeviceClass.VIBRATION: ["173"], }