Use try_parse_enum in integrations (#87085)
This commit is contained in:
parent
4a38b622b2
commit
bd6a4d10ea
11 changed files with 36 additions and 61 deletions
|
@ -1,7 +1,6 @@
|
|||
"""Support for esphome numbers."""
|
||||
from __future__ import annotations
|
||||
|
||||
from contextlib import suppress
|
||||
import math
|
||||
|
||||
from aioesphomeapi import NumberInfo, NumberMode as EsphomeNumberMode, NumberState
|
||||
|
@ -10,6 +9,7 @@ from homeassistant.components.number import NumberDeviceClass, NumberEntity, Num
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util.enum import try_parse_enum
|
||||
|
||||
from . import (
|
||||
EsphomeEntity,
|
||||
|
@ -51,9 +51,7 @@ class EsphomeNumber(EsphomeEntity[NumberInfo, NumberState], NumberEntity):
|
|||
@property
|
||||
def device_class(self) -> NumberDeviceClass | None:
|
||||
"""Return the class of this entity."""
|
||||
with suppress(ValueError):
|
||||
return NumberDeviceClass(self._static_info.device_class)
|
||||
return None
|
||||
return try_parse_enum(NumberDeviceClass, self._static_info.device_class)
|
||||
|
||||
@property
|
||||
def native_min_value(self) -> float:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue