diff --git a/homeassistant/components/shelly/binary_sensor.py b/homeassistant/components/shelly/binary_sensor.py index 737efad923c..069e6a9839c 100644 --- a/homeassistant/components/shelly/binary_sensor.py +++ b/homeassistant/components/shelly/binary_sensor.py @@ -4,22 +4,13 @@ from __future__ import annotations from typing import Final, cast from homeassistant.components.binary_sensor import ( - DEVICE_CLASS_CONNECTIVITY, - DEVICE_CLASS_GAS, - DEVICE_CLASS_MOISTURE, - DEVICE_CLASS_MOTION, - DEVICE_CLASS_OPENING, - DEVICE_CLASS_POWER, - DEVICE_CLASS_PROBLEM, - DEVICE_CLASS_SMOKE, - DEVICE_CLASS_UPDATE, - DEVICE_CLASS_VIBRATION, STATE_ON, + BinarySensorDeviceClass, BinarySensorEntity, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC from homeassistant.core import HomeAssistant +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from .const import CONF_SLEEP_PERIOD @@ -44,69 +35,69 @@ from .utils import ( SENSORS: Final = { ("device", "overtemp"): BlockAttributeDescription( name="Overheating", - device_class=DEVICE_CLASS_PROBLEM, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + device_class=BinarySensorDeviceClass.PROBLEM, + entity_category=EntityCategory.DIAGNOSTIC, ), ("device", "overpower"): BlockAttributeDescription( name="Overpowering", - device_class=DEVICE_CLASS_PROBLEM, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + device_class=BinarySensorDeviceClass.PROBLEM, + entity_category=EntityCategory.DIAGNOSTIC, ), ("light", "overpower"): BlockAttributeDescription( name="Overpowering", - device_class=DEVICE_CLASS_PROBLEM, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + device_class=BinarySensorDeviceClass.PROBLEM, + entity_category=EntityCategory.DIAGNOSTIC, ), ("relay", "overpower"): BlockAttributeDescription( name="Overpowering", - device_class=DEVICE_CLASS_PROBLEM, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + device_class=BinarySensorDeviceClass.PROBLEM, + entity_category=EntityCategory.DIAGNOSTIC, ), ("sensor", "dwIsOpened"): BlockAttributeDescription( name="Door", - device_class=DEVICE_CLASS_OPENING, + device_class=BinarySensorDeviceClass.OPENING, available=lambda block: cast(int, block.dwIsOpened) != -1, ), ("sensor", "flood"): BlockAttributeDescription( - name="Flood", device_class=DEVICE_CLASS_MOISTURE + name="Flood", device_class=BinarySensorDeviceClass.MOISTURE ), ("sensor", "gas"): BlockAttributeDescription( name="Gas", - device_class=DEVICE_CLASS_GAS, + device_class=BinarySensorDeviceClass.GAS, value=lambda value: value in ["mild", "heavy"], extra_state_attributes=lambda block: {"detected": block.gas}, ), ("sensor", "smoke"): BlockAttributeDescription( - name="Smoke", device_class=DEVICE_CLASS_SMOKE + name="Smoke", device_class=BinarySensorDeviceClass.SMOKE ), ("sensor", "vibration"): BlockAttributeDescription( - name="Vibration", device_class=DEVICE_CLASS_VIBRATION + name="Vibration", device_class=BinarySensorDeviceClass.VIBRATION ), ("input", "input"): BlockAttributeDescription( name="Input", - device_class=DEVICE_CLASS_POWER, + device_class=BinarySensorDeviceClass.POWER, default_enabled=False, removal_condition=is_block_momentary_input, ), ("relay", "input"): BlockAttributeDescription( name="Input", - device_class=DEVICE_CLASS_POWER, + device_class=BinarySensorDeviceClass.POWER, default_enabled=False, removal_condition=is_block_momentary_input, ), ("device", "input"): BlockAttributeDescription( name="Input", - device_class=DEVICE_CLASS_POWER, + device_class=BinarySensorDeviceClass.POWER, default_enabled=False, removal_condition=is_block_momentary_input, ), ("sensor", "extInput"): BlockAttributeDescription( name="External Input", - device_class=DEVICE_CLASS_POWER, + device_class=BinarySensorDeviceClass.POWER, default_enabled=False, ), ("sensor", "motion"): BlockAttributeDescription( - name="Motion", device_class=DEVICE_CLASS_MOTION + name="Motion", device_class=BinarySensorDeviceClass.MOTION ), } @@ -114,13 +105,13 @@ REST_SENSORS: Final = { "cloud": RestAttributeDescription( name="Cloud", value=lambda status, _: status["cloud"]["connected"], - device_class=DEVICE_CLASS_CONNECTIVITY, + device_class=BinarySensorDeviceClass.CONNECTIVITY, default_enabled=False, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, ), "fwupdate": RestAttributeDescription( name="Firmware Update", - device_class=DEVICE_CLASS_UPDATE, + device_class=BinarySensorDeviceClass.UPDATE, value=lambda status, _: status["update"]["has_update"], default_enabled=False, extra_state_attributes=lambda status: { @@ -128,7 +119,7 @@ REST_SENSORS: Final = { "installed_version": status["update"]["old_version"], "beta_version": status["update"].get("beta_version", ""), }, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, ), } @@ -137,7 +128,7 @@ RPC_SENSORS: Final = { key="input", sub_key="state", name="Input", - device_class=DEVICE_CLASS_POWER, + device_class=BinarySensorDeviceClass.POWER, default_enabled=False, removal_condition=is_rpc_momentary_input, ), @@ -145,22 +136,22 @@ RPC_SENSORS: Final = { key="cloud", sub_key="connected", name="Cloud", - device_class=DEVICE_CLASS_CONNECTIVITY, + device_class=BinarySensorDeviceClass.CONNECTIVITY, default_enabled=False, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, ), "fwupdate": RpcAttributeDescription( key="sys", sub_key="available_updates", name="Firmware Update", - device_class=DEVICE_CLASS_UPDATE, + device_class=BinarySensorDeviceClass.UPDATE, default_enabled=False, extra_state_attributes=lambda status, shelly: { "latest_stable_version": status.get("stable", {"version": ""})["version"], "installed_version": shelly["ver"], "beta_version": status.get("beta", {"version": ""})["version"], }, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, ), } diff --git a/homeassistant/components/shelly/button.py b/homeassistant/components/shelly/button.py index ec308814fd8..84c86f3fe91 100644 --- a/homeassistant/components/shelly/button.py +++ b/homeassistant/components/shelly/button.py @@ -11,10 +11,9 @@ from homeassistant.components.button import ( ButtonEntityDescription, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ENTITY_CATEGORY_CONFIG from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC -from homeassistant.helpers.entity import DeviceInfo +from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.util import slugify @@ -40,7 +39,7 @@ BUTTONS: Final = [ key="ota_update", name="OTA Update", device_class=ButtonDeviceClass.UPDATE, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, press_action=lambda wrapper: wrapper.async_trigger_ota_update(), ), ShellyButtonDescription( @@ -48,14 +47,14 @@ BUTTONS: Final = [ name="OTA Update Beta", device_class=ButtonDeviceClass.UPDATE, entity_registry_enabled_default=False, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, press_action=lambda wrapper: wrapper.async_trigger_ota_update(beta=True), ), ShellyButtonDescription( key="reboot", name="Reboot", device_class=ButtonDeviceClass.RESTART, - entity_category=ENTITY_CATEGORY_CONFIG, + entity_category=EntityCategory.CONFIG, press_action=lambda wrapper: wrapper.device.trigger_reboot(), ), ] diff --git a/homeassistant/components/shelly/cover.py b/homeassistant/components/shelly/cover.py index 47166ff2dbd..78aa7606aac 100644 --- a/homeassistant/components/shelly/cover.py +++ b/homeassistant/components/shelly/cover.py @@ -7,11 +7,11 @@ from aioshelly.block_device import Block from homeassistant.components.cover import ( ATTR_POSITION, - DEVICE_CLASS_SHUTTER, SUPPORT_CLOSE, SUPPORT_OPEN, SUPPORT_SET_POSITION, SUPPORT_STOP, + CoverDeviceClass, CoverEntity, ) from homeassistant.config_entries import ConfigEntry @@ -41,7 +41,7 @@ async def async_setup_entry( class ShellyCover(ShellyBlockEntity, CoverEntity): """Switch that controls a cover block on Shelly devices.""" - _attr_device_class = DEVICE_CLASS_SHUTTER + _attr_device_class = CoverDeviceClass.SHUTTER def __init__(self, wrapper: BlockDeviceWrapper, block: Block) -> None: """Initialize light.""" diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index 7fcf456b658..bccb538bf9d 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -3,8 +3,11 @@ from __future__ import annotations from typing import Final, cast -from homeassistant.components import sensor -from homeassistant.components.sensor import SensorEntity +from homeassistant.components.sensor import ( + SensorDeviceClass, + SensorEntity, + SensorStateClass, +) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, @@ -12,7 +15,6 @@ from homeassistant.const import ( ELECTRIC_CURRENT_AMPERE, ELECTRIC_POTENTIAL_VOLT, ENERGY_KILO_WATT_HOUR, - ENTITY_CATEGORY_DIAGNOSTIC, LIGHT_LUX, PERCENTAGE, POWER_WATT, @@ -20,6 +22,7 @@ from homeassistant.const import ( TEMP_CELSIUS, ) from homeassistant.core import HomeAssistant +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import StateType @@ -42,163 +45,163 @@ SENSORS: Final = { ("device", "battery"): BlockAttributeDescription( name="Battery", unit=PERCENTAGE, - device_class=sensor.DEVICE_CLASS_BATTERY, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.BATTERY, + state_class=SensorStateClass.MEASUREMENT, removal_condition=lambda settings, _: settings.get("external_power") == 1, available=lambda block: cast(int, block.battery) != -1, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, ), ("device", "deviceTemp"): BlockAttributeDescription( name="Device Temperature", unit=temperature_unit, value=lambda value: round(value, 1), - device_class=sensor.DEVICE_CLASS_TEMPERATURE, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, default_enabled=False, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, ), ("emeter", "current"): BlockAttributeDescription( name="Current", unit=ELECTRIC_CURRENT_AMPERE, value=lambda value: value, - device_class=sensor.DEVICE_CLASS_CURRENT, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, ), ("light", "power"): BlockAttributeDescription( name="Power", unit=POWER_WATT, value=lambda value: round(value, 1), - device_class=sensor.DEVICE_CLASS_POWER, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, default_enabled=False, ), ("device", "power"): BlockAttributeDescription( name="Power", unit=POWER_WATT, value=lambda value: round(value, 1), - device_class=sensor.DEVICE_CLASS_POWER, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), ("emeter", "power"): BlockAttributeDescription( name="Power", unit=POWER_WATT, value=lambda value: round(value, 1), - device_class=sensor.DEVICE_CLASS_POWER, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), ("device", "voltage"): BlockAttributeDescription( name="Voltage", unit=ELECTRIC_POTENTIAL_VOLT, value=lambda value: round(value, 1), - device_class=sensor.DEVICE_CLASS_VOLTAGE, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, default_enabled=False, ), ("emeter", "voltage"): BlockAttributeDescription( name="Voltage", unit=ELECTRIC_POTENTIAL_VOLT, value=lambda value: round(value, 1), - device_class=sensor.DEVICE_CLASS_VOLTAGE, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, ), ("emeter", "powerFactor"): BlockAttributeDescription( name="Power Factor", unit=PERCENTAGE, value=lambda value: round(value * 100, 1), - device_class=sensor.DEVICE_CLASS_POWER_FACTOR, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER_FACTOR, + state_class=SensorStateClass.MEASUREMENT, ), ("relay", "power"): BlockAttributeDescription( name="Power", unit=POWER_WATT, value=lambda value: round(value, 1), - device_class=sensor.DEVICE_CLASS_POWER, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), ("roller", "rollerPower"): BlockAttributeDescription( name="Power", unit=POWER_WATT, value=lambda value: round(value, 1), - device_class=sensor.DEVICE_CLASS_POWER, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), ("device", "energy"): BlockAttributeDescription( name="Energy", unit=ENERGY_KILO_WATT_HOUR, value=lambda value: round(value / 60 / 1000, 2), - device_class=sensor.DEVICE_CLASS_ENERGY, - state_class=sensor.STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), ("emeter", "energy"): BlockAttributeDescription( name="Energy", unit=ENERGY_KILO_WATT_HOUR, value=lambda value: round(value / 1000, 2), - device_class=sensor.DEVICE_CLASS_ENERGY, - state_class=sensor.STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), ("emeter", "energyReturned"): BlockAttributeDescription( name="Energy Returned", unit=ENERGY_KILO_WATT_HOUR, value=lambda value: round(value / 1000, 2), - device_class=sensor.DEVICE_CLASS_ENERGY, - state_class=sensor.STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), ("light", "energy"): BlockAttributeDescription( name="Energy", unit=ENERGY_KILO_WATT_HOUR, value=lambda value: round(value / 60 / 1000, 2), - device_class=sensor.DEVICE_CLASS_ENERGY, - state_class=sensor.STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, default_enabled=False, ), ("relay", "energy"): BlockAttributeDescription( name="Energy", unit=ENERGY_KILO_WATT_HOUR, value=lambda value: round(value / 60 / 1000, 2), - device_class=sensor.DEVICE_CLASS_ENERGY, - state_class=sensor.STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), ("roller", "rollerEnergy"): BlockAttributeDescription( name="Energy", unit=ENERGY_KILO_WATT_HOUR, value=lambda value: round(value / 60 / 1000, 2), - device_class=sensor.DEVICE_CLASS_ENERGY, - state_class=sensor.STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), ("sensor", "concentration"): BlockAttributeDescription( name="Gas Concentration", unit=CONCENTRATION_PARTS_PER_MILLION, icon="mdi:gauge", - state_class=sensor.STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), ("sensor", "extTemp"): BlockAttributeDescription( name="Temperature", unit=temperature_unit, value=lambda value: round(value, 1), - device_class=sensor.DEVICE_CLASS_TEMPERATURE, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, available=lambda block: cast(int, block.extTemp) != 999, ), ("sensor", "humidity"): BlockAttributeDescription( name="Humidity", unit=PERCENTAGE, value=lambda value: round(value, 1), - device_class=sensor.DEVICE_CLASS_HUMIDITY, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.HUMIDITY, + state_class=SensorStateClass.MEASUREMENT, available=lambda block: cast(int, block.humidity) != 999, ), ("sensor", "luminosity"): BlockAttributeDescription( name="Luminosity", unit=LIGHT_LUX, - device_class=sensor.DEVICE_CLASS_ILLUMINANCE, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.ILLUMINANCE, + state_class=SensorStateClass.MEASUREMENT, available=lambda block: cast(int, block.luminosity) != -1, ), ("sensor", "tilt"): BlockAttributeDescription( name="Tilt", unit=DEGREE, icon="mdi:angle-acute", - state_class=sensor.STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), ("relay", "totalWorkTime"): BlockAttributeDescription( name="Lamp Life", @@ -208,14 +211,14 @@ SENSORS: Final = { extra_state_attributes=lambda block: { "Operational hours": round(cast(int, block.totalWorkTime) / 3600, 1) }, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, ), ("adc", "adc"): BlockAttributeDescription( name="ADC", unit=ELECTRIC_POTENTIAL_VOLT, value=lambda value: round(value, 1), - device_class=sensor.DEVICE_CLASS_VOLTAGE, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, ), ("sensor", "sensorOp"): BlockAttributeDescription( name="Operation", @@ -230,17 +233,17 @@ REST_SENSORS: Final = { name="RSSI", unit=SIGNAL_STRENGTH_DECIBELS_MILLIWATT, value=lambda status, _: status["wifi_sta"]["rssi"], - device_class=sensor.DEVICE_CLASS_SIGNAL_STRENGTH, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.SIGNAL_STRENGTH, + state_class=SensorStateClass.MEASUREMENT, default_enabled=False, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, ), "uptime": RestAttributeDescription( name="Uptime", value=lambda status, last: get_device_uptime(status["uptime"], last), - device_class=sensor.DEVICE_CLASS_TIMESTAMP, + device_class=SensorDeviceClass.TIMESTAMP, default_enabled=False, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, ), } @@ -252,8 +255,8 @@ RPC_SENSORS: Final = { name="Power", unit=POWER_WATT, value=lambda status, _: round(float(status), 1), - device_class=sensor.DEVICE_CLASS_POWER, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), "voltage": RpcAttributeDescription( key="switch", @@ -261,8 +264,8 @@ RPC_SENSORS: Final = { name="Voltage", unit=ELECTRIC_POTENTIAL_VOLT, value=lambda status, _: round(float(status), 1), - device_class=sensor.DEVICE_CLASS_VOLTAGE, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, default_enabled=False, ), "energy": RpcAttributeDescription( @@ -271,8 +274,8 @@ RPC_SENSORS: Final = { name="Energy", unit=ENERGY_KILO_WATT_HOUR, value=lambda status, _: round(status["total"] / 1000, 2), - device_class=sensor.DEVICE_CLASS_ENERGY, - state_class=sensor.STATE_CLASS_TOTAL_INCREASING, + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), "temperature": RpcAttributeDescription( key="switch", @@ -280,8 +283,8 @@ RPC_SENSORS: Final = { name="Temperature", unit=TEMP_CELSIUS, value=lambda status, _: round(status["tC"], 1), - device_class=sensor.DEVICE_CLASS_TEMPERATURE, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, default_enabled=False, ), "rssi": RpcAttributeDescription( @@ -289,19 +292,19 @@ RPC_SENSORS: Final = { sub_key="rssi", name="RSSI", unit=SIGNAL_STRENGTH_DECIBELS_MILLIWATT, - device_class=sensor.DEVICE_CLASS_SIGNAL_STRENGTH, - state_class=sensor.STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.SIGNAL_STRENGTH, + state_class=SensorStateClass.MEASUREMENT, default_enabled=False, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, ), "uptime": RpcAttributeDescription( key="sys", sub_key="uptime", name="Uptime", value=get_device_uptime, - device_class=sensor.DEVICE_CLASS_TIMESTAMP, + device_class=SensorDeviceClass.TIMESTAMP, default_enabled=False, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, ), }