mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Use DEVICE_CLASS_DOOR and DEVICE_CLASS_SMOKE in various integrations (#39950)
This commit is contained in:
parent
cf6b84790f
commit
1bb5d4754f
@ -8,6 +8,7 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
DEVICE_CLASS_SAFETY,
|
DEVICE_CLASS_SAFETY,
|
||||||
|
DEVICE_CLASS_SMOKE,
|
||||||
DEVICE_CLASSES,
|
DEVICE_CLASSES,
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
@ -90,7 +91,7 @@ def get_opening_type(zone):
|
|||||||
if "KEY" in zone["name"]:
|
if "KEY" in zone["name"]:
|
||||||
return DEVICE_CLASS_SAFETY
|
return DEVICE_CLASS_SAFETY
|
||||||
if "SMOKE" in zone["name"]:
|
if "SMOKE" in zone["name"]:
|
||||||
return "smoke"
|
return DEVICE_CLASS_SMOKE
|
||||||
if "WATER" in zone["name"]:
|
if "WATER" in zone["name"]:
|
||||||
return "water"
|
return "water"
|
||||||
return "opening"
|
return "opening"
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
|
DEVICE_CLASS_DOOR,
|
||||||
|
DEVICE_CLASS_SMOKE,
|
||||||
DEVICE_CLASS_WINDOW,
|
DEVICE_CLASS_WINDOW,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
@ -15,9 +17,9 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
SENSOR_TYPES = {
|
SENSOR_TYPES = {
|
||||||
"com.fibaro.floodSensor": ["Flood", "mdi:water", "flood"],
|
"com.fibaro.floodSensor": ["Flood", "mdi:water", "flood"],
|
||||||
"com.fibaro.motionSensor": ["Motion", "mdi:run", "motion"],
|
"com.fibaro.motionSensor": ["Motion", "mdi:run", "motion"],
|
||||||
"com.fibaro.doorSensor": ["Door", "mdi:window-open", "door"],
|
"com.fibaro.doorSensor": ["Door", "mdi:window-open", DEVICE_CLASS_DOOR],
|
||||||
"com.fibaro.windowSensor": ["Window", "mdi:window-open", DEVICE_CLASS_WINDOW],
|
"com.fibaro.windowSensor": ["Window", "mdi:window-open", DEVICE_CLASS_WINDOW],
|
||||||
"com.fibaro.smokeSensor": ["Smoke", "mdi:smoking", "smoke"],
|
"com.fibaro.smokeSensor": ["Smoke", "mdi:smoking", DEVICE_CLASS_SMOKE],
|
||||||
"com.fibaro.FGMS001": ["Motion", "mdi:run", "motion"],
|
"com.fibaro.FGMS001": ["Motion", "mdi:run", "motion"],
|
||||||
"com.fibaro.heatDetector": ["Heat", "mdi:fire", "heat"],
|
"com.fibaro.heatDetector": ["Heat", "mdi:fire", "heat"],
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ import logging
|
|||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
|
DEVICE_CLASS_DOOR,
|
||||||
|
DEVICE_CLASS_SMOKE,
|
||||||
DEVICE_CLASS_WINDOW,
|
DEVICE_CLASS_WINDOW,
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
@ -29,13 +31,13 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
BINARY_SENSOR_TYPES = {
|
BINARY_SENSOR_TYPES = {
|
||||||
SENSOR_BATTERY: ("Low Battery", "battery"),
|
SENSOR_BATTERY: ("Low Battery", "battery"),
|
||||||
SENSOR_DOOR: ("Door", "door"),
|
SENSOR_DOOR: ("Door", DEVICE_CLASS_DOOR),
|
||||||
SENSOR_GARAGE_DOOR: ("Garage Door", "garage_door"),
|
SENSOR_GARAGE_DOOR: ("Garage Door", "garage_door"),
|
||||||
SENSOR_LEAK: ("Leak Detector", "moisture"),
|
SENSOR_LEAK: ("Leak Detector", "moisture"),
|
||||||
SENSOR_MISSING: ("Missing", "connectivity"),
|
SENSOR_MISSING: ("Missing", "connectivity"),
|
||||||
SENSOR_SAFE: ("Safe", "door"),
|
SENSOR_SAFE: ("Safe", DEVICE_CLASS_DOOR),
|
||||||
SENSOR_SLIDING: ("Sliding Door/Window", "door"),
|
SENSOR_SLIDING: ("Sliding Door/Window", DEVICE_CLASS_DOOR),
|
||||||
SENSOR_SMOKE_CO: ("Smoke/Carbon Monoxide Detector", "smoke"),
|
SENSOR_SMOKE_CO: ("Smoke/Carbon Monoxide Detector", DEVICE_CLASS_SMOKE),
|
||||||
SENSOR_WINDOW_HINGED_HORIZONTAL: ("Hinged Window", DEVICE_CLASS_WINDOW),
|
SENSOR_WINDOW_HINGED_HORIZONTAL: ("Hinged Window", DEVICE_CLASS_WINDOW),
|
||||||
SENSOR_WINDOW_HINGED_VERTICAL: ("Hinged Window", DEVICE_CLASS_WINDOW),
|
SENSOR_WINDOW_HINGED_VERTICAL: ("Hinged Window", DEVICE_CLASS_WINDOW),
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
"""Support for Satel Integra zone states- represented as binary sensors."""
|
"""Support for Satel Integra zone states- represented as binary sensors."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
from homeassistant.components.binary_sensor import (
|
||||||
|
DEVICE_CLASS_SMOKE,
|
||||||
|
BinarySensorEntity,
|
||||||
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
|
||||||
@ -89,7 +92,7 @@ class SatelIntegraBinarySensor(BinarySensorEntity):
|
|||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Icon for device by its type."""
|
"""Icon for device by its type."""
|
||||||
if self._zone_type == "smoke":
|
if self._zone_type == DEVICE_CLASS_SMOKE:
|
||||||
return "mdi:fire"
|
return "mdi:fire"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -3,7 +3,10 @@ import logging
|
|||||||
|
|
||||||
from pyspcwebgw.const import ZoneInput, ZoneType
|
from pyspcwebgw.const import ZoneInput, ZoneType
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
from homeassistant.components.binary_sensor import (
|
||||||
|
DEVICE_CLASS_SMOKE,
|
||||||
|
BinarySensorEntity,
|
||||||
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
|
||||||
@ -16,7 +19,7 @@ def _get_device_class(zone_type):
|
|||||||
return {
|
return {
|
||||||
ZoneType.ALARM: "motion",
|
ZoneType.ALARM: "motion",
|
||||||
ZoneType.ENTRY_EXIT: "opening",
|
ZoneType.ENTRY_EXIT: "opening",
|
||||||
ZoneType.FIRE: "smoke",
|
ZoneType.FIRE: DEVICE_CLASS_SMOKE,
|
||||||
ZoneType.TECHNICAL: "power",
|
ZoneType.TECHNICAL: "power",
|
||||||
}.get(zone_type)
|
}.get(zone_type)
|
||||||
|
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
from homeassistant.components.binary_sensor import (
|
||||||
|
DEVICE_CLASS_SMOKE,
|
||||||
|
BinarySensorEntity,
|
||||||
|
)
|
||||||
from homeassistant.const import ATTR_BATTERY_LEVEL, STATE_OFF, STATE_ON
|
from homeassistant.const import ATTR_BATTERY_LEVEL, STATE_OFF, STATE_ON
|
||||||
|
|
||||||
from . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice
|
from . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice
|
||||||
@ -45,7 +48,7 @@ class TahomaBinarySensor(TahomaDevice, BinarySensorEntity):
|
|||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the class of the device."""
|
"""Return the class of the device."""
|
||||||
if self.tahoma_device.type == "rtds:RTDSSmokeSensor":
|
if self.tahoma_device.type == "rtds:RTDSSmokeSensor":
|
||||||
return "smoke"
|
return DEVICE_CLASS_SMOKE
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -4,6 +4,7 @@ import logging
|
|||||||
import pywink
|
import pywink
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
|
DEVICE_CLASS_SMOKE,
|
||||||
DEVICE_CLASS_SOUND,
|
DEVICE_CLASS_SOUND,
|
||||||
DEVICE_CLASS_VIBRATION,
|
DEVICE_CLASS_VIBRATION,
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
@ -25,7 +26,7 @@ SENSOR_TYPES = {
|
|||||||
"noise": DEVICE_CLASS_SOUND,
|
"noise": DEVICE_CLASS_SOUND,
|
||||||
"opened": "opening",
|
"opened": "opening",
|
||||||
"presence": "occupancy",
|
"presence": "occupancy",
|
||||||
"smoke_detected": "smoke",
|
"smoke_detected": DEVICE_CLASS_SMOKE,
|
||||||
"vibration": DEVICE_CLASS_VIBRATION,
|
"vibration": DEVICE_CLASS_VIBRATION,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user