1 """Provides number enties for Home Connect."""
5 from homeconnect.api
import HomeConnectError
12 NumberEntityDescription,
18 from .
import HomeConnectConfigEntry, get_dict_from_home_connect_error
25 SVE_TRANSLATION_PLACEHOLDER_ENTITY_ID,
26 SVE_TRANSLATION_PLACEHOLDER_SETTING_KEY,
27 SVE_TRANSLATION_PLACEHOLDER_VALUE,
29 from .entity
import HomeConnectEntity
31 _LOGGER = logging.getLogger(__name__)
36 key=
"Refrigeration.FridgeFreezer.Setting.SetpointTemperatureRefrigerator",
37 device_class=NumberDeviceClass.TEMPERATURE,
38 translation_key=
"refrigerator_setpoint_temperature",
41 key=
"Refrigeration.FridgeFreezer.Setting.SetpointTemperatureFreezer",
42 device_class=NumberDeviceClass.TEMPERATURE,
43 translation_key=
"freezer_setpoint_temperature",
46 key=
"Refrigeration.Common.Setting.BottleCooler.SetpointTemperature",
47 device_class=NumberDeviceClass.TEMPERATURE,
48 translation_key=
"bottle_cooler_setpoint_temperature",
51 key=
"Refrigeration.Common.Setting.ChillerLeft.SetpointTemperature",
52 device_class=NumberDeviceClass.TEMPERATURE,
53 translation_key=
"chiller_left_setpoint_temperature",
56 key=
"Refrigeration.Common.Setting.ChillerCommon.SetpointTemperature",
57 device_class=NumberDeviceClass.TEMPERATURE,
58 translation_key=
"chiller_setpoint_temperature",
61 key=
"Refrigeration.Common.Setting.ChillerRight.SetpointTemperature",
62 device_class=NumberDeviceClass.TEMPERATURE,
63 translation_key=
"chiller_right_setpoint_temperature",
66 key=
"Refrigeration.Common.Setting.WineCompartment.SetpointTemperature",
67 device_class=NumberDeviceClass.TEMPERATURE,
68 translation_key=
"wine_compartment_setpoint_temperature",
71 key=
"Refrigeration.Common.Setting.WineCompartment2.SetpointTemperature",
72 device_class=NumberDeviceClass.TEMPERATURE,
73 translation_key=
"wine_compartment_2_setpoint_temperature",
76 key=
"Refrigeration.Common.Setting.WineCompartment3.SetpointTemperature",
77 device_class=NumberDeviceClass.TEMPERATURE,
78 translation_key=
"wine_compartment_3_setpoint_temperature",
85 entry: HomeConnectConfigEntry,
86 async_add_entities: AddEntitiesCallback,
88 """Set up the Home Connect number."""
91 """Get a list of entities."""
94 for description
in NUMBERS
95 for device
in entry.runtime_data.devices
96 if description.key
in device.appliance.status
103 """Number setting class for Home Connect."""
106 """Set the native value of the entity."""
108 "Tried to set value %s to %s for %s",
114 await self.
hasshass.async_add_executor_job(
115 self.
devicedevice.appliance.set_setting,
119 except HomeConnectError
as err:
121 translation_domain=DOMAIN,
122 translation_key=
"set_setting",
123 translation_placeholders={
125 SVE_TRANSLATION_PLACEHOLDER_ENTITY_ID: self.
entity_identity_id,
126 SVE_TRANSLATION_PLACEHOLDER_SETTING_KEY: self.
bsh_keybsh_key,
127 SVE_TRANSLATION_PLACEHOLDER_VALUE:
str(value),
131 async
def async_fetch_constraints(self) -> None:
132 """Fetch the max and min values and step for the number entity."""
134 data = await self.
hasshass.async_add_executor_job(
135 self.
devicedevice.appliance.get, f
"/settings/{self.bsh_key}"
137 except HomeConnectError
as err:
138 _LOGGER.error(
"An error occurred: %s", err)
140 if not data
or not (constraints := data.get(ATTR_CONSTRAINTS)):
148 """Update the number setting status."""
149 if not (data := self.
devicedevice.appliance.status.get(self.
bsh_keybsh_key)):
150 _LOGGER.error(
"No value for %s", self.
bsh_keybsh_key)
157 not hasattr(self,
"_attr_native_min_value")
159 or not hasattr(self,
"_attr_native_max_value")
161 or not hasattr(self,
"_attr_native_step")
164 await self.async_fetch_constraints()
_attr_native_unit_of_measurement
None async_set_native_value(self, float value)
list[BaseAprilaireSensor] get_entities(type[BaseAprilaireSensor] entity_class, AprilaireCoordinator coordinator, str unique_id, tuple[AprilaireSensorDescription,...] descriptions)
None async_setup_entry(HomeAssistant hass, HomeConnectConfigEntry entry, AddEntitiesCallback async_add_entities)
dict[str, Any] get_dict_from_home_connect_error(api.HomeConnectError err)