diff --git a/homeassistant/components/bmw_connected_drive/binary_sensor.py b/homeassistant/components/bmw_connected_drive/binary_sensor.py index ee89873e8fe..5cc3964ccee 100644 --- a/homeassistant/components/bmw_connected_drive/binary_sensor.py +++ b/homeassistant/components/bmw_connected_drive/binary_sensor.py @@ -3,7 +3,10 @@ import logging from bimmer_connected.state import ChargingState, LockState -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OPENING, + BinarySensorEntity, +) from homeassistant.const import ATTR_ATTRIBUTION, LENGTH_KILOMETERS from . import DOMAIN as BMW_DOMAIN @@ -12,8 +15,8 @@ from .const import ATTRIBUTION _LOGGER = logging.getLogger(__name__) SENSOR_TYPES = { - "lids": ["Doors", "opening", "mdi:car-door-lock"], - "windows": ["Windows", "opening", "mdi:car-door"], + "lids": ["Doors", DEVICE_CLASS_OPENING, "mdi:car-door-lock"], + "windows": ["Windows", DEVICE_CLASS_OPENING, "mdi:car-door"], "door_lock_state": ["Door lock state", "lock", "mdi:car-key"], "lights_parking": ["Parking lights", "light", "mdi:car-parking-lights"], "condition_based_services": ["Condition based services", "problem", "mdi:wrench"], diff --git a/homeassistant/components/concord232/binary_sensor.py b/homeassistant/components/concord232/binary_sensor.py index 5ff75526b27..3b2e980b777 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_OPENING, DEVICE_CLASS_SAFETY, DEVICE_CLASS_SMOKE, DEVICE_CLASSES, @@ -94,7 +95,7 @@ def get_opening_type(zone): return DEVICE_CLASS_SMOKE if "WATER" in zone["name"]: return "water" - return "opening" + return DEVICE_CLASS_OPENING class Concord232ZoneSensor(BinarySensorEntity): diff --git a/homeassistant/components/danfoss_air/binary_sensor.py b/homeassistant/components/danfoss_air/binary_sensor.py index 7f6876a709b..9d3123185c4 100644 --- a/homeassistant/components/danfoss_air/binary_sensor.py +++ b/homeassistant/components/danfoss_air/binary_sensor.py @@ -1,7 +1,10 @@ """Support for the for Danfoss Air HRV binary sensors.""" from pydanfossair.commands import ReadCommand -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OPENING, + BinarySensorEntity, +) from . import DOMAIN as DANFOSS_AIR_DOMAIN @@ -11,7 +14,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): data = hass.data[DANFOSS_AIR_DOMAIN] sensors = [ - ["Danfoss Air Bypass Active", ReadCommand.bypass, "opening"], + ["Danfoss Air Bypass Active", ReadCommand.bypass, DEVICE_CLASS_OPENING], ["Danfoss Air Away Mode Active", ReadCommand.away_mode, None], ] diff --git a/homeassistant/components/egardia/binary_sensor.py b/homeassistant/components/egardia/binary_sensor.py index 4be443a36f4..f4bb5097625 100644 --- a/homeassistant/components/egardia/binary_sensor.py +++ b/homeassistant/components/egardia/binary_sensor.py @@ -1,7 +1,10 @@ """Interfaces with Egardia/Woonveilig alarm control panel.""" import logging -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OPENING, + BinarySensorEntity, +) from homeassistant.const import STATE_OFF, STATE_ON from . import ATTR_DISCOVER_DEVICES, EGARDIA_DEVICE @@ -10,7 +13,7 @@ _LOGGER = logging.getLogger(__name__) EGARDIA_TYPE_TO_DEVICE_CLASS = { "IR Sensor": "motion", - "Door Contact": "opening", + "Door Contact": DEVICE_CLASS_OPENING, "IR": "motion", } diff --git a/homeassistant/components/hive/binary_sensor.py b/homeassistant/components/hive/binary_sensor.py index 27c648f554b..bc71939bf6a 100644 --- a/homeassistant/components/hive/binary_sensor.py +++ b/homeassistant/components/hive/binary_sensor.py @@ -1,9 +1,15 @@ """Support for the Hive binary sensors.""" -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OPENING, + BinarySensorEntity, +) from . import DATA_HIVE, DOMAIN, HiveEntity -DEVICETYPE_DEVICE_CLASS = {"motionsensor": "motion", "contactsensor": "opening"} +DEVICETYPE_DEVICE_CLASS = { + "motionsensor": "motion", + "contactsensor": DEVICE_CLASS_OPENING, +} def setup_platform(hass, config, add_entities, discovery_info=None): diff --git a/homeassistant/components/nest/binary_sensor.py b/homeassistant/components/nest/binary_sensor.py index d4c9b6ca35d..35acab6f504 100644 --- a/homeassistant/components/nest/binary_sensor.py +++ b/homeassistant/components/nest/binary_sensor.py @@ -3,6 +3,7 @@ from itertools import chain import logging from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OCCUPANCY, DEVICE_CLASS_SOUND, BinarySensorEntity, ) @@ -24,7 +25,7 @@ CLIMATE_BINARY_TYPES = { CAMERA_BINARY_TYPES = { "motion_detected": "motion", "sound_detected": DEVICE_CLASS_SOUND, - "person_detected": "occupancy", + "person_detected": DEVICE_CLASS_OCCUPANCY, } STRUCTURE_BINARY_TYPES = {"away": None} diff --git a/homeassistant/components/nx584/binary_sensor.py b/homeassistant/components/nx584/binary_sensor.py index 127ce02b371..2db3531f879 100644 --- a/homeassistant/components/nx584/binary_sensor.py +++ b/homeassistant/components/nx584/binary_sensor.py @@ -8,6 +8,7 @@ import requests import voluptuous as vol from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OPENING, DEVICE_CLASSES, PLATFORM_SCHEMA, BinarySensorEntity, @@ -59,7 +60,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return False zone_sensors = { - zone["number"]: NX584ZoneSensor(zone, zone_types.get(zone["number"], "opening")) + zone["number"]: NX584ZoneSensor( + zone, zone_types.get(zone["number"], DEVICE_CLASS_OPENING) + ) for zone in zones if zone["number"] not in exclude } diff --git a/homeassistant/components/ring/binary_sensor.py b/homeassistant/components/ring/binary_sensor.py index fa303b94378..876caad3f85 100644 --- a/homeassistant/components/ring/binary_sensor.py +++ b/homeassistant/components/ring/binary_sensor.py @@ -2,7 +2,10 @@ from datetime import datetime import logging -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OCCUPANCY, + BinarySensorEntity, +) from homeassistant.core import callback from . import DOMAIN @@ -12,7 +15,7 @@ _LOGGER = logging.getLogger(__name__) # Sensor types: Name, category, device_class SENSOR_TYPES = { - "ding": ["Ding", ["doorbots", "authorized_doorbots"], "occupancy"], + "ding": ["Ding", ["doorbots", "authorized_doorbots"], DEVICE_CLASS_OCCUPANCY], "motion": ["Motion", ["doorbots", "authorized_doorbots", "stickup_cams"], "motion"], } diff --git a/homeassistant/components/skybell/binary_sensor.py b/homeassistant/components/skybell/binary_sensor.py index a5c6681eb2b..38cf0a98f40 100644 --- a/homeassistant/components/skybell/binary_sensor.py +++ b/homeassistant/components/skybell/binary_sensor.py @@ -4,7 +4,11 @@ import logging import voluptuous as vol -from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OCCUPANCY, + PLATFORM_SCHEMA, + BinarySensorEntity, +) from homeassistant.const import CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS import homeassistant.helpers.config_validation as cv @@ -16,7 +20,7 @@ SCAN_INTERVAL = timedelta(seconds=5) # Sensor types: Name, device_class, event SENSOR_TYPES = { - "button": ["Button", "occupancy", "device:sensor:button"], + "button": ["Button", DEVICE_CLASS_OCCUPANCY, "device:sensor:button"], "motion": ["Motion", "motion", "device:sensor:motion"], } diff --git a/homeassistant/components/sleepiq/binary_sensor.py b/homeassistant/components/sleepiq/binary_sensor.py index 39ae3e7c658..cfbd6f576be 100644 --- a/homeassistant/components/sleepiq/binary_sensor.py +++ b/homeassistant/components/sleepiq/binary_sensor.py @@ -1,5 +1,8 @@ """Support for SleepIQ sensors.""" -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OCCUPANCY, + BinarySensorEntity, +) from . import SleepIQSensor from .const import DOMAIN, IS_IN_BED, SENSOR_TYPES, SIDES @@ -39,7 +42,7 @@ class IsInBedBinarySensor(SleepIQSensor, BinarySensorEntity): @property def device_class(self): """Return the class of this sensor.""" - return "occupancy" + return DEVICE_CLASS_OCCUPANCY def update(self): """Get the latest data from SleepIQ and updates the states.""" diff --git a/homeassistant/components/smartthings/binary_sensor.py b/homeassistant/components/smartthings/binary_sensor.py index 4e555aece22..baeac063598 100644 --- a/homeassistant/components/smartthings/binary_sensor.py +++ b/homeassistant/components/smartthings/binary_sensor.py @@ -4,6 +4,7 @@ from typing import Optional, Sequence from pysmartthings import Attribute, Capability from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OPENING, DEVICE_CLASS_SOUND, BinarySensorEntity, ) @@ -24,13 +25,13 @@ CAPABILITY_TO_ATTRIB = { } ATTRIB_TO_CLASS = { Attribute.acceleration: "moving", - Attribute.contact: "opening", + Attribute.contact: DEVICE_CLASS_OPENING, Attribute.filter_status: "problem", Attribute.motion: "motion", Attribute.presence: "presence", Attribute.sound: DEVICE_CLASS_SOUND, Attribute.tamper: "problem", - Attribute.valve: "opening", + Attribute.valve: DEVICE_CLASS_OPENING, Attribute.water: "moisture", } diff --git a/homeassistant/components/spc/binary_sensor.py b/homeassistant/components/spc/binary_sensor.py index faa803b25dd..4ee8ffad77e 100644 --- a/homeassistant/components/spc/binary_sensor.py +++ b/homeassistant/components/spc/binary_sensor.py @@ -4,6 +4,7 @@ import logging from pyspcwebgw.const import ZoneInput, ZoneType from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OPENING, DEVICE_CLASS_SMOKE, BinarySensorEntity, ) @@ -18,7 +19,7 @@ _LOGGER = logging.getLogger(__name__) def _get_device_class(zone_type): return { ZoneType.ALARM: "motion", - ZoneType.ENTRY_EXIT: "opening", + ZoneType.ENTRY_EXIT: DEVICE_CLASS_OPENING, ZoneType.FIRE: DEVICE_CLASS_SMOKE, ZoneType.TECHNICAL: "power", }.get(zone_type) diff --git a/homeassistant/components/wink/binary_sensor.py b/homeassistant/components/wink/binary_sensor.py index d4443f31ab6..742ed9d020d 100644 --- a/homeassistant/components/wink/binary_sensor.py +++ b/homeassistant/components/wink/binary_sensor.py @@ -4,6 +4,8 @@ import logging import pywink from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OCCUPANCY, + DEVICE_CLASS_OPENING, DEVICE_CLASS_SMOKE, DEVICE_CLASS_SOUND, DEVICE_CLASS_VIBRATION, @@ -24,8 +26,8 @@ SENSOR_TYPES = { "loudness": DEVICE_CLASS_SOUND, "motion": "motion", "noise": DEVICE_CLASS_SOUND, - "opened": "opening", - "presence": "occupancy", + "opened": DEVICE_CLASS_OPENING, + "presence": DEVICE_CLASS_OCCUPANCY, "smoke_detected": DEVICE_CLASS_SMOKE, "vibration": DEVICE_CLASS_VIBRATION, } diff --git a/homeassistant/components/xiaomi_aqara/binary_sensor.py b/homeassistant/components/xiaomi_aqara/binary_sensor.py index fecdfd91a75..f8d1622ae92 100644 --- a/homeassistant/components/xiaomi_aqara/binary_sensor.py +++ b/homeassistant/components/xiaomi_aqara/binary_sensor.py @@ -1,7 +1,10 @@ """Support for Xiaomi aqara binary sensors.""" import logging -from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.components.binary_sensor import ( + DEVICE_CLASS_OPENING, + BinarySensorEntity, +) from homeassistant.core import callback from homeassistant.helpers.event import async_call_later @@ -299,7 +302,7 @@ class XiaomiDoorSensor(XiaomiBinarySensor): "Door Window Sensor", xiaomi_hub, data_key, - "opening", + DEVICE_CLASS_OPENING, config_entry, )