1313 NumberEntity ,
1414 NumberEntityDescription ,
1515)
16- from homeassistant .const import EntityCategory , Platform , UnitOfTime
16+ from homeassistant .const import (
17+ PERCENTAGE ,
18+ EntityCategory ,
19+ Platform ,
20+ UnitOfTemperature ,
21+ UnitOfTime ,
22+ )
1723from homeassistant .core import HomeAssistant , callback
1824from homeassistant .helpers .entity_platform import AddEntitiesCallback
1925
@@ -32,8 +38,8 @@ class PlugwiseNumberEntityDescription(
3238):
3339 """Describes Plugwise Number entity."""
3440
35- api_attribute : str = ""
3641 async_number_fn : str = ""
42+ async_number_type : str = "int"
3743
3844
3945NUMBER_TYPES : tuple [PlugwiseNumberEntityDescription , ...] = (
@@ -47,7 +53,7 @@ class PlugwiseNumberEntityDescription(
4753 native_unit_of_measurement = UnitOfTime .MINUTES ,
4854 native_max_value = 255 ,
4955 native_min_value = 1 ,
50- api_attribute = "reset_timer " ,
56+ mode = "box " ,
5157 ),
5258 PlugwiseNumberEntityDescription (
5359 key = "maintenance_interval" ,
@@ -59,7 +65,6 @@ class PlugwiseNumberEntityDescription(
5965 native_unit_of_measurement = UnitOfTime .MINUTES ,
6066 native_max_value = 1440 ,
6167 native_min_value = 5 ,
62- api_attribute = "maintenance_interval" ,
6368 ),
6469 PlugwiseNumberEntityDescription (
6570 key = "sleep_duration" ,
@@ -71,7 +76,6 @@ class PlugwiseNumberEntityDescription(
7176 entity_category = EntityCategory .CONFIG ,
7277 native_max_value = 1440 ,
7378 native_min_value = 60 ,
74- api_attribute = "sleep_duration" ,
7579 ),
7680 PlugwiseNumberEntityDescription (
7781 key = "awake_duration" ,
@@ -83,7 +87,7 @@ class PlugwiseNumberEntityDescription(
8387 entity_category = EntityCategory .CONFIG ,
8488 native_max_value = 60 ,
8589 native_min_value = 1 ,
86- api_attribute = "awake_duration " ,
90+ mode = "box " ,
8791 ),
8892 PlugwiseNumberEntityDescription (
8993 key = "clock_interval" ,
@@ -95,7 +99,62 @@ class PlugwiseNumberEntityDescription(
9599 native_unit_of_measurement = UnitOfTime .MINUTES ,
96100 native_max_value = 65535 ,
97101 native_min_value = 1 ,
98- api_attribute = "clock_interval" ,
102+ ),
103+ PlugwiseNumberEntityDescription (
104+ key = "humidity_upper_bound" ,
105+ translation_key = "sense_humidity_upper_bound" ,
106+ async_number_fn = "set_hysteresis_humidity_upper_bound" ,
107+ node_feature = NodeFeature .SENSE_HYSTERESIS ,
108+ entity_category = EntityCategory .CONFIG ,
109+ device_class = NumberDeviceClass .HUMIDITY ,
110+ native_unit_of_measurement = PERCENTAGE ,
111+ native_max_value = 99 ,
112+ native_min_value = 1 ,
113+ native_step = 0.1 ,
114+ async_number_type = "float" ,
115+ mode = "box" ,
116+ ),
117+ PlugwiseNumberEntityDescription (
118+ key = "humidity_lower_bound" ,
119+ translation_key = "sense_humidity_lower_bound" ,
120+ async_number_fn = "set_hysteresis_humidity_lower_bound" ,
121+ node_feature = NodeFeature .SENSE_HYSTERESIS ,
122+ entity_category = EntityCategory .CONFIG ,
123+ device_class = NumberDeviceClass .HUMIDITY ,
124+ native_unit_of_measurement = PERCENTAGE ,
125+ native_max_value = 99 ,
126+ native_min_value = 1 ,
127+ native_step = 0.1 ,
128+ async_number_type = "float" ,
129+ mode = "box" ,
130+ ),
131+ PlugwiseNumberEntityDescription (
132+ key = "temperature_upper_bound" ,
133+ translation_key = "sense_temperature_upper_bound" ,
134+ async_number_fn = "set_hysteresis_temperature_upper_bound" ,
135+ node_feature = NodeFeature .SENSE_HYSTERESIS ,
136+ entity_category = EntityCategory .CONFIG ,
137+ device_class = NumberDeviceClass .TEMPERATURE ,
138+ native_unit_of_measurement = UnitOfTemperature .CELSIUS ,
139+ native_max_value = 60 ,
140+ native_min_value = 1 ,
141+ native_step = 0.1 ,
142+ async_number_type = "float" ,
143+ mode = "box" ,
144+ ),
145+ PlugwiseNumberEntityDescription (
146+ key = "temperature_lower_bound" ,
147+ translation_key = "sense_temperature_lower_bound" ,
148+ async_number_fn = "set_hysteresis_temperature_lower_bound" ,
149+ node_feature = NodeFeature .SENSE_HYSTERESIS ,
150+ entity_category = EntityCategory .CONFIG ,
151+ device_class = NumberDeviceClass .TEMPERATURE ,
152+ native_unit_of_measurement = UnitOfTemperature .CELSIUS ,
153+ native_max_value = 60 ,
154+ native_min_value = 1 ,
155+ native_step = 0.1 ,
156+ async_number_type = "float" ,
157+ mode = "box" ,
99158 ),
100159)
101160
@@ -178,12 +237,14 @@ def _handle_coordinator_update(self) -> None:
178237 return
179238 self ._attr_native_value = getattr (
180239 self .coordinator .data [self .entity_description .node_feature ],
181- self .entity_description .api_attribute ,
240+ self .entity_description .key ,
182241 )
183242 self .async_write_ha_state ()
184243
185244 async def async_set_native_value (self , value : float ) -> None :
186245 """Update the current value."""
187-
188- await self .async_number_fn (int (value ))
246+ if self .entity_description .async_number_type == "float" :
247+ await self .async_number_fn (float (value ))
248+ else :
249+ await self .async_number_fn (int (value ))
189250 self .async_write_ha_state ()
0 commit comments