Use new enums in notion (#61950)
This commit is contained in:
parent
77829e397b
commit
1e9e056671
2 changed files with 19 additions and 24 deletions
|
@ -5,19 +5,13 @@ from dataclasses import dataclass
|
|||
from typing import Literal
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_BATTERY,
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
DEVICE_CLASS_DOOR,
|
||||
DEVICE_CLASS_GARAGE_DOOR,
|
||||
DEVICE_CLASS_MOISTURE,
|
||||
DEVICE_CLASS_SMOKE,
|
||||
DEVICE_CLASS_WINDOW,
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
BinarySensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import NotionEntity
|
||||
|
@ -55,63 +49,63 @@ BINARY_SENSOR_DESCRIPTIONS = (
|
|||
NotionBinarySensorDescription(
|
||||
key=SENSOR_BATTERY,
|
||||
name="Low Battery",
|
||||
device_class=DEVICE_CLASS_BATTERY,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
device_class=BinarySensorDeviceClass.BATTERY,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
on_state="critical",
|
||||
),
|
||||
NotionBinarySensorDescription(
|
||||
key=SENSOR_DOOR,
|
||||
name="Door",
|
||||
device_class=DEVICE_CLASS_DOOR,
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
on_state="open",
|
||||
),
|
||||
NotionBinarySensorDescription(
|
||||
key=SENSOR_GARAGE_DOOR,
|
||||
name="Garage Door",
|
||||
device_class=DEVICE_CLASS_GARAGE_DOOR,
|
||||
device_class=BinarySensorDeviceClass.GARAGE_DOOR,
|
||||
on_state="open",
|
||||
),
|
||||
NotionBinarySensorDescription(
|
||||
key=SENSOR_LEAK,
|
||||
name="Leak Detector",
|
||||
device_class=DEVICE_CLASS_MOISTURE,
|
||||
device_class=BinarySensorDeviceClass.MOISTURE,
|
||||
on_state="leak",
|
||||
),
|
||||
NotionBinarySensorDescription(
|
||||
key=SENSOR_MISSING,
|
||||
name="Missing",
|
||||
device_class=DEVICE_CLASS_CONNECTIVITY,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
on_state="not_missing",
|
||||
),
|
||||
NotionBinarySensorDescription(
|
||||
key=SENSOR_SAFE,
|
||||
name="Safe",
|
||||
device_class=DEVICE_CLASS_DOOR,
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
on_state="open",
|
||||
),
|
||||
NotionBinarySensorDescription(
|
||||
key=SENSOR_SLIDING,
|
||||
name="Sliding Door/Window",
|
||||
device_class=DEVICE_CLASS_DOOR,
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
on_state="open",
|
||||
),
|
||||
NotionBinarySensorDescription(
|
||||
key=SENSOR_SMOKE_CO,
|
||||
name="Smoke/Carbon Monoxide Detector",
|
||||
device_class=DEVICE_CLASS_SMOKE,
|
||||
device_class=BinarySensorDeviceClass.SMOKE,
|
||||
on_state="alarm",
|
||||
),
|
||||
NotionBinarySensorDescription(
|
||||
key=SENSOR_WINDOW_HINGED_HORIZONTAL,
|
||||
name="Hinged Window",
|
||||
device_class=DEVICE_CLASS_WINDOW,
|
||||
device_class=BinarySensorDeviceClass.WINDOW,
|
||||
on_state="open",
|
||||
),
|
||||
NotionBinarySensorDescription(
|
||||
key=SENSOR_WINDOW_HINGED_VERTICAL,
|
||||
name="Hinged Window",
|
||||
device_class=DEVICE_CLASS_WINDOW,
|
||||
device_class=BinarySensorDeviceClass.WINDOW,
|
||||
on_state="open",
|
||||
),
|
||||
)
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
"""Support for Notion sensors."""
|
||||
from homeassistant.components.sensor import (
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS
|
||||
from homeassistant.const import TEMP_CELSIUS
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
|
@ -16,9 +17,9 @@ SENSOR_DESCRIPTIONS = (
|
|||
SensorEntityDescription(
|
||||
key=SENSOR_TEMPERATURE,
|
||||
name="Temperature",
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue