mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Migrate NumberEntity a-j to native_value (#73486)
This commit is contained in:
parent
576de9ac40
commit
1f7340313a
@ -40,8 +40,8 @@ AUTO_COMFORT_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="comfort_min_speed",
|
||||
name="Auto Comfort Minimum Speed",
|
||||
min_value=0,
|
||||
max_value=SPEED_RANGE[1] - 1,
|
||||
native_min_value=0,
|
||||
native_max_value=SPEED_RANGE[1] - 1,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(Optional[int], device.comfort_min_speed),
|
||||
mode=NumberMode.BOX,
|
||||
@ -49,8 +49,8 @@ AUTO_COMFORT_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="comfort_max_speed",
|
||||
name="Auto Comfort Maximum Speed",
|
||||
min_value=1,
|
||||
max_value=SPEED_RANGE[1],
|
||||
native_min_value=1,
|
||||
native_max_value=SPEED_RANGE[1],
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(Optional[int], device.comfort_max_speed),
|
||||
mode=NumberMode.BOX,
|
||||
@ -58,8 +58,8 @@ AUTO_COMFORT_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="comfort_heat_assist_speed",
|
||||
name="Auto Comfort Heat Assist Speed",
|
||||
min_value=SPEED_RANGE[0],
|
||||
max_value=SPEED_RANGE[1],
|
||||
native_min_value=SPEED_RANGE[0],
|
||||
native_max_value=SPEED_RANGE[1],
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
value_fn=lambda device: cast(Optional[int], device.comfort_heat_assist_speed),
|
||||
mode=NumberMode.BOX,
|
||||
@ -70,20 +70,20 @@ FAN_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="return_to_auto_timeout",
|
||||
name="Return to Auto Timeout",
|
||||
min_value=ONE_MIN_SECS,
|
||||
max_value=HALF_DAY_SECS,
|
||||
native_min_value=ONE_MIN_SECS,
|
||||
native_max_value=HALF_DAY_SECS,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
unit_of_measurement=TIME_SECONDS,
|
||||
native_unit_of_measurement=TIME_SECONDS,
|
||||
value_fn=lambda device: cast(Optional[int], device.return_to_auto_timeout),
|
||||
mode=NumberMode.SLIDER,
|
||||
),
|
||||
BAFNumberDescription(
|
||||
key="motion_sense_timeout",
|
||||
name="Motion Sense Timeout",
|
||||
min_value=ONE_MIN_SECS,
|
||||
max_value=ONE_DAY_SECS,
|
||||
native_min_value=ONE_MIN_SECS,
|
||||
native_max_value=ONE_DAY_SECS,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
unit_of_measurement=TIME_SECONDS,
|
||||
native_unit_of_measurement=TIME_SECONDS,
|
||||
value_fn=lambda device: cast(Optional[int], device.motion_sense_timeout),
|
||||
mode=NumberMode.SLIDER,
|
||||
),
|
||||
@ -93,10 +93,10 @@ LIGHT_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="light_return_to_auto_timeout",
|
||||
name="Light Return to Auto Timeout",
|
||||
min_value=ONE_MIN_SECS,
|
||||
max_value=HALF_DAY_SECS,
|
||||
native_min_value=ONE_MIN_SECS,
|
||||
native_max_value=HALF_DAY_SECS,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
unit_of_measurement=TIME_SECONDS,
|
||||
native_unit_of_measurement=TIME_SECONDS,
|
||||
value_fn=lambda device: cast(
|
||||
Optional[int], device.light_return_to_auto_timeout
|
||||
),
|
||||
@ -105,10 +105,10 @@ LIGHT_NUMBER_DESCRIPTIONS = (
|
||||
BAFNumberDescription(
|
||||
key="light_auto_motion_timeout",
|
||||
name="Light Motion Sense Timeout",
|
||||
min_value=ONE_MIN_SECS,
|
||||
max_value=ONE_DAY_SECS,
|
||||
native_min_value=ONE_MIN_SECS,
|
||||
native_max_value=ONE_DAY_SECS,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
unit_of_measurement=TIME_SECONDS,
|
||||
native_unit_of_measurement=TIME_SECONDS,
|
||||
value_fn=lambda device: cast(Optional[int], device.light_auto_motion_timeout),
|
||||
mode=NumberMode.SLIDER,
|
||||
),
|
||||
@ -149,8 +149,8 @@ class BAFNumber(BAFEntity, NumberEntity):
|
||||
def _async_update_attrs(self) -> None:
|
||||
"""Update attrs from device."""
|
||||
if (value := self.entity_description.value_fn(self._device)) is not None:
|
||||
self._attr_value = float(value)
|
||||
self._attr_native_value = float(value)
|
||||
|
||||
async def async_set_value(self, value: float) -> None:
|
||||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Set the value."""
|
||||
setattr(self._device, self.entity_description.key, int(value))
|
||||
|
@ -43,9 +43,9 @@ ENTITY_DESCRIPTIONS = {
|
||||
value_fn=lambda device: device.delay,
|
||||
suffix="Delay",
|
||||
update_key=PRESENCE_DELAY,
|
||||
max_value=65535,
|
||||
min_value=0,
|
||||
step=1,
|
||||
native_max_value=65535,
|
||||
native_min_value=0,
|
||||
native_step=1,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
)
|
||||
]
|
||||
@ -107,11 +107,11 @@ class DeconzNumber(DeconzDevice, NumberEntity):
|
||||
super().async_update_callback()
|
||||
|
||||
@property
|
||||
def value(self) -> float | None:
|
||||
def native_value(self) -> float | None:
|
||||
"""Return the value of the sensor property."""
|
||||
return self.entity_description.value_fn(self._device)
|
||||
|
||||
async def async_set_value(self, value: float) -> None:
|
||||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Set sensor config."""
|
||||
data = {self.entity_description.key: int(value)}
|
||||
await self._device.set_config(**data)
|
||||
|
@ -85,9 +85,9 @@ class DemoNumber(NumberEntity):
|
||||
state: float,
|
||||
icon: str,
|
||||
assumed: bool,
|
||||
min_value: float | None = None,
|
||||
max_value: float | None = None,
|
||||
step: float | None = None,
|
||||
native_min_value: float | None = None,
|
||||
native_max_value: float | None = None,
|
||||
native_step: float | None = None,
|
||||
mode: NumberMode = NumberMode.AUTO,
|
||||
) -> None:
|
||||
"""Initialize the Demo Number entity."""
|
||||
@ -95,15 +95,15 @@ class DemoNumber(NumberEntity):
|
||||
self._attr_icon = icon
|
||||
self._attr_name = name or DEVICE_DEFAULT_NAME
|
||||
self._attr_unique_id = unique_id
|
||||
self._attr_value = state
|
||||
self._attr_native_value = state
|
||||
self._attr_mode = mode
|
||||
|
||||
if min_value is not None:
|
||||
self._attr_min_value = min_value
|
||||
if max_value is not None:
|
||||
self._attr_max_value = max_value
|
||||
if step is not None:
|
||||
self._attr_step = step
|
||||
if native_min_value is not None:
|
||||
self._attr_min_value = native_min_value
|
||||
if native_max_value is not None:
|
||||
self._attr_max_value = native_max_value
|
||||
if native_step is not None:
|
||||
self._attr_step = native_step
|
||||
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
@ -113,7 +113,7 @@ class DemoNumber(NumberEntity):
|
||||
name=self.name,
|
||||
)
|
||||
|
||||
async def async_set_value(self, value):
|
||||
async def async_set_native_value(self, value):
|
||||
"""Update the current value."""
|
||||
self._attr_value = value
|
||||
self._attr_native_value = value
|
||||
self.async_write_ha_state()
|
||||
|
@ -52,22 +52,22 @@ class EsphomeNumber(EsphomeEntity[NumberInfo, NumberState], NumberEntity):
|
||||
"""A number implementation for esphome."""
|
||||
|
||||
@property
|
||||
def min_value(self) -> float:
|
||||
def native_min_value(self) -> float:
|
||||
"""Return the minimum value."""
|
||||
return super()._static_info.min_value
|
||||
|
||||
@property
|
||||
def max_value(self) -> float:
|
||||
def native_max_value(self) -> float:
|
||||
"""Return the maximum value."""
|
||||
return super()._static_info.max_value
|
||||
|
||||
@property
|
||||
def step(self) -> float:
|
||||
def native_step(self) -> float:
|
||||
"""Return the increment/decrement step."""
|
||||
return super()._static_info.step
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self) -> str | None:
|
||||
def native_unit_of_measurement(self) -> str | None:
|
||||
"""Return the unit of measurement."""
|
||||
return super()._static_info.unit_of_measurement
|
||||
|
||||
@ -79,7 +79,7 @@ class EsphomeNumber(EsphomeEntity[NumberInfo, NumberState], NumberEntity):
|
||||
return NumberMode.AUTO
|
||||
|
||||
@esphome_state_property
|
||||
def value(self) -> float | None:
|
||||
def native_value(self) -> float | None:
|
||||
"""Return the state of the entity."""
|
||||
if math.isnan(self._state.state):
|
||||
return None
|
||||
@ -87,6 +87,6 @@ class EsphomeNumber(EsphomeEntity[NumberInfo, NumberState], NumberEntity):
|
||||
return None
|
||||
return self._state.state
|
||||
|
||||
async def async_set_value(self, value: float) -> None:
|
||||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Update the current value."""
|
||||
await self._client.number_command(self._static_info.key, value)
|
||||
|
@ -34,11 +34,11 @@ async def async_setup_entry(
|
||||
class PeriodicVentingTime(CoordinatorEntity[Coordinator], NumberEntity):
|
||||
"""Periodic Venting."""
|
||||
|
||||
_attr_max_value: float = 59
|
||||
_attr_min_value: float = 0
|
||||
_attr_step: float = 1
|
||||
_attr_native_max_value: float = 59
|
||||
_attr_native_min_value: float = 0
|
||||
_attr_native_step: float = 1
|
||||
_attr_entity_category = EntityCategory.CONFIG
|
||||
_attr_unit_of_measurement = TIME_MINUTES
|
||||
_attr_native_unit_of_measurement = TIME_MINUTES
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -54,13 +54,13 @@ class PeriodicVentingTime(CoordinatorEntity[Coordinator], NumberEntity):
|
||||
self._attr_name = f"{device_info['name']} Periodic Venting"
|
||||
|
||||
@property
|
||||
def value(self) -> float | None:
|
||||
def native_value(self) -> float | None:
|
||||
"""Return the entity value to represent the entity state."""
|
||||
if data := self.coordinator.data:
|
||||
return data.periodic_venting
|
||||
return None
|
||||
|
||||
async def async_set_value(self, value: float) -> None:
|
||||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Set new value."""
|
||||
await self._device.send_periodic_venting(int(value))
|
||||
self.coordinator.async_set_updated_data(self._device.state)
|
||||
|
@ -97,18 +97,18 @@ class FluxSpeedNumber(
|
||||
):
|
||||
"""Defines a flux_led speed number."""
|
||||
|
||||
_attr_min_value = 1
|
||||
_attr_max_value = 100
|
||||
_attr_step = 1
|
||||
_attr_native_min_value = 1
|
||||
_attr_native_max_value = 100
|
||||
_attr_native_step = 1
|
||||
_attr_mode = NumberMode.SLIDER
|
||||
_attr_icon = "mdi:speedometer"
|
||||
|
||||
@property
|
||||
def value(self) -> float:
|
||||
def native_value(self) -> float:
|
||||
"""Return the effect speed."""
|
||||
return cast(float, self._device.speed)
|
||||
|
||||
async def async_set_value(self, value: float) -> None:
|
||||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Set the flux speed value."""
|
||||
current_effect = self._device.effect
|
||||
new_speed = int(value)
|
||||
@ -130,8 +130,8 @@ class FluxConfigNumber(
|
||||
"""Base class for flux config numbers."""
|
||||
|
||||
_attr_entity_category = EntityCategory.CONFIG
|
||||
_attr_min_value = 1
|
||||
_attr_step = 1
|
||||
_attr_native_min_value = 1
|
||||
_attr_native_step = 1
|
||||
_attr_mode = NumberMode.BOX
|
||||
|
||||
def __init__(
|
||||
@ -153,18 +153,18 @@ class FluxConfigNumber(
|
||||
logger=_LOGGER,
|
||||
cooldown=DEBOUNCE_TIME,
|
||||
immediate=False,
|
||||
function=self._async_set_value,
|
||||
function=self._async_set_native_value,
|
||||
)
|
||||
await super().async_added_to_hass()
|
||||
|
||||
async def async_set_value(self, value: float) -> None:
|
||||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Set the value."""
|
||||
self._pending_value = int(value)
|
||||
assert self._debouncer is not None
|
||||
await self._debouncer.async_call()
|
||||
|
||||
@abstractmethod
|
||||
async def _async_set_value(self) -> None:
|
||||
async def _async_set_native_value(self) -> None:
|
||||
"""Call on debounce to set the value."""
|
||||
|
||||
def _pixels_and_segments_fit_in_music_mode(self) -> bool:
|
||||
@ -189,19 +189,19 @@ class FluxPixelsPerSegmentNumber(FluxConfigNumber):
|
||||
_attr_icon = "mdi:dots-grid"
|
||||
|
||||
@property
|
||||
def max_value(self) -> int:
|
||||
def native_max_value(self) -> int:
|
||||
"""Return the max value."""
|
||||
return min(
|
||||
PIXELS_PER_SEGMENT_MAX, int(PIXELS_MAX / (self._device.segments or 1))
|
||||
)
|
||||
|
||||
@property
|
||||
def value(self) -> int:
|
||||
def native_value(self) -> int:
|
||||
"""Return the pixels per segment."""
|
||||
assert self._device.pixels_per_segment is not None
|
||||
return self._device.pixels_per_segment
|
||||
|
||||
async def _async_set_value(self) -> None:
|
||||
async def _async_set_native_value(self) -> None:
|
||||
"""Set the pixels per segment."""
|
||||
assert self._pending_value is not None
|
||||
await self._device.async_set_device_config(
|
||||
@ -215,7 +215,7 @@ class FluxSegmentsNumber(FluxConfigNumber):
|
||||
_attr_icon = "mdi:segment"
|
||||
|
||||
@property
|
||||
def max_value(self) -> int:
|
||||
def native_max_value(self) -> int:
|
||||
"""Return the max value."""
|
||||
assert self._device.pixels_per_segment is not None
|
||||
return min(
|
||||
@ -223,12 +223,12 @@ class FluxSegmentsNumber(FluxConfigNumber):
|
||||
)
|
||||
|
||||
@property
|
||||
def value(self) -> int:
|
||||
def native_value(self) -> int:
|
||||
"""Return the segments."""
|
||||
assert self._device.segments is not None
|
||||
return self._device.segments
|
||||
|
||||
async def _async_set_value(self) -> None:
|
||||
async def _async_set_native_value(self) -> None:
|
||||
"""Set the segments."""
|
||||
assert self._pending_value is not None
|
||||
await self._device.async_set_device_config(segments=self._pending_value)
|
||||
@ -249,7 +249,7 @@ class FluxMusicPixelsPerSegmentNumber(FluxMusicNumber):
|
||||
_attr_icon = "mdi:dots-grid"
|
||||
|
||||
@property
|
||||
def max_value(self) -> int:
|
||||
def native_max_value(self) -> int:
|
||||
"""Return the max value."""
|
||||
assert self._device.music_segments is not None
|
||||
return min(
|
||||
@ -258,12 +258,12 @@ class FluxMusicPixelsPerSegmentNumber(FluxMusicNumber):
|
||||
)
|
||||
|
||||
@property
|
||||
def value(self) -> int:
|
||||
def native_value(self) -> int:
|
||||
"""Return the music pixels per segment."""
|
||||
assert self._device.music_pixels_per_segment is not None
|
||||
return self._device.music_pixels_per_segment
|
||||
|
||||
async def _async_set_value(self) -> None:
|
||||
async def _async_set_native_value(self) -> None:
|
||||
"""Set the music pixels per segment."""
|
||||
assert self._pending_value is not None
|
||||
await self._device.async_set_device_config(
|
||||
@ -277,7 +277,7 @@ class FluxMusicSegmentsNumber(FluxMusicNumber):
|
||||
_attr_icon = "mdi:segment"
|
||||
|
||||
@property
|
||||
def max_value(self) -> int:
|
||||
def native_max_value(self) -> int:
|
||||
"""Return the max value."""
|
||||
assert self._device.pixels_per_segment is not None
|
||||
return min(
|
||||
@ -286,12 +286,12 @@ class FluxMusicSegmentsNumber(FluxMusicNumber):
|
||||
)
|
||||
|
||||
@property
|
||||
def value(self) -> int:
|
||||
def native_value(self) -> int:
|
||||
"""Return the music segments."""
|
||||
assert self._device.music_segments is not None
|
||||
return self._device.music_segments
|
||||
|
||||
async def _async_set_value(self) -> None:
|
||||
async def _async_set_native_value(self) -> None:
|
||||
"""Set the music segments."""
|
||||
assert self._pending_value is not None
|
||||
await self._device.async_set_device_config(music_segments=self._pending_value)
|
||||
|
@ -40,24 +40,24 @@ NUMBERS = (
|
||||
name="Grid export limit",
|
||||
icon="mdi:transmission-tower",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
getter=lambda inv: inv.get_grid_export_limit(),
|
||||
setter=lambda inv, val: inv.set_grid_export_limit(val),
|
||||
step=100,
|
||||
min_value=0,
|
||||
max_value=10000,
|
||||
native_step=100,
|
||||
native_min_value=0,
|
||||
native_max_value=10000,
|
||||
),
|
||||
GoodweNumberEntityDescription(
|
||||
key="battery_discharge_depth",
|
||||
name="Depth of discharge (on-grid)",
|
||||
icon="mdi:battery-arrow-down",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
unit_of_measurement=PERCENTAGE,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
getter=lambda inv: inv.get_ongrid_battery_dod(),
|
||||
setter=lambda inv, val: inv.set_ongrid_battery_dod(val),
|
||||
step=1,
|
||||
min_value=0,
|
||||
max_value=99,
|
||||
native_step=1,
|
||||
native_min_value=0,
|
||||
native_max_value=99,
|
||||
),
|
||||
)
|
||||
|
||||
@ -105,12 +105,12 @@ class InverterNumberEntity(NumberEntity):
|
||||
self.entity_description = description
|
||||
self._attr_unique_id = f"{DOMAIN}-{description.key}-{inverter.serial_number}"
|
||||
self._attr_device_info = device_info
|
||||
self._attr_value = float(current_value)
|
||||
self._attr_native_value = float(current_value)
|
||||
self._inverter: Inverter = inverter
|
||||
|
||||
async def async_set_value(self, value: float) -> None:
|
||||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Set new value."""
|
||||
if self.entity_description.setter:
|
||||
await self.entity_description.setter(self._inverter, int(value))
|
||||
self._attr_value = value
|
||||
self._attr_native_value = value
|
||||
self.async_write_ha_state()
|
||||
|
@ -104,26 +104,26 @@ class HomeKitNumber(CharacteristicEntity, NumberEntity):
|
||||
return [self._char.type]
|
||||
|
||||
@property
|
||||
def min_value(self) -> float:
|
||||
def native_min_value(self) -> float:
|
||||
"""Return the minimum value."""
|
||||
return self._char.minValue or DEFAULT_MIN_VALUE
|
||||
|
||||
@property
|
||||
def max_value(self) -> float:
|
||||
def native_max_value(self) -> float:
|
||||
"""Return the maximum value."""
|
||||
return self._char.maxValue or DEFAULT_MAX_VALUE
|
||||
|
||||
@property
|
||||
def step(self) -> float:
|
||||
def native_step(self) -> float:
|
||||
"""Return the increment/decrement step."""
|
||||
return self._char.minStep or DEFAULT_STEP
|
||||
|
||||
@property
|
||||
def value(self) -> float:
|
||||
def native_value(self) -> float:
|
||||
"""Return the current characteristic value."""
|
||||
return self._char.value
|
||||
|
||||
async def async_set_value(self, value: float) -> None:
|
||||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Set the characteristic to this value."""
|
||||
await self.async_put_characteristics(
|
||||
{
|
||||
@ -148,26 +148,26 @@ class HomeKitEcobeeFanModeNumber(CharacteristicEntity, NumberEntity):
|
||||
return f"{prefix} Fan Mode"
|
||||
|
||||
@property
|
||||
def min_value(self) -> float:
|
||||
def native_min_value(self) -> float:
|
||||
"""Return the minimum value."""
|
||||
return self._char.minValue or DEFAULT_MIN_VALUE
|
||||
|
||||
@property
|
||||
def max_value(self) -> float:
|
||||
def native_max_value(self) -> float:
|
||||
"""Return the maximum value."""
|
||||
return self._char.maxValue or DEFAULT_MAX_VALUE
|
||||
|
||||
@property
|
||||
def step(self) -> float:
|
||||
def native_step(self) -> float:
|
||||
"""Return the increment/decrement step."""
|
||||
return self._char.minStep or DEFAULT_STEP
|
||||
|
||||
@property
|
||||
def value(self) -> float:
|
||||
def native_value(self) -> float:
|
||||
"""Return the current characteristic value."""
|
||||
return self._char.value
|
||||
|
||||
async def async_set_value(self, value: float) -> None:
|
||||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Set the characteristic to this value."""
|
||||
|
||||
# Sending the fan mode request sometimes ends up getting ignored by ecobee
|
||||
|
@ -29,16 +29,16 @@ class JuiceNetNumberEntityDescription(
|
||||
):
|
||||
"""An entity description for a JuiceNetNumber."""
|
||||
|
||||
max_value_key: str | None = None
|
||||
native_max_value_key: str | None = None
|
||||
|
||||
|
||||
NUMBER_TYPES: tuple[JuiceNetNumberEntityDescription, ...] = (
|
||||
JuiceNetNumberEntityDescription(
|
||||
name="Amperage Limit",
|
||||
key="current_charging_amperage_limit",
|
||||
min_value=6,
|
||||
max_value_key="max_charging_amperage",
|
||||
step=1,
|
||||
native_min_value=6,
|
||||
native_max_value_key="max_charging_amperage",
|
||||
native_step=1,
|
||||
setter_key="set_charging_amperage_limit",
|
||||
),
|
||||
)
|
||||
@ -80,19 +80,19 @@ class JuiceNetNumber(JuiceNetDevice, NumberEntity):
|
||||
self._attr_name = f"{self.device.name} {description.name}"
|
||||
|
||||
@property
|
||||
def value(self) -> float | None:
|
||||
def native_value(self) -> float | None:
|
||||
"""Return the value of the entity."""
|
||||
return getattr(self.device, self.entity_description.key, None)
|
||||
|
||||
@property
|
||||
def max_value(self) -> float:
|
||||
def native_max_value(self) -> float:
|
||||
"""Return the maximum value."""
|
||||
if self.entity_description.max_value_key is not None:
|
||||
return getattr(self.device, self.entity_description.max_value_key)
|
||||
if self.entity_description.max_value is not None:
|
||||
return self.entity_description.max_value
|
||||
if self.entity_description.native_max_value_key is not None:
|
||||
return getattr(self.device, self.entity_description.native_max_value_key)
|
||||
if self.entity_description.native_max_value is not None:
|
||||
return self.entity_description.native_max_value
|
||||
return DEFAULT_MAX_VALUE
|
||||
|
||||
async def async_set_value(self, value: float) -> None:
|
||||
async def async_set_native_value(self, value: float) -> None:
|
||||
"""Update the current value."""
|
||||
await getattr(self.device, self.entity_description.setter_key)(value)
|
||||
|
Loading…
x
Reference in New Issue
Block a user