Use opening and occupancy device class in various integrations (#39965)
This commit is contained in:
parent
4c0f075d6a
commit
cee96ae207
14 changed files with 62 additions and 25 deletions
|
@ -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"],
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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],
|
||||
]
|
||||
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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"],
|
||||
}
|
||||
|
||||
|
|
|
@ -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"],
|
||||
}
|
||||
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue