Use DEVICE_CLASS_MOTION in various integrations (#39962)
This commit is contained in:
parent
02cb592917
commit
e55035b2f9
15 changed files with 59 additions and 31 deletions
|
@ -1,5 +1,8 @@
|
|||
"""Support for Android IP Webcam binary sensors."""
|
||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_MOTION,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
|
||||
from . import CONF_HOST, CONF_NAME, DATA_IP_WEBCAM, KEY_MAP, AndroidIPCamEntity
|
||||
|
||||
|
@ -47,4 +50,4 @@ class IPWebcamBinarySensor(AndroidIPCamEntity, BinarySensorEntity):
|
|||
@property
|
||||
def device_class(self):
|
||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||
return "motion"
|
||||
return DEVICE_CLASS_MOTION
|
||||
|
|
|
@ -7,6 +7,7 @@ import requests
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_OPENING,
|
||||
DEVICE_CLASS_SAFETY,
|
||||
DEVICE_CLASS_SMOKE,
|
||||
|
@ -88,7 +89,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
def get_opening_type(zone):
|
||||
"""Return the result of the type guessing from name."""
|
||||
if "MOTION" in zone["name"]:
|
||||
return "motion"
|
||||
return DEVICE_CLASS_MOTION
|
||||
if "KEY" in zone["name"]:
|
||||
return DEVICE_CLASS_SAFETY
|
||||
if "SMOKE" in zone["name"]:
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
"""Demo platform that has two fake binary sensors."""
|
||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_MOTION,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
|
||||
from . import DOMAIN
|
||||
|
||||
|
@ -9,7 +12,9 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||
async_add_entities(
|
||||
[
|
||||
DemoBinarySensor("binary_1", "Basement Floor Wet", False, "moisture"),
|
||||
DemoBinarySensor("binary_2", "Movement Backyard", True, "motion"),
|
||||
DemoBinarySensor(
|
||||
"binary_2", "Movement Backyard", True, DEVICE_CLASS_MOTION
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import logging
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_OPENING,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
|
@ -12,9 +13,9 @@ from . import ATTR_DISCOVER_DEVICES, EGARDIA_DEVICE
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
EGARDIA_TYPE_TO_DEVICE_CLASS = {
|
||||
"IR Sensor": "motion",
|
||||
"IR Sensor": DEVICE_CLASS_MOTION,
|
||||
"Door Contact": DEVICE_CLASS_OPENING,
|
||||
"IR": "motion",
|
||||
"IR": DEVICE_CLASS_MOTION,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,11 @@ import logging
|
|||
import haffmpeg.sensor as ffmpeg_sensor
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_MOTION,
|
||||
PLATFORM_SCHEMA,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.components.ffmpeg import (
|
||||
CONF_EXTRA_ARGUMENTS,
|
||||
CONF_INITIAL_STATE,
|
||||
|
@ -119,4 +123,4 @@ class FFmpegMotion(FFmpegBinarySensor):
|
|||
@property
|
||||
def device_class(self):
|
||||
"""Return the class of this sensor, from DEVICE_CLASSES."""
|
||||
return "motion"
|
||||
return DEVICE_CLASS_MOTION
|
||||
|
|
|
@ -3,6 +3,7 @@ import logging
|
|||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_DOOR,
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_SMOKE,
|
||||
DEVICE_CLASS_WINDOW,
|
||||
DOMAIN,
|
||||
|
@ -16,11 +17,11 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
SENSOR_TYPES = {
|
||||
"com.fibaro.floodSensor": ["Flood", "mdi:water", "flood"],
|
||||
"com.fibaro.motionSensor": ["Motion", "mdi:run", "motion"],
|
||||
"com.fibaro.motionSensor": ["Motion", "mdi:run", DEVICE_CLASS_MOTION],
|
||||
"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", DEVICE_CLASS_SMOKE],
|
||||
"com.fibaro.FGMS001": ["Motion", "mdi:run", "motion"],
|
||||
"com.fibaro.FGMS001": ["Motion", "mdi:run", DEVICE_CLASS_MOTION],
|
||||
"com.fibaro.heatDetector": ["Heat", "mdi:fire", "heat"],
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
DEVICE_CLASS_MOTION,
|
||||
PLATFORM_SCHEMA,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
|
@ -38,11 +39,11 @@ DEFAULT_DELAY = 0
|
|||
ATTR_DELAY = "delay"
|
||||
|
||||
DEVICE_CLASS_MAP = {
|
||||
"Motion": "motion",
|
||||
"Line Crossing": "motion",
|
||||
"Field Detection": "motion",
|
||||
"Motion": DEVICE_CLASS_MOTION,
|
||||
"Line Crossing": DEVICE_CLASS_MOTION,
|
||||
"Field Detection": DEVICE_CLASS_MOTION,
|
||||
"Video Loss": None,
|
||||
"Tamper Detection": "motion",
|
||||
"Tamper Detection": DEVICE_CLASS_MOTION,
|
||||
"Shelter Alarm": None,
|
||||
"Disk Full": None,
|
||||
"Disk Error": None,
|
||||
|
@ -51,15 +52,15 @@ DEVICE_CLASS_MAP = {
|
|||
"Illegal Access": None,
|
||||
"Video Mismatch": None,
|
||||
"Bad Video": None,
|
||||
"PIR Alarm": "motion",
|
||||
"Face Detection": "motion",
|
||||
"Scene Change Detection": "motion",
|
||||
"PIR Alarm": DEVICE_CLASS_MOTION,
|
||||
"Face Detection": DEVICE_CLASS_MOTION,
|
||||
"Scene Change Detection": DEVICE_CLASS_MOTION,
|
||||
"I/O": None,
|
||||
"Unattended Baggage": "motion",
|
||||
"Attended Baggage": "motion",
|
||||
"Unattended Baggage": DEVICE_CLASS_MOTION,
|
||||
"Attended Baggage": DEVICE_CLASS_MOTION,
|
||||
"Recording Failure": None,
|
||||
"Exiting Region": "motion",
|
||||
"Entering Region": "motion",
|
||||
"Exiting Region": DEVICE_CLASS_MOTION,
|
||||
"Entering Region": DEVICE_CLASS_MOTION,
|
||||
}
|
||||
|
||||
CUSTOMIZE_SCHEMA = vol.Schema(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""Support for the Hive binary sensors."""
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_OPENING,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
|
@ -7,7 +8,7 @@ from homeassistant.components.binary_sensor import (
|
|||
from . import DATA_HIVE, DOMAIN, HiveEntity
|
||||
|
||||
DEVICETYPE_DEVICE_CLASS = {
|
||||
"motionsensor": "motion",
|
||||
"motionsensor": DEVICE_CLASS_MOTION,
|
||||
"contactsensor": DEVICE_CLASS_OPENING,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Support for MySensors binary sensors."""
|
||||
from homeassistant.components import mysensors
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_SAFETY,
|
||||
DEVICE_CLASS_SOUND,
|
||||
DEVICE_CLASS_VIBRATION,
|
||||
|
@ -12,7 +13,7 @@ from homeassistant.const import STATE_ON
|
|||
|
||||
SENSORS = {
|
||||
"S_DOOR": "door",
|
||||
"S_MOTION": "motion",
|
||||
"S_MOTION": DEVICE_CLASS_MOTION,
|
||||
"S_SMOKE": "smoke",
|
||||
"S_SPRINKLER": DEVICE_CLASS_SAFETY,
|
||||
"S_WATER_LEAK": DEVICE_CLASS_SAFETY,
|
||||
|
|
|
@ -4,6 +4,7 @@ import logging
|
|||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_OCCUPANCY,
|
||||
DEVICE_CLASS_SOUND,
|
||||
BinarySensorEntity,
|
||||
|
@ -24,7 +25,7 @@ CLIMATE_BINARY_TYPES = {
|
|||
}
|
||||
|
||||
CAMERA_BINARY_TYPES = {
|
||||
"motion_detected": "motion",
|
||||
"motion_detected": DEVICE_CLASS_MOTION,
|
||||
"sound_detected": DEVICE_CLASS_SOUND,
|
||||
"person_detected": DEVICE_CLASS_OCCUPANCY,
|
||||
}
|
||||
|
@ -158,7 +159,7 @@ class NestActivityZoneSensor(NestBinarySensor):
|
|||
@property
|
||||
def device_class(self):
|
||||
"""Return the device class of the binary sensor."""
|
||||
return "motion"
|
||||
return DEVICE_CLASS_MOTION
|
||||
|
||||
def update(self):
|
||||
"""Retrieve latest state."""
|
||||
|
|
|
@ -3,6 +3,7 @@ from datetime import datetime
|
|||
import logging
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_OCCUPANCY,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
|
@ -16,7 +17,11 @@ _LOGGER = logging.getLogger(__name__)
|
|||
# Sensor types: Name, category, device_class
|
||||
SENSOR_TYPES = {
|
||||
"ding": ["Ding", ["doorbots", "authorized_doorbots"], DEVICE_CLASS_OCCUPANCY],
|
||||
"motion": ["Motion", ["doorbots", "authorized_doorbots", "stickup_cams"], "motion"],
|
||||
"motion": [
|
||||
"Motion",
|
||||
["doorbots", "authorized_doorbots", "stickup_cams"],
|
||||
DEVICE_CLASS_MOTION,
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import logging
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_OCCUPANCY,
|
||||
PLATFORM_SCHEMA,
|
||||
BinarySensorEntity,
|
||||
|
@ -21,7 +22,7 @@ SCAN_INTERVAL = timedelta(seconds=5)
|
|||
# Sensor types: Name, device_class, event
|
||||
SENSOR_TYPES = {
|
||||
"button": ["Button", DEVICE_CLASS_OCCUPANCY, "device:sensor:button"],
|
||||
"motion": ["Motion", "motion", "device:sensor:motion"],
|
||||
"motion": ["Motion", DEVICE_CLASS_MOTION, "device:sensor:motion"],
|
||||
}
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
|
|
|
@ -4,6 +4,7 @@ from typing import Optional, Sequence
|
|||
from pysmartthings import Attribute, Capability
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_OPENING,
|
||||
DEVICE_CLASS_PRESENCE,
|
||||
DEVICE_CLASS_PROBLEM,
|
||||
|
@ -29,7 +30,7 @@ ATTRIB_TO_CLASS = {
|
|||
Attribute.acceleration: "moving",
|
||||
Attribute.contact: DEVICE_CLASS_OPENING,
|
||||
Attribute.filter_status: DEVICE_CLASS_PROBLEM,
|
||||
Attribute.motion: "motion",
|
||||
Attribute.motion: DEVICE_CLASS_MOTION,
|
||||
Attribute.presence: DEVICE_CLASS_PRESENCE,
|
||||
Attribute.sound: DEVICE_CLASS_SOUND,
|
||||
Attribute.tamper: DEVICE_CLASS_PROBLEM,
|
||||
|
|
|
@ -4,6 +4,7 @@ import logging
|
|||
from pyspcwebgw.const import ZoneInput, ZoneType
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_MOTION,
|
||||
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.ALARM: DEVICE_CLASS_MOTION,
|
||||
ZoneType.ENTRY_EXIT: DEVICE_CLASS_OPENING,
|
||||
ZoneType.FIRE: DEVICE_CLASS_SMOKE,
|
||||
ZoneType.TECHNICAL: "power",
|
||||
|
|
|
@ -4,6 +4,7 @@ import logging
|
|||
import pywink
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_OCCUPANCY,
|
||||
DEVICE_CLASS_OPENING,
|
||||
DEVICE_CLASS_SMOKE,
|
||||
|
@ -24,7 +25,7 @@ SENSOR_TYPES = {
|
|||
"co_detected": "gas",
|
||||
"liquid_detected": "moisture",
|
||||
"loudness": DEVICE_CLASS_SOUND,
|
||||
"motion": "motion",
|
||||
"motion": DEVICE_CLASS_MOTION,
|
||||
"noise": DEVICE_CLASS_SOUND,
|
||||
"opened": DEVICE_CLASS_OPENING,
|
||||
"presence": DEVICE_CLASS_OCCUPANCY,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue