Use connectivity device class constant in various integrations (#39972)
parent
6751a38b8e
commit
3d4ef8cfe1
|
@ -6,6 +6,7 @@ from aioambient import Client
|
|||
from aioambient.errors import WebsocketError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import DEVICE_CLASS_CONNECTIVITY
|
||||
from homeassistant.config_entries import SOURCE_IMPORT
|
||||
from homeassistant.const import (
|
||||
ATTR_LOCATION,
|
||||
|
@ -175,16 +176,16 @@ SENSOR_TYPES = {
|
|||
TYPE_LASTRAIN: ("Last Rain", None, TYPE_SENSOR, "timestamp"),
|
||||
TYPE_MAXDAILYGUST: ("Max Gust", SPEED_MILES_PER_HOUR, TYPE_SENSOR, None),
|
||||
TYPE_MONTHLYRAININ: ("Monthly Rain", "in", TYPE_SENSOR, None),
|
||||
TYPE_RELAY10: ("Relay 10", None, TYPE_BINARY_SENSOR, "connectivity"),
|
||||
TYPE_RELAY1: ("Relay 1", None, TYPE_BINARY_SENSOR, "connectivity"),
|
||||
TYPE_RELAY2: ("Relay 2", None, TYPE_BINARY_SENSOR, "connectivity"),
|
||||
TYPE_RELAY3: ("Relay 3", None, TYPE_BINARY_SENSOR, "connectivity"),
|
||||
TYPE_RELAY4: ("Relay 4", None, TYPE_BINARY_SENSOR, "connectivity"),
|
||||
TYPE_RELAY5: ("Relay 5", None, TYPE_BINARY_SENSOR, "connectivity"),
|
||||
TYPE_RELAY6: ("Relay 6", None, TYPE_BINARY_SENSOR, "connectivity"),
|
||||
TYPE_RELAY7: ("Relay 7", None, TYPE_BINARY_SENSOR, "connectivity"),
|
||||
TYPE_RELAY8: ("Relay 8", None, TYPE_BINARY_SENSOR, "connectivity"),
|
||||
TYPE_RELAY9: ("Relay 9", None, TYPE_BINARY_SENSOR, "connectivity"),
|
||||
TYPE_RELAY10: ("Relay 10", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
|
||||
TYPE_RELAY1: ("Relay 1", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
|
||||
TYPE_RELAY2: ("Relay 2", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
|
||||
TYPE_RELAY3: ("Relay 3", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
|
||||
TYPE_RELAY4: ("Relay 4", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
|
||||
TYPE_RELAY5: ("Relay 5", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
|
||||
TYPE_RELAY6: ("Relay 6", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
|
||||
TYPE_RELAY7: ("Relay 7", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
|
||||
TYPE_RELAY8: ("Relay 8", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
|
||||
TYPE_RELAY9: ("Relay 9", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
|
||||
TYPE_SOILHUM10: ("Soil Humidity 10", PERCENTAGE, TYPE_SENSOR, "humidity"),
|
||||
TYPE_SOILHUM1: ("Soil Humidity 1", PERCENTAGE, TYPE_SENSOR, "humidity"),
|
||||
TYPE_SOILHUM2: ("Soil Humidity 2", PERCENTAGE, TYPE_SENSOR, "humidity"),
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
"""Support for Home Assistant Cloud binary sensors."""
|
||||
import asyncio
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
from .const import DISPATCHER_REMOTE_UPDATE, DOMAIN
|
||||
|
@ -44,7 +47,7 @@ class CloudRemoteBinary(BinarySensorEntity):
|
|||
@property
|
||||
def device_class(self) -> str:
|
||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||
return "connectivity"
|
||||
return DEVICE_CLASS_CONNECTIVITY
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
|
|
|
@ -3,7 +3,10 @@ from typing import Callable, Dict
|
|||
|
||||
from aioguardian import Client
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
@ -22,7 +25,7 @@ ATTR_CONNECTED_CLIENTS = "connected_clients"
|
|||
SENSOR_KIND_AP_INFO = "ap_enabled"
|
||||
SENSOR_KIND_LEAK_DETECTED = "leak_detected"
|
||||
SENSORS = [
|
||||
(SENSOR_KIND_AP_INFO, "Onboard AP Enabled", "connectivity"),
|
||||
(SENSOR_KIND_AP_INFO, "Onboard AP Enabled", DEVICE_CLASS_CONNECTIVITY),
|
||||
(SENSOR_KIND_LEAK_DETECTED, "Leak Detected", "moisture"),
|
||||
]
|
||||
|
||||
|
|
|
@ -5,7 +5,11 @@ import logging
|
|||
from pyhik.hikvision import HikCamera
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
PLATFORM_SCHEMA,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_LAST_TRIP_TIME,
|
||||
CONF_CUSTOMIZE,
|
||||
|
@ -42,8 +46,8 @@ DEVICE_CLASS_MAP = {
|
|||
"Shelter Alarm": None,
|
||||
"Disk Full": None,
|
||||
"Disk Error": None,
|
||||
"Net Interface Broken": "connectivity",
|
||||
"IP Conflict": "connectivity",
|
||||
"Net Interface Broken": DEVICE_CLASS_CONNECTIVITY,
|
||||
"IP Conflict": DEVICE_CLASS_CONNECTIVITY,
|
||||
"Illegal Access": None,
|
||||
"Video Mismatch": None,
|
||||
"Bad Video": None,
|
||||
|
|
|
@ -3,6 +3,7 @@ from itertools import chain
|
|||
import logging
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
DEVICE_CLASS_OCCUPANCY,
|
||||
DEVICE_CLASS_SOUND,
|
||||
BinarySensorEntity,
|
||||
|
@ -13,7 +14,7 @@ from . import CONF_BINARY_SENSORS, DATA_NEST, DATA_NEST_CONFIG, NestSensorDevice
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
BINARY_TYPES = {"online": "connectivity"}
|
||||
BINARY_TYPES = {"online": DEVICE_CLASS_CONNECTIVITY}
|
||||
|
||||
CLIMATE_BINARY_TYPES = {
|
||||
"fan": None,
|
||||
|
|
|
@ -3,6 +3,7 @@ import logging
|
|||
from typing import Callable
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
DEVICE_CLASS_DOOR,
|
||||
DEVICE_CLASS_SMOKE,
|
||||
DEVICE_CLASS_WINDOW,
|
||||
|
@ -34,7 +35,7 @@ BINARY_SENSOR_TYPES = {
|
|||
SENSOR_DOOR: ("Door", DEVICE_CLASS_DOOR),
|
||||
SENSOR_GARAGE_DOOR: ("Garage Door", "garage_door"),
|
||||
SENSOR_LEAK: ("Leak Detector", "moisture"),
|
||||
SENSOR_MISSING: ("Missing", "connectivity"),
|
||||
SENSOR_MISSING: ("Missing", DEVICE_CLASS_CONNECTIVITY),
|
||||
SENSOR_SAFE: ("Safe", DEVICE_CLASS_DOOR),
|
||||
SENSOR_SLIDING: ("Sliding Door/Window", DEVICE_CLASS_DOOR),
|
||||
SENSOR_SMOKE_CO: ("Smoke/Carbon Monoxide Detector", DEVICE_CLASS_SMOKE),
|
||||
|
|
|
@ -10,7 +10,11 @@ from typing import Any, Dict
|
|||
from icmplib import SocketPermissionError, ping as icmp_ping
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
PLATFORM_SCHEMA,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.reload import setup_reload_service
|
||||
|
@ -30,7 +34,6 @@ CONF_PING_COUNT = "count"
|
|||
|
||||
DEFAULT_NAME = "Ping"
|
||||
DEFAULT_PING_COUNT = 5
|
||||
DEFAULT_DEVICE_CLASS = "connectivity"
|
||||
|
||||
SCAN_INTERVAL = timedelta(minutes=5)
|
||||
|
||||
|
@ -94,7 +97,7 @@ class PingBinarySensor(BinarySensorEntity):
|
|||
@property
|
||||
def device_class(self) -> str:
|
||||
"""Return the class of this sensor."""
|
||||
return DEFAULT_DEVICE_CLASS
|
||||
return DEVICE_CLASS_CONNECTIVITY
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
"""Support for Minut Point binary sensors."""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.binary_sensor import DOMAIN, BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
DOMAIN,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
|
@ -116,7 +120,7 @@ class MinutPointBinarySensor(MinutPointEntity, BinarySensorEntity):
|
|||
@property
|
||||
def is_on(self):
|
||||
"""Return the state of the binary sensor."""
|
||||
if self.device_class == "connectivity":
|
||||
if self.device_class == DEVICE_CLASS_CONNECTIVITY:
|
||||
# connectivity is the other way around.
|
||||
return not self._is_on
|
||||
return self._is_on
|
||||
|
|
|
@ -4,7 +4,11 @@ import logging
|
|||
from pyuptimerobot import UptimeRobot
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
PLATFORM_SCHEMA,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
|
@ -68,7 +72,7 @@ class UptimeRobotBinarySensor(BinarySensorEntity):
|
|||
@property
|
||||
def device_class(self):
|
||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||
return "connectivity"
|
||||
return DEVICE_CLASS_CONNECTIVITY
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
"""Support for ZoneMinder binary sensors."""
|
||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
|
||||
from . import DOMAIN as ZONEMINDER_DOMAIN
|
||||
|
||||
|
@ -35,7 +38,7 @@ class ZMAvailabilitySensor(BinarySensorEntity):
|
|||
@property
|
||||
def device_class(self):
|
||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||
return "connectivity"
|
||||
return DEVICE_CLASS_CONNECTIVITY
|
||||
|
||||
def update(self):
|
||||
"""Update the state of this sensor (availability of ZoneMinder)."""
|
||||
|
|
Loading…
Reference in New Issue