Use enums in zwave_js (#62130)

* Use enums in zwave_js

* oops
This commit is contained in:
Robert Hillis 2021-12-19 06:28:09 -05:00 committed by GitHub
parent 1cbcb9e2fd
commit b559d8845e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 78 additions and 109 deletions

View file

@ -12,27 +12,15 @@ from zwave_js_server.const.command_class.notification import (
) )
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_DOOR,
DEVICE_CLASS_GAS,
DEVICE_CLASS_HEAT,
DEVICE_CLASS_LOCK,
DEVICE_CLASS_MOISTURE,
DEVICE_CLASS_MOTION,
DEVICE_CLASS_PLUG,
DEVICE_CLASS_PROBLEM,
DEVICE_CLASS_SAFETY,
DEVICE_CLASS_SMOKE,
DEVICE_CLASS_SOUND,
DEVICE_CLASS_TAMPER,
DOMAIN as BINARY_SENSOR_DOMAIN, DOMAIN as BINARY_SENSOR_DOMAIN,
BinarySensorDeviceClass,
BinarySensorEntity, BinarySensorEntity,
BinarySensorEntityDescription, BinarySensorEntityDescription,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DATA_CLIENT, DOMAIN from .const import DATA_CLIENT, DOMAIN
@ -91,101 +79,101 @@ NOTIFICATION_SENSOR_MAPPINGS: tuple[NotificationZWaveJSEntityDescription, ...] =
# NotificationType 1: Smoke Alarm - State Id's 1 and 2 - Smoke detected # NotificationType 1: Smoke Alarm - State Id's 1 and 2 - Smoke detected
key=NOTIFICATION_SMOKE_ALARM, key=NOTIFICATION_SMOKE_ALARM,
states=("1", "2"), states=("1", "2"),
device_class=DEVICE_CLASS_SMOKE, device_class=BinarySensorDeviceClass.SMOKE,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 1: Smoke Alarm - All other State Id's # NotificationType 1: Smoke Alarm - All other State Id's
key=NOTIFICATION_SMOKE_ALARM, key=NOTIFICATION_SMOKE_ALARM,
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 2: Carbon Monoxide - State Id's 1 and 2 # NotificationType 2: Carbon Monoxide - State Id's 1 and 2
key=NOTIFICATION_CARBON_MONOOXIDE, key=NOTIFICATION_CARBON_MONOOXIDE,
states=("1", "2"), states=("1", "2"),
device_class=DEVICE_CLASS_GAS, device_class=BinarySensorDeviceClass.GAS,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 2: Carbon Monoxide - All other State Id's # NotificationType 2: Carbon Monoxide - All other State Id's
key=NOTIFICATION_CARBON_MONOOXIDE, key=NOTIFICATION_CARBON_MONOOXIDE,
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 3: Carbon Dioxide - State Id's 1 and 2 # NotificationType 3: Carbon Dioxide - State Id's 1 and 2
key=NOTIFICATION_CARBON_DIOXIDE, key=NOTIFICATION_CARBON_DIOXIDE,
states=("1", "2"), states=("1", "2"),
device_class=DEVICE_CLASS_GAS, device_class=BinarySensorDeviceClass.GAS,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 3: Carbon Dioxide - All other State Id's # NotificationType 3: Carbon Dioxide - All other State Id's
key=NOTIFICATION_CARBON_DIOXIDE, key=NOTIFICATION_CARBON_DIOXIDE,
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 4: Heat - State Id's 1, 2, 5, 6 (heat/underheat) # NotificationType 4: Heat - State Id's 1, 2, 5, 6 (heat/underheat)
key=NOTIFICATION_HEAT, key=NOTIFICATION_HEAT,
states=("1", "2", "5", "6"), states=("1", "2", "5", "6"),
device_class=DEVICE_CLASS_HEAT, device_class=BinarySensorDeviceClass.HEAT,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 4: Heat - All other State Id's # NotificationType 4: Heat - All other State Id's
key=NOTIFICATION_HEAT, key=NOTIFICATION_HEAT,
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 5: Water - State Id's 1, 2, 3, 4 # NotificationType 5: Water - State Id's 1, 2, 3, 4
key=NOTIFICATION_WATER, key=NOTIFICATION_WATER,
states=("1", "2", "3", "4"), states=("1", "2", "3", "4"),
device_class=DEVICE_CLASS_MOISTURE, device_class=BinarySensorDeviceClass.MOISTURE,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 5: Water - All other State Id's # NotificationType 5: Water - All other State Id's
key=NOTIFICATION_WATER, key=NOTIFICATION_WATER,
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 6: Access Control - State Id's 1, 2, 3, 4 (Lock) # NotificationType 6: Access Control - State Id's 1, 2, 3, 4 (Lock)
key=NOTIFICATION_ACCESS_CONTROL, key=NOTIFICATION_ACCESS_CONTROL,
states=("1", "2", "3", "4"), states=("1", "2", "3", "4"),
device_class=DEVICE_CLASS_LOCK, device_class=BinarySensorDeviceClass.LOCK,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 6: Access Control - State Id's 11 (Lock jammed) # NotificationType 6: Access Control - State Id's 11 (Lock jammed)
key=NOTIFICATION_ACCESS_CONTROL, key=NOTIFICATION_ACCESS_CONTROL,
states=("11",), states=("11",),
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 6: Access Control - State Id 22 (door/window open) # NotificationType 6: Access Control - State Id 22 (door/window open)
key=NOTIFICATION_ACCESS_CONTROL, key=NOTIFICATION_ACCESS_CONTROL,
off_state="23", off_state="23",
states=("22", "23"), states=("22", "23"),
device_class=DEVICE_CLASS_DOOR, device_class=BinarySensorDeviceClass.DOOR,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 7: Home Security - State Id's 1, 2 (intrusion) # NotificationType 7: Home Security - State Id's 1, 2 (intrusion)
key=NOTIFICATION_HOME_SECURITY, key=NOTIFICATION_HOME_SECURITY,
states=("1", "2"), states=("1", "2"),
device_class=DEVICE_CLASS_SAFETY, device_class=BinarySensorDeviceClass.SAFETY,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 7: Home Security - State Id's 3, 4, 9 (tampering) # NotificationType 7: Home Security - State Id's 3, 4, 9 (tampering)
key=NOTIFICATION_HOME_SECURITY, key=NOTIFICATION_HOME_SECURITY,
states=("3", "4", "9"), states=("3", "4", "9"),
device_class=DEVICE_CLASS_TAMPER, device_class=BinarySensorDeviceClass.TAMPER,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 7: Home Security - State Id's 5, 6 (glass breakage) # NotificationType 7: Home Security - State Id's 5, 6 (glass breakage)
key=NOTIFICATION_HOME_SECURITY, key=NOTIFICATION_HOME_SECURITY,
states=("5", "6"), states=("5", "6"),
device_class=DEVICE_CLASS_SAFETY, device_class=BinarySensorDeviceClass.SAFETY,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 7: Home Security - State Id's 7, 8 (motion) # NotificationType 7: Home Security - State Id's 7, 8 (motion)
key=NOTIFICATION_HOME_SECURITY, key=NOTIFICATION_HOME_SECURITY,
states=("7", "8"), states=("7", "8"),
device_class=DEVICE_CLASS_MOTION, device_class=BinarySensorDeviceClass.MOTION,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 8: Power Management - # NotificationType 8: Power Management -
@ -193,55 +181,55 @@ NOTIFICATION_SENSOR_MAPPINGS: tuple[NotificationZWaveJSEntityDescription, ...] =
key=NOTIFICATION_POWER_MANAGEMENT, key=NOTIFICATION_POWER_MANAGEMENT,
off_state="2", off_state="2",
states=("2", "3"), states=("2", "3"),
device_class=DEVICE_CLASS_PLUG, device_class=BinarySensorDeviceClass.PLUG,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 8: Power Management - # NotificationType 8: Power Management -
# State Id's 6, 7, 8, 9 (power status) # State Id's 6, 7, 8, 9 (power status)
key=NOTIFICATION_POWER_MANAGEMENT, key=NOTIFICATION_POWER_MANAGEMENT,
states=("6", "7", "8", "9"), states=("6", "7", "8", "9"),
device_class=DEVICE_CLASS_SAFETY, device_class=BinarySensorDeviceClass.SAFETY,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 8: Power Management - # NotificationType 8: Power Management -
# State Id's 10, 11, 17 (Battery maintenance status) # State Id's 10, 11, 17 (Battery maintenance status)
key=NOTIFICATION_POWER_MANAGEMENT, key=NOTIFICATION_POWER_MANAGEMENT,
states=("10", "11", "17"), states=("10", "11", "17"),
device_class=DEVICE_CLASS_BATTERY, device_class=BinarySensorDeviceClass.BATTERY,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 9: System - State Id's 1, 2, 3, 4, 6, 7 # NotificationType 9: System - State Id's 1, 2, 3, 4, 6, 7
key=NOTIFICATION_SYSTEM, key=NOTIFICATION_SYSTEM,
states=("1", "2", "3", "4", "6", "7"), states=("1", "2", "3", "4", "6", "7"),
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 10: Emergency - State Id's 1, 2, 3 # NotificationType 10: Emergency - State Id's 1, 2, 3
key=NOTIFICATION_EMERGENCY, key=NOTIFICATION_EMERGENCY,
states=("1", "2", "3"), states=("1", "2", "3"),
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 14: Siren # NotificationType 14: Siren
key=NOTIFICATION_SIREN, key=NOTIFICATION_SIREN,
states=("1",), states=("1",),
device_class=DEVICE_CLASS_SOUND, device_class=BinarySensorDeviceClass.SOUND,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 18: Gas # NotificationType 18: Gas
key=NOTIFICATION_GAS, key=NOTIFICATION_GAS,
states=("1", "2", "3", "4"), states=("1", "2", "3", "4"),
device_class=DEVICE_CLASS_GAS, device_class=BinarySensorDeviceClass.GAS,
), ),
NotificationZWaveJSEntityDescription( NotificationZWaveJSEntityDescription(
# NotificationType 18: Gas # NotificationType 18: Gas
key=NOTIFICATION_GAS, key=NOTIFICATION_GAS,
states=("6",), states=("6",),
device_class=DEVICE_CLASS_PROBLEM, device_class=BinarySensorDeviceClass.PROBLEM,
), ),
) )
@ -251,7 +239,7 @@ PROPERTY_SENSOR_MAPPINGS: dict[str, PropertyZWaveJSEntityDescription] = {
DOOR_STATUS_PROPERTY: PropertyZWaveJSEntityDescription( DOOR_STATUS_PROPERTY: PropertyZWaveJSEntityDescription(
key=DOOR_STATUS_PROPERTY, key=DOOR_STATUS_PROPERTY,
on_states=("open",), on_states=("open",),
device_class=DEVICE_CLASS_DOOR, device_class=BinarySensorDeviceClass.DOOR,
), ),
} }
@ -260,8 +248,8 @@ PROPERTY_SENSOR_MAPPINGS: dict[str, PropertyZWaveJSEntityDescription] = {
BOOLEAN_SENSOR_MAPPINGS: dict[str, BinarySensorEntityDescription] = { BOOLEAN_SENSOR_MAPPINGS: dict[str, BinarySensorEntityDescription] = {
CommandClass.BATTERY: BinarySensorEntityDescription( CommandClass.BATTERY: BinarySensorEntityDescription(
key=str(CommandClass.BATTERY), key=str(CommandClass.BATTERY),
device_class=DEVICE_CLASS_BATTERY, device_class=BinarySensorDeviceClass.BATTERY,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
} }

View file

@ -20,10 +20,6 @@ from zwave_js_server.model.value import Value as ZwaveValue
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
ATTR_TILT_POSITION, ATTR_TILT_POSITION,
DEVICE_CLASS_BLIND,
DEVICE_CLASS_GARAGE,
DEVICE_CLASS_SHUTTER,
DEVICE_CLASS_WINDOW,
DOMAIN as COVER_DOMAIN, DOMAIN as COVER_DOMAIN,
SUPPORT_CLOSE, SUPPORT_CLOSE,
SUPPORT_CLOSE_TILT, SUPPORT_CLOSE_TILT,
@ -32,6 +28,7 @@ from homeassistant.components.cover import (
SUPPORT_SET_POSITION, SUPPORT_SET_POSITION,
SUPPORT_SET_TILT_POSITION, SUPPORT_SET_TILT_POSITION,
SUPPORT_STOP, SUPPORT_STOP,
CoverDeviceClass,
CoverEntity, CoverEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -119,11 +116,11 @@ class ZWaveCover(ZWaveBaseEntity, CoverEntity):
super().__init__(config_entry, client, info) super().__init__(config_entry, client, info)
# Entity class attributes # Entity class attributes
self._attr_device_class = DEVICE_CLASS_WINDOW self._attr_device_class = CoverDeviceClass.WINDOW
if self.info.platform_hint in ("window_shutter", "window_shutter_tilt"): if self.info.platform_hint in ("window_shutter", "window_shutter_tilt"):
self._attr_device_class = DEVICE_CLASS_SHUTTER self._attr_device_class = CoverDeviceClass.SHUTTER
if self.info.platform_hint == "window_blind": if self.info.platform_hint == "window_blind":
self._attr_device_class = DEVICE_CLASS_BLIND self._attr_device_class = CoverDeviceClass.BLIND
@property @property
def is_closed(self) -> bool | None: def is_closed(self) -> bool | None:
@ -235,7 +232,7 @@ class ZwaveMotorizedBarrier(ZWaveBaseEntity, CoverEntity):
"""Representation of a Z-Wave motorized barrier device.""" """Representation of a Z-Wave motorized barrier device."""
_attr_supported_features = SUPPORT_OPEN | SUPPORT_CLOSE _attr_supported_features = SUPPORT_OPEN | SUPPORT_CLOSE
_attr_device_class = DEVICE_CLASS_GARAGE _attr_device_class = CoverDeviceClass.GARAGE
def __init__( def __init__(
self, self,

View file

@ -17,33 +17,17 @@ from zwave_js_server.model.value import ConfigurationValue
from zwave_js_server.util.command_class.meter import get_meter_type from zwave_js_server.util.command_class.meter import get_meter_type
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
DEVICE_CLASS_ENERGY,
DOMAIN as SENSOR_DOMAIN, DOMAIN as SENSOR_DOMAIN,
STATE_CLASS_MEASUREMENT, SensorDeviceClass,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_CO,
DEVICE_CLASS_CO2,
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_ILLUMINANCE,
DEVICE_CLASS_POWER,
DEVICE_CLASS_POWER_FACTOR,
DEVICE_CLASS_PRESSURE,
DEVICE_CLASS_SIGNAL_STRENGTH,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_VOLTAGE,
ENTITY_CATEGORY_DIAGNOSTIC,
)
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_platform
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo, EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import ( from .const import (
@ -90,91 +74,91 @@ STATUS_ICON: dict[NodeStatus, str] = {
ENTITY_DESCRIPTION_KEY_MAP: dict[str, SensorEntityDescription] = { ENTITY_DESCRIPTION_KEY_MAP: dict[str, SensorEntityDescription] = {
ENTITY_DESC_KEY_BATTERY: SensorEntityDescription( ENTITY_DESC_KEY_BATTERY: SensorEntityDescription(
ENTITY_DESC_KEY_BATTERY, ENTITY_DESC_KEY_BATTERY,
device_class=DEVICE_CLASS_BATTERY, device_class=SensorDeviceClass.BATTERY,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_CURRENT: SensorEntityDescription( ENTITY_DESC_KEY_CURRENT: SensorEntityDescription(
ENTITY_DESC_KEY_CURRENT, ENTITY_DESC_KEY_CURRENT,
device_class=DEVICE_CLASS_CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_VOLTAGE: SensorEntityDescription( ENTITY_DESC_KEY_VOLTAGE: SensorEntityDescription(
ENTITY_DESC_KEY_VOLTAGE, ENTITY_DESC_KEY_VOLTAGE,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_ENERGY_MEASUREMENT: SensorEntityDescription( ENTITY_DESC_KEY_ENERGY_MEASUREMENT: SensorEntityDescription(
ENTITY_DESC_KEY_ENERGY_MEASUREMENT, ENTITY_DESC_KEY_ENERGY_MEASUREMENT,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_ENERGY_TOTAL_INCREASING: SensorEntityDescription( ENTITY_DESC_KEY_ENERGY_TOTAL_INCREASING: SensorEntityDescription(
ENTITY_DESC_KEY_ENERGY_TOTAL_INCREASING, ENTITY_DESC_KEY_ENERGY_TOTAL_INCREASING,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
ENTITY_DESC_KEY_POWER: SensorEntityDescription( ENTITY_DESC_KEY_POWER: SensorEntityDescription(
ENTITY_DESC_KEY_POWER, ENTITY_DESC_KEY_POWER,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_POWER_FACTOR: SensorEntityDescription( ENTITY_DESC_KEY_POWER_FACTOR: SensorEntityDescription(
ENTITY_DESC_KEY_POWER_FACTOR, ENTITY_DESC_KEY_POWER_FACTOR,
device_class=DEVICE_CLASS_POWER_FACTOR, device_class=SensorDeviceClass.POWER_FACTOR,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_CO: SensorEntityDescription( ENTITY_DESC_KEY_CO: SensorEntityDescription(
ENTITY_DESC_KEY_CO, ENTITY_DESC_KEY_CO,
device_class=DEVICE_CLASS_CO, device_class=SensorDeviceClass.CO,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_CO2: SensorEntityDescription( ENTITY_DESC_KEY_CO2: SensorEntityDescription(
ENTITY_DESC_KEY_CO2, ENTITY_DESC_KEY_CO2,
device_class=DEVICE_CLASS_CO2, device_class=SensorDeviceClass.CO2,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_HUMIDITY: SensorEntityDescription( ENTITY_DESC_KEY_HUMIDITY: SensorEntityDescription(
ENTITY_DESC_KEY_HUMIDITY, ENTITY_DESC_KEY_HUMIDITY,
device_class=DEVICE_CLASS_HUMIDITY, device_class=SensorDeviceClass.HUMIDITY,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_ILLUMINANCE: SensorEntityDescription( ENTITY_DESC_KEY_ILLUMINANCE: SensorEntityDescription(
ENTITY_DESC_KEY_ILLUMINANCE, ENTITY_DESC_KEY_ILLUMINANCE,
device_class=DEVICE_CLASS_ILLUMINANCE, device_class=SensorDeviceClass.ILLUMINANCE,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_PRESSURE: SensorEntityDescription( ENTITY_DESC_KEY_PRESSURE: SensorEntityDescription(
ENTITY_DESC_KEY_PRESSURE, ENTITY_DESC_KEY_PRESSURE,
device_class=DEVICE_CLASS_PRESSURE, device_class=SensorDeviceClass.PRESSURE,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_SIGNAL_STRENGTH: SensorEntityDescription( ENTITY_DESC_KEY_SIGNAL_STRENGTH: SensorEntityDescription(
ENTITY_DESC_KEY_SIGNAL_STRENGTH, ENTITY_DESC_KEY_SIGNAL_STRENGTH,
device_class=DEVICE_CLASS_SIGNAL_STRENGTH, device_class=SensorDeviceClass.SIGNAL_STRENGTH,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_TEMPERATURE: SensorEntityDescription( ENTITY_DESC_KEY_TEMPERATURE: SensorEntityDescription(
ENTITY_DESC_KEY_TEMPERATURE, ENTITY_DESC_KEY_TEMPERATURE,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_TARGET_TEMPERATURE: SensorEntityDescription( ENTITY_DESC_KEY_TARGET_TEMPERATURE: SensorEntityDescription(
ENTITY_DESC_KEY_TARGET_TEMPERATURE, ENTITY_DESC_KEY_TARGET_TEMPERATURE,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=None, state_class=None,
), ),
ENTITY_DESC_KEY_MEASUREMENT: SensorEntityDescription( ENTITY_DESC_KEY_MEASUREMENT: SensorEntityDescription(
ENTITY_DESC_KEY_MEASUREMENT, ENTITY_DESC_KEY_MEASUREMENT,
device_class=None, device_class=None,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
ENTITY_DESC_KEY_TOTAL_INCREASING: SensorEntityDescription( ENTITY_DESC_KEY_TOTAL_INCREASING: SensorEntityDescription(
ENTITY_DESC_KEY_TOTAL_INCREASING, ENTITY_DESC_KEY_TOTAL_INCREASING,
device_class=None, device_class=None,
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
} }
@ -465,7 +449,7 @@ class ZWaveNodeStatusSensor(SensorEntity):
"""Representation of a node status sensor.""" """Representation of a node status sensor."""
_attr_should_poll = False _attr_should_poll = False
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC _attr_entity_category = EntityCategory.DIAGNOSTIC
def __init__( def __init__(
self, config_entry: ConfigEntry, client: ZwaveClient, node: ZwaveNode self, config_entry: ConfigEntry, client: ZwaveClient, node: ZwaveNode