Use DEVICE_CLASS_DOOR and DEVICE_CLASS_SMOKE in various integrations (#39950)

This commit is contained in:
springstan 2020-09-12 14:35:24 +02:00 committed by GitHub
parent cf6b84790f
commit 1bb5d4754f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 14 deletions

View file

@ -8,6 +8,7 @@ import voluptuous as vol
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_SAFETY,
DEVICE_CLASS_SMOKE,
DEVICE_CLASSES,
PLATFORM_SCHEMA,
BinarySensorEntity,
@ -90,7 +91,7 @@ def get_opening_type(zone):
if "KEY" in zone["name"]:
return DEVICE_CLASS_SAFETY
if "SMOKE" in zone["name"]:
return "smoke"
return DEVICE_CLASS_SMOKE
if "WATER" in zone["name"]:
return "water"
return "opening"

View file

@ -2,6 +2,8 @@
import logging
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_DOOR,
DEVICE_CLASS_SMOKE,
DEVICE_CLASS_WINDOW,
DOMAIN,
BinarySensorEntity,
@ -15,9 +17,9 @@ _LOGGER = logging.getLogger(__name__)
SENSOR_TYPES = {
"com.fibaro.floodSensor": ["Flood", "mdi:water", "flood"],
"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.smokeSensor": ["Smoke", "mdi:smoking", "smoke"],
"com.fibaro.smokeSensor": ["Smoke", "mdi:smoking", DEVICE_CLASS_SMOKE],
"com.fibaro.FGMS001": ["Motion", "mdi:run", "motion"],
"com.fibaro.heatDetector": ["Heat", "mdi:fire", "heat"],
}

View file

@ -3,6 +3,8 @@ import logging
from typing import Callable
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_DOOR,
DEVICE_CLASS_SMOKE,
DEVICE_CLASS_WINDOW,
BinarySensorEntity,
)
@ -29,13 +31,13 @@ _LOGGER = logging.getLogger(__name__)
BINARY_SENSOR_TYPES = {
SENSOR_BATTERY: ("Low Battery", "battery"),
SENSOR_DOOR: ("Door", "door"),
SENSOR_DOOR: ("Door", DEVICE_CLASS_DOOR),
SENSOR_GARAGE_DOOR: ("Garage Door", "garage_door"),
SENSOR_LEAK: ("Leak Detector", "moisture"),
SENSOR_MISSING: ("Missing", "connectivity"),
SENSOR_SAFE: ("Safe", "door"),
SENSOR_SLIDING: ("Sliding Door/Window", "door"),
SENSOR_SMOKE_CO: ("Smoke/Carbon Monoxide Detector", "smoke"),
SENSOR_SAFE: ("Safe", DEVICE_CLASS_DOOR),
SENSOR_SLIDING: ("Sliding Door/Window", DEVICE_CLASS_DOOR),
SENSOR_SMOKE_CO: ("Smoke/Carbon Monoxide Detector", DEVICE_CLASS_SMOKE),
SENSOR_WINDOW_HINGED_HORIZONTAL: ("Hinged Window", DEVICE_CLASS_WINDOW),
SENSOR_WINDOW_HINGED_VERTICAL: ("Hinged Window", DEVICE_CLASS_WINDOW),
}

View file

@ -1,7 +1,10 @@
"""Support for Satel Integra zone states- represented as binary sensors."""
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.helpers.dispatcher import async_dispatcher_connect
@ -89,7 +92,7 @@ class SatelIntegraBinarySensor(BinarySensorEntity):
@property
def icon(self):
"""Icon for device by its type."""
if self._zone_type == "smoke":
if self._zone_type == DEVICE_CLASS_SMOKE:
return "mdi:fire"
@property

View file

@ -3,7 +3,10 @@ import logging
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.helpers.dispatcher import async_dispatcher_connect
@ -16,7 +19,7 @@ def _get_device_class(zone_type):
return {
ZoneType.ALARM: "motion",
ZoneType.ENTRY_EXIT: "opening",
ZoneType.FIRE: "smoke",
ZoneType.FIRE: DEVICE_CLASS_SMOKE,
ZoneType.TECHNICAL: "power",
}.get(zone_type)

View file

@ -2,7 +2,10 @@
from datetime import timedelta
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 . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice
@ -45,7 +48,7 @@ class TahomaBinarySensor(TahomaDevice, BinarySensorEntity):
def device_class(self):
"""Return the class of the device."""
if self.tahoma_device.type == "rtds:RTDSSmokeSensor":
return "smoke"
return DEVICE_CLASS_SMOKE
return None
@property

View file

@ -4,6 +4,7 @@ import logging
import pywink
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_SMOKE,
DEVICE_CLASS_SOUND,
DEVICE_CLASS_VIBRATION,
BinarySensorEntity,
@ -25,7 +26,7 @@ SENSOR_TYPES = {
"noise": DEVICE_CLASS_SOUND,
"opened": "opening",
"presence": "occupancy",
"smoke_detected": "smoke",
"smoke_detected": DEVICE_CLASS_SMOKE,
"vibration": DEVICE_CLASS_VIBRATION,
}