From 1bb5d4754fc8b0e1da7375e7bdcaea56d404e199 Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Sat, 12 Sep 2020 14:35:24 +0200 Subject: [PATCH] Use DEVICE_CLASS_DOOR and DEVICE_CLASS_SMOKE in various integrations (#39950) --- homeassistant/components/concord232/binary_sensor.py | 3 ++- homeassistant/components/fibaro/binary_sensor.py | 6 ++++-- homeassistant/components/notion/binary_sensor.py | 10 ++++++---- .../components/satel_integra/binary_sensor.py | 7 +++++-- homeassistant/components/spc/binary_sensor.py | 7 +++++-- homeassistant/components/tahoma/binary_sensor.py | 7 +++++-- homeassistant/components/wink/binary_sensor.py | 3 ++- 7 files changed, 29 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/concord232/binary_sensor.py b/homeassistant/components/concord232/binary_sensor.py index 806fb5c513d..5ff75526b27 100644 --- a/homeassistant/components/concord232/binary_sensor.py +++ b/homeassistant/components/concord232/binary_sensor.py @@ -8,6 +8,7 @@ import voluptuous as vol from homeassistant.components.binary_sensor import ( DEVICE_CLASS_SAFETY, + DEVICE_CLASS_SMOKE, DEVICE_CLASSES, PLATFORM_SCHEMA, BinarySensorEntity, @@ -90,7 +91,7 @@ def get_opening_type(zone): if "KEY" in zone["name"]: return DEVICE_CLASS_SAFETY if "SMOKE" in zone["name"]: - return "smoke" + return DEVICE_CLASS_SMOKE if "WATER" in zone["name"]: return "water" return "opening" diff --git a/homeassistant/components/fibaro/binary_sensor.py b/homeassistant/components/fibaro/binary_sensor.py index bd327e7de3d..42783df9df6 100644 --- a/homeassistant/components/fibaro/binary_sensor.py +++ b/homeassistant/components/fibaro/binary_sensor.py @@ -2,6 +2,8 @@ import logging from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_DOOR, + DEVICE_CLASS_SMOKE, DEVICE_CLASS_WINDOW, DOMAIN, BinarySensorEntity, @@ -15,9 +17,9 @@ _LOGGER = logging.getLogger(__name__) SENSOR_TYPES = { "com.fibaro.floodSensor": ["Flood", "mdi:water", "flood"], "com.fibaro.motionSensor": ["Motion", "mdi:run", "motion"], - "com.fibaro.doorSensor": ["Door", "mdi:window-open", "door"], + "com.fibaro.doorSensor": ["Door", "mdi:window-open", DEVICE_CLASS_DOOR], "com.fibaro.windowSensor": ["Window", "mdi:window-open", DEVICE_CLASS_WINDOW], - "com.fibaro.smokeSensor": ["Smoke", "mdi:smoking", "smoke"], + "com.fibaro.smokeSensor": ["Smoke", "mdi:smoking", DEVICE_CLASS_SMOKE], "com.fibaro.FGMS001": ["Motion", "mdi:run", "motion"], "com.fibaro.heatDetector": ["Heat", "mdi:fire", "heat"], } diff --git a/homeassistant/components/notion/binary_sensor.py b/homeassistant/components/notion/binary_sensor.py index 74d7cabddd3..3d02e364021 100644 --- a/homeassistant/components/notion/binary_sensor.py +++ b/homeassistant/components/notion/binary_sensor.py @@ -3,6 +3,8 @@ import logging from typing import Callable from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_DOOR, + DEVICE_CLASS_SMOKE, DEVICE_CLASS_WINDOW, BinarySensorEntity, ) @@ -29,13 +31,13 @@ _LOGGER = logging.getLogger(__name__) BINARY_SENSOR_TYPES = { SENSOR_BATTERY: ("Low Battery", "battery"), - SENSOR_DOOR: ("Door", "door"), + SENSOR_DOOR: ("Door", DEVICE_CLASS_DOOR), SENSOR_GARAGE_DOOR: ("Garage Door", "garage_door"), SENSOR_LEAK: ("Leak Detector", "moisture"), SENSOR_MISSING: ("Missing", "connectivity"), - SENSOR_SAFE: ("Safe", "door"), - SENSOR_SLIDING: ("Sliding Door/Window", "door"), - SENSOR_SMOKE_CO: ("Smoke/Carbon Monoxide Detector", "smoke"), + SENSOR_SAFE: ("Safe", DEVICE_CLASS_DOOR), + SENSOR_SLIDING: ("Sliding Door/Window", DEVICE_CLASS_DOOR), + SENSOR_SMOKE_CO: ("Smoke/Carbon Monoxide Detector", DEVICE_CLASS_SMOKE), SENSOR_WINDOW_HINGED_HORIZONTAL: ("Hinged Window", DEVICE_CLASS_WINDOW), SENSOR_WINDOW_HINGED_VERTICAL: ("Hinged Window", DEVICE_CLASS_WINDOW), } diff --git a/homeassistant/components/satel_integra/binary_sensor.py b/homeassistant/components/satel_integra/binary_sensor.py index 19763903f27..ea9c19376f6 100644 --- a/homeassistant/components/satel_integra/binary_sensor.py +++ b/homeassistant/components/satel_integra/binary_sensor.py @@ -1,7 +1,10 @@ """Support for Satel Integra zone states- represented as binary sensors.""" import logging -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_SMOKE, + BinarySensorEntity, +) from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -89,7 +92,7 @@ class SatelIntegraBinarySensor(BinarySensorEntity): @property def icon(self): """Icon for device by its type.""" - if self._zone_type == "smoke": + if self._zone_type == DEVICE_CLASS_SMOKE: return "mdi:fire" @property diff --git a/homeassistant/components/spc/binary_sensor.py b/homeassistant/components/spc/binary_sensor.py index 75256b60cfb..faa803b25dd 100644 --- a/homeassistant/components/spc/binary_sensor.py +++ b/homeassistant/components/spc/binary_sensor.py @@ -3,7 +3,10 @@ import logging from pyspcwebgw.const import ZoneInput, ZoneType -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_SMOKE, + BinarySensorEntity, +) from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -16,7 +19,7 @@ def _get_device_class(zone_type): return { ZoneType.ALARM: "motion", ZoneType.ENTRY_EXIT: "opening", - ZoneType.FIRE: "smoke", + ZoneType.FIRE: DEVICE_CLASS_SMOKE, ZoneType.TECHNICAL: "power", }.get(zone_type) diff --git a/homeassistant/components/tahoma/binary_sensor.py b/homeassistant/components/tahoma/binary_sensor.py index 39e492601bd..af06bf5ca4c 100644 --- a/homeassistant/components/tahoma/binary_sensor.py +++ b/homeassistant/components/tahoma/binary_sensor.py @@ -2,7 +2,10 @@ from datetime import timedelta import logging -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_SMOKE, + BinarySensorEntity, +) from homeassistant.const import ATTR_BATTERY_LEVEL, STATE_OFF, STATE_ON from . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice @@ -45,7 +48,7 @@ class TahomaBinarySensor(TahomaDevice, BinarySensorEntity): def device_class(self): """Return the class of the device.""" if self.tahoma_device.type == "rtds:RTDSSmokeSensor": - return "smoke" + return DEVICE_CLASS_SMOKE return None @property diff --git a/homeassistant/components/wink/binary_sensor.py b/homeassistant/components/wink/binary_sensor.py index 34bb4feee56..d4443f31ab6 100644 --- a/homeassistant/components/wink/binary_sensor.py +++ b/homeassistant/components/wink/binary_sensor.py @@ -4,6 +4,7 @@ import logging import pywink from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_SMOKE, DEVICE_CLASS_SOUND, DEVICE_CLASS_VIBRATION, BinarySensorEntity, @@ -25,7 +26,7 @@ SENSOR_TYPES = { "noise": DEVICE_CLASS_SOUND, "opened": "opening", "presence": "occupancy", - "smoke_detected": "smoke", + "smoke_detected": DEVICE_CLASS_SMOKE, "vibration": DEVICE_CLASS_VIBRATION, }