mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Migrate kostal_plenticore number to native_* (#74159)
This commit is contained in:
parent
20680535ec
commit
6a0ca2b36d
@ -818,10 +818,10 @@ NUMBER_SETTINGS_DATA = [
|
|||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
icon="mdi:battery-negative",
|
icon="mdi:battery-negative",
|
||||||
name="Battery min SoC",
|
name="Battery min SoC",
|
||||||
unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
max_value=100,
|
native_max_value=100,
|
||||||
min_value=5,
|
native_min_value=5,
|
||||||
step=5,
|
native_step=5,
|
||||||
module_id="devices:local",
|
module_id="devices:local",
|
||||||
data_id="Battery:MinSoc",
|
data_id="Battery:MinSoc",
|
||||||
fmt_from="format_round",
|
fmt_from="format_round",
|
||||||
@ -833,10 +833,10 @@ NUMBER_SETTINGS_DATA = [
|
|||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
name="Battery min Home Consumption",
|
name="Battery min Home Consumption",
|
||||||
unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=POWER_WATT,
|
||||||
max_value=38000,
|
native_max_value=38000,
|
||||||
min_value=50,
|
native_min_value=50,
|
||||||
step=1,
|
native_step=1,
|
||||||
module_id="devices:local",
|
module_id="devices:local",
|
||||||
data_id="Battery:MinHomeComsumption",
|
data_id="Battery:MinHomeComsumption",
|
||||||
fmt_from="format_round",
|
fmt_from="format_round",
|
||||||
|
@ -105,9 +105,9 @@ class PlenticoreDataNumber(CoordinatorEntity, NumberEntity, ABC):
|
|||||||
|
|
||||||
# overwrite from retrieved setting data
|
# overwrite from retrieved setting data
|
||||||
if setting_data.min is not None:
|
if setting_data.min is not None:
|
||||||
self._attr_min_value = self._formatter(setting_data.min)
|
self._attr_native_min_value = self._formatter(setting_data.min)
|
||||||
if setting_data.max is not None:
|
if setting_data.max is not None:
|
||||||
self._attr_max_value = self._formatter(setting_data.max)
|
self._attr_native_max_value = self._formatter(setting_data.max)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def module_id(self) -> str:
|
def module_id(self) -> str:
|
||||||
@ -140,7 +140,7 @@ class PlenticoreDataNumber(CoordinatorEntity, NumberEntity, ABC):
|
|||||||
await super().async_will_remove_from_hass()
|
await super().async_will_remove_from_hass()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def value(self) -> float | None:
|
def native_value(self) -> float | None:
|
||||||
"""Return the current value."""
|
"""Return the current value."""
|
||||||
if self.available:
|
if self.available:
|
||||||
raw_value = self.coordinator.data[self.module_id][self.data_id]
|
raw_value = self.coordinator.data[self.module_id][self.data_id]
|
||||||
@ -148,7 +148,7 @@ class PlenticoreDataNumber(CoordinatorEntity, NumberEntity, ABC):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def async_set_value(self, value: float) -> None:
|
async def async_set_native_value(self, value: float) -> None:
|
||||||
"""Set a new value."""
|
"""Set a new value."""
|
||||||
str_value = self._formatter_back(value)
|
str_value = self._formatter_back(value)
|
||||||
await self.coordinator.async_write_data(
|
await self.coordinator.async_write_data(
|
||||||
|
@ -31,8 +31,8 @@ def mock_number_description() -> PlenticoreNumberEntityDescription:
|
|||||||
key="mock key",
|
key="mock key",
|
||||||
module_id="moduleid",
|
module_id="moduleid",
|
||||||
data_id="dataid",
|
data_id="dataid",
|
||||||
min_value=0,
|
native_min_value=0,
|
||||||
max_value=1000,
|
native_max_value=1000,
|
||||||
fmt_from="format_round",
|
fmt_from="format_round",
|
||||||
fmt_to="format_round_back",
|
fmt_to="format_round_back",
|
||||||
)
|
)
|
||||||
@ -136,7 +136,7 @@ async def test_set_value(
|
|||||||
mock_coordinator, "42", "scb", None, mock_number_description, mock_setting_data
|
mock_coordinator, "42", "scb", None, mock_number_description, mock_setting_data
|
||||||
)
|
)
|
||||||
|
|
||||||
await entity.async_set_value(42)
|
await entity.async_set_native_value(42)
|
||||||
|
|
||||||
mock_coordinator.async_write_data.assert_called_once_with(
|
mock_coordinator.async_write_data.assert_called_once_with(
|
||||||
"moduleid", {"dataid": "42"}
|
"moduleid", {"dataid": "42"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user