Skip to content

Commit

Permalink
Use DEVICE_CLASS_DOOR and DEVICE_CLASS_SMOKE in various integrations (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
springstan authored Sep 12, 2020
1 parent cf6b847 commit 1bb5d47
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 14 deletions.
3 changes: 2 additions & 1 deletion homeassistant/components/concord232/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from homeassistant.components.binary_sensor import (
DEVICE_CLASS_SAFETY,
DEVICE_CLASS_SMOKE,
DEVICE_CLASSES,
PLATFORM_SCHEMA,
BinarySensorEntity,
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/fibaro/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import logging

from homeassistant.components.binary_sensor import (
DEVICE_CLASS_DOOR,
DEVICE_CLASS_SMOKE,
DEVICE_CLASS_WINDOW,
DOMAIN,
BinarySensorEntity,
Expand All @@ -15,9 +17,9 @@
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"],
}
Expand Down
10 changes: 6 additions & 4 deletions homeassistant/components/notion/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from typing import Callable

from homeassistant.components.binary_sensor import (
DEVICE_CLASS_DOOR,
DEVICE_CLASS_SMOKE,
DEVICE_CLASS_WINDOW,
BinarySensorEntity,
)
Expand All @@ -29,13 +31,13 @@

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),
}
Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/satel_integra/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -89,7 +92,7 @@ def name(self):
@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
Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/spc/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

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

Expand All @@ -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)

Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/tahoma/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -45,7 +48,7 @@ def is_on(self):
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
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/wink/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pywink

from homeassistant.components.binary_sensor import (
DEVICE_CLASS_SMOKE,
DEVICE_CLASS_SOUND,
DEVICE_CLASS_VIBRATION,
BinarySensorEntity,
Expand All @@ -25,7 +26,7 @@
"noise": DEVICE_CLASS_SOUND,
"opened": "opening",
"presence": "occupancy",
"smoke_detected": "smoke",
"smoke_detected": DEVICE_CLASS_SMOKE,
"vibration": DEVICE_CLASS_VIBRATION,
}

Expand Down

0 comments on commit 1bb5d47

Please sign in to comment.