From f93c0c5cd32300fe38bc86c3cda60b738db54590 Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Sat, 12 Sep 2020 04:24:23 +0200 Subject: [PATCH] Use DEVICE_CLASS_WINDOW constant in various integrations (#39949) --- homeassistant/components/brunt/cover.py | 4 ++-- homeassistant/components/deconz/cover.py | 3 ++- homeassistant/components/fibaro/binary_sensor.py | 8 ++++++-- homeassistant/components/fritzbox/binary_sensor.py | 7 +++++-- homeassistant/components/maxcube/binary_sensor.py | 7 +++++-- homeassistant/components/notion/binary_sensor.py | 9 ++++++--- homeassistant/components/somfy_mylink/cover.py | 8 ++++++-- 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/brunt/cover.py b/homeassistant/components/brunt/cover.py index 7f36874c40ef..ceb56ba03fa7 100644 --- a/homeassistant/components/brunt/cover.py +++ b/homeassistant/components/brunt/cover.py @@ -7,6 +7,7 @@ import voluptuous as vol from homeassistant.components.cover import ( ATTR_POSITION, + DEVICE_CLASS_WINDOW, PLATFORM_SCHEMA, SUPPORT_CLOSE, SUPPORT_OPEN, @@ -19,7 +20,6 @@ import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) COVER_FEATURES = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION -DEVICE_CLASS = "window" ATTR_REQUEST_POSITION = "request_position" NOTIFICATION_ID = "brunt_notification" @@ -141,7 +141,7 @@ class BruntDevice(CoverEntity): @property def device_class(self): """Return the class of this device, from component DEVICE_CLASSES.""" - return DEVICE_CLASS + return DEVICE_CLASS_WINDOW @property def supported_features(self): diff --git a/homeassistant/components/deconz/cover.py b/homeassistant/components/deconz/cover.py index e01cfdbe5f89..996727d366b8 100644 --- a/homeassistant/components/deconz/cover.py +++ b/homeassistant/components/deconz/cover.py @@ -1,6 +1,7 @@ """Support for deCONZ covers.""" from homeassistant.components.cover import ( ATTR_POSITION, + DEVICE_CLASS_WINDOW, SUPPORT_CLOSE, SUPPORT_OPEN, SUPPORT_SET_POSITION, @@ -74,7 +75,7 @@ class DeconzCover(DeconzDevice, CoverEntity): if self._device.type in DAMPERS: return "damper" if self._device.type in WINDOW_COVERS: - return "window" + return DEVICE_CLASS_WINDOW @property def supported_features(self): diff --git a/homeassistant/components/fibaro/binary_sensor.py b/homeassistant/components/fibaro/binary_sensor.py index 251bd1df6a3e..bd327e7de3d8 100644 --- a/homeassistant/components/fibaro/binary_sensor.py +++ b/homeassistant/components/fibaro/binary_sensor.py @@ -1,7 +1,11 @@ """Support for Fibaro binary sensors.""" import logging -from homeassistant.components.binary_sensor import DOMAIN, BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_WINDOW, + DOMAIN, + BinarySensorEntity, +) from homeassistant.const import CONF_DEVICE_CLASS, CONF_ICON from . import FIBARO_DEVICES, FibaroDevice @@ -12,7 +16,7 @@ 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.windowSensor": ["Window", "mdi:window-open", "window"], + "com.fibaro.windowSensor": ["Window", "mdi:window-open", DEVICE_CLASS_WINDOW], "com.fibaro.smokeSensor": ["Smoke", "mdi:smoking", "smoke"], "com.fibaro.FGMS001": ["Motion", "mdi:run", "motion"], "com.fibaro.heatDetector": ["Heat", "mdi:fire", "heat"], diff --git a/homeassistant/components/fritzbox/binary_sensor.py b/homeassistant/components/fritzbox/binary_sensor.py index 7db216c32e10..1246eb4afaf2 100644 --- a/homeassistant/components/fritzbox/binary_sensor.py +++ b/homeassistant/components/fritzbox/binary_sensor.py @@ -1,7 +1,10 @@ """Support for Fritzbox binary sensors.""" import requests -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_WINDOW, + BinarySensorEntity, +) from homeassistant.const import CONF_DEVICES from .const import CONF_CONNECTIONS, DOMAIN as FRITZBOX_DOMAIN, LOGGER @@ -53,7 +56,7 @@ class FritzboxBinarySensor(BinarySensorEntity): @property def device_class(self): """Return the class of this sensor.""" - return "window" + return DEVICE_CLASS_WINDOW @property def is_on(self): diff --git a/homeassistant/components/maxcube/binary_sensor.py b/homeassistant/components/maxcube/binary_sensor.py index b42c96f99c2f..1897f3b7465a 100644 --- a/homeassistant/components/maxcube/binary_sensor.py +++ b/homeassistant/components/maxcube/binary_sensor.py @@ -1,7 +1,10 @@ """Support for MAX! binary sensors via MAX! Cube.""" import logging -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_WINDOW, + BinarySensorEntity, +) from . import DATA_KEY @@ -30,7 +33,7 @@ class MaxCubeShutter(BinarySensorEntity): def __init__(self, handler, name, rf_address): """Initialize MAX! Cube BinarySensorEntity.""" self._name = name - self._sensor_type = "window" + self._sensor_type = DEVICE_CLASS_WINDOW self._rf_address = rf_address self._cubehandle = handler self._state = None diff --git a/homeassistant/components/notion/binary_sensor.py b/homeassistant/components/notion/binary_sensor.py index e798b5385658..74d7cabddd34 100644 --- a/homeassistant/components/notion/binary_sensor.py +++ b/homeassistant/components/notion/binary_sensor.py @@ -2,7 +2,10 @@ import logging from typing import Callable -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_WINDOW, + BinarySensorEntity, +) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback @@ -33,8 +36,8 @@ BINARY_SENSOR_TYPES = { SENSOR_SAFE: ("Safe", "door"), SENSOR_SLIDING: ("Sliding Door/Window", "door"), SENSOR_SMOKE_CO: ("Smoke/Carbon Monoxide Detector", "smoke"), - SENSOR_WINDOW_HINGED_HORIZONTAL: ("Hinged Window", "window"), - SENSOR_WINDOW_HINGED_VERTICAL: ("Hinged Window", "window"), + SENSOR_WINDOW_HINGED_HORIZONTAL: ("Hinged Window", DEVICE_CLASS_WINDOW), + SENSOR_WINDOW_HINGED_VERTICAL: ("Hinged Window", DEVICE_CLASS_WINDOW), } diff --git a/homeassistant/components/somfy_mylink/cover.py b/homeassistant/components/somfy_mylink/cover.py index b849a4909404..ac3bf0673f18 100644 --- a/homeassistant/components/somfy_mylink/cover.py +++ b/homeassistant/components/somfy_mylink/cover.py @@ -1,7 +1,11 @@ """Cover Platform for the Somfy MyLink component.""" import logging -from homeassistant.components.cover import ENTITY_ID_FORMAT, CoverEntity +from homeassistant.components.cover import ( + DEVICE_CLASS_WINDOW, + ENTITY_ID_FORMAT, + CoverEntity, +) from homeassistant.util import slugify from . import CONF_DEFAULT_REVERSE, DATA_SOMFY_MYLINK @@ -49,7 +53,7 @@ class SomfyShade(CoverEntity): target_id, name="SomfyShade", reverse=False, - device_class="window", + device_class=DEVICE_CLASS_WINDOW, ): """Initialize the cover.""" self.somfy_mylink = somfy_mylink