mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add number device class support to ESPHome (#82277)
This commit is contained in:
parent
b717da879f
commit
a07117470e
@ -3,7 +3,7 @@
|
|||||||
"name": "ESPHome",
|
"name": "ESPHome",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/esphome",
|
"documentation": "https://www.home-assistant.io/integrations/esphome",
|
||||||
"requirements": ["aioesphomeapi==11.4.3"],
|
"requirements": ["aioesphomeapi==11.5.0"],
|
||||||
"zeroconf": ["_esphomelib._tcp.local."],
|
"zeroconf": ["_esphomelib._tcp.local."],
|
||||||
"dhcp": [{ "registered_devices": true }],
|
"dhcp": [{ "registered_devices": true }],
|
||||||
"codeowners": ["@OttoWinter", "@jesserockz"],
|
"codeowners": ["@OttoWinter", "@jesserockz"],
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
"""Support for esphome numbers."""
|
"""Support for esphome numbers."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from contextlib import suppress
|
||||||
import math
|
import math
|
||||||
|
|
||||||
from aioesphomeapi import NumberInfo, NumberMode as EsphomeNumberMode, NumberState
|
from aioesphomeapi import NumberInfo, NumberMode as EsphomeNumberMode, NumberState
|
||||||
|
|
||||||
from homeassistant.components.number import NumberEntity, NumberMode
|
from homeassistant.components.number import NumberDeviceClass, NumberEntity, NumberMode
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -47,6 +48,13 @@ NUMBER_MODES: EsphomeEnumMapper[EsphomeNumberMode, NumberMode] = EsphomeEnumMapp
|
|||||||
class EsphomeNumber(EsphomeEntity[NumberInfo, NumberState], NumberEntity):
|
class EsphomeNumber(EsphomeEntity[NumberInfo, NumberState], NumberEntity):
|
||||||
"""A number implementation for esphome."""
|
"""A number implementation for esphome."""
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_min_value(self) -> float:
|
def native_min_value(self) -> float:
|
||||||
"""Return the minimum value."""
|
"""Return the minimum value."""
|
||||||
|
@ -156,7 +156,7 @@ aioecowitt==2022.09.3
|
|||||||
aioemonitor==1.0.5
|
aioemonitor==1.0.5
|
||||||
|
|
||||||
# homeassistant.components.esphome
|
# homeassistant.components.esphome
|
||||||
aioesphomeapi==11.4.3
|
aioesphomeapi==11.5.0
|
||||||
|
|
||||||
# homeassistant.components.flo
|
# homeassistant.components.flo
|
||||||
aioflo==2021.11.0
|
aioflo==2021.11.0
|
||||||
|
@ -143,7 +143,7 @@ aioecowitt==2022.09.3
|
|||||||
aioemonitor==1.0.5
|
aioemonitor==1.0.5
|
||||||
|
|
||||||
# homeassistant.components.esphome
|
# homeassistant.components.esphome
|
||||||
aioesphomeapi==11.4.3
|
aioesphomeapi==11.5.0
|
||||||
|
|
||||||
# homeassistant.components.flo
|
# homeassistant.components.flo
|
||||||
aioflo==2021.11.0
|
aioflo==2021.11.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user