diff --git a/homeassistant/components/concord232/binary_sensor.py b/homeassistant/components/concord232/binary_sensor.py index 3077056c397..806fb5c513d 100644 --- a/homeassistant/components/concord232/binary_sensor.py +++ b/homeassistant/components/concord232/binary_sensor.py @@ -7,6 +7,7 @@ import requests import voluptuous as vol from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_SAFETY, DEVICE_CLASSES, PLATFORM_SCHEMA, BinarySensorEntity, @@ -87,7 +88,7 @@ def get_opening_type(zone): if "MOTION" in zone["name"]: return "motion" if "KEY" in zone["name"]: - return "safety" + return DEVICE_CLASS_SAFETY if "SMOKE" in zone["name"]: return "smoke" if "WATER" in zone["name"]: diff --git a/homeassistant/components/ffmpeg_noise/binary_sensor.py b/homeassistant/components/ffmpeg_noise/binary_sensor.py index 6ada2bb2748..387f25afe6e 100644 --- a/homeassistant/components/ffmpeg_noise/binary_sensor.py +++ b/homeassistant/components/ffmpeg_noise/binary_sensor.py @@ -4,7 +4,7 @@ import logging import haffmpeg.sensor as ffmpeg_sensor import voluptuous as vol -from homeassistant.components.binary_sensor import PLATFORM_SCHEMA +from homeassistant.components.binary_sensor import DEVICE_CLASS_SOUND, PLATFORM_SCHEMA from homeassistant.components.ffmpeg import ( CONF_EXTRA_ARGUMENTS, CONF_INITIAL_STATE, @@ -84,4 +84,4 @@ class FFmpegNoise(FFmpegBinarySensor): @property def device_class(self): """Return the class of this sensor, from DEVICE_CLASSES.""" - return "sound" + return DEVICE_CLASS_SOUND diff --git a/homeassistant/components/meteoalarm/binary_sensor.py b/homeassistant/components/meteoalarm/binary_sensor.py index b481b417b9e..6b13d03ebba 100644 --- a/homeassistant/components/meteoalarm/binary_sensor.py +++ b/homeassistant/components/meteoalarm/binary_sensor.py @@ -5,7 +5,11 @@ import logging from meteoalertapi import Meteoalert import voluptuous as vol -from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_SAFETY, + PLATFORM_SCHEMA, + BinarySensorEntity, +) from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME import homeassistant.helpers.config_validation as cv @@ -17,7 +21,6 @@ CONF_COUNTRY = "country" CONF_LANGUAGE = "language" CONF_PROVINCE = "province" -DEFAULT_DEVICE_CLASS = "safety" DEFAULT_NAME = "meteoalarm" SCAN_INTERVAL = timedelta(minutes=30) @@ -78,7 +81,7 @@ class MeteoAlertBinarySensor(BinarySensorEntity): @property def device_class(self): """Return the device class of this binary sensor.""" - return DEFAULT_DEVICE_CLASS + return DEVICE_CLASS_SAFETY def update(self): """Update device state.""" diff --git a/homeassistant/components/mysensors/binary_sensor.py b/homeassistant/components/mysensors/binary_sensor.py index 0bab6ea6eea..406f82c845e 100644 --- a/homeassistant/components/mysensors/binary_sensor.py +++ b/homeassistant/components/mysensors/binary_sensor.py @@ -1,6 +1,9 @@ """Support for MySensors binary sensors.""" from homeassistant.components import mysensors from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_SAFETY, + DEVICE_CLASS_SOUND, + DEVICE_CLASS_VIBRATION, DEVICE_CLASSES, DOMAIN, BinarySensorEntity, @@ -11,10 +14,10 @@ SENSORS = { "S_DOOR": "door", "S_MOTION": "motion", "S_SMOKE": "smoke", - "S_SPRINKLER": "safety", - "S_WATER_LEAK": "safety", - "S_SOUND": "sound", - "S_VIBRATION": "vibration", + "S_SPRINKLER": DEVICE_CLASS_SAFETY, + "S_WATER_LEAK": DEVICE_CLASS_SAFETY, + "S_SOUND": DEVICE_CLASS_SOUND, + "S_VIBRATION": DEVICE_CLASS_VIBRATION, "S_MOISTURE": "moisture", } diff --git a/homeassistant/components/nest/binary_sensor.py b/homeassistant/components/nest/binary_sensor.py index dd52e1d665f..d4c9b6ca35d 100644 --- a/homeassistant/components/nest/binary_sensor.py +++ b/homeassistant/components/nest/binary_sensor.py @@ -2,7 +2,10 @@ from itertools import chain import logging -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_SOUND, + BinarySensorEntity, +) from homeassistant.const import CONF_MONITORED_CONDITIONS from . import CONF_BINARY_SENSORS, DATA_NEST, DATA_NEST_CONFIG, NestSensorDevice @@ -20,7 +23,7 @@ CLIMATE_BINARY_TYPES = { CAMERA_BINARY_TYPES = { "motion_detected": "motion", - "sound_detected": "sound", + "sound_detected": DEVICE_CLASS_SOUND, "person_detected": "occupancy", } diff --git a/homeassistant/components/smartthings/binary_sensor.py b/homeassistant/components/smartthings/binary_sensor.py index 825cf149952..4e555aece22 100644 --- a/homeassistant/components/smartthings/binary_sensor.py +++ b/homeassistant/components/smartthings/binary_sensor.py @@ -3,7 +3,10 @@ from typing import Optional, Sequence from pysmartthings import Attribute, Capability -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_SOUND, + BinarySensorEntity, +) from . import SmartThingsEntity from .const import DATA_BROKERS, DOMAIN @@ -25,7 +28,7 @@ ATTRIB_TO_CLASS = { Attribute.filter_status: "problem", Attribute.motion: "motion", Attribute.presence: "presence", - Attribute.sound: "sound", + Attribute.sound: DEVICE_CLASS_SOUND, Attribute.tamper: "problem", Attribute.valve: "opening", Attribute.water: "moisture", diff --git a/homeassistant/components/wink/binary_sensor.py b/homeassistant/components/wink/binary_sensor.py index d8967dd064d..34bb4feee56 100644 --- a/homeassistant/components/wink/binary_sensor.py +++ b/homeassistant/components/wink/binary_sensor.py @@ -3,7 +3,11 @@ import logging import pywink -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_SOUND, + DEVICE_CLASS_VIBRATION, + BinarySensorEntity, +) from . import DOMAIN, WinkDevice @@ -12,17 +16,17 @@ _LOGGER = logging.getLogger(__name__) # These are the available sensors mapped to binary_sensor class SENSOR_TYPES = { "brightness": "light", - "capturing_audio": "sound", + "capturing_audio": DEVICE_CLASS_SOUND, "capturing_video": None, "co_detected": "gas", "liquid_detected": "moisture", - "loudness": "sound", + "loudness": DEVICE_CLASS_SOUND, "motion": "motion", - "noise": "sound", + "noise": DEVICE_CLASS_SOUND, "opened": "opening", "presence": "occupancy", "smoke_detected": "smoke", - "vibration": "vibration", + "vibration": DEVICE_CLASS_VIBRATION, }