7
7
from homeassistant .components .sensor import (ENTITY_ID_FORMAT ,
8
8
STATE_CLASS_MEASUREMENT )
9
9
from homeassistant .config_entries import ConfigEntry
10
- from homeassistant .const import DEVICE_CLASS_TEMPERATURE , ENTITY_CATEGORIES , TEMP_CELSIUS
10
+ from homeassistant .const import (DEVICE_CLASS_TEMPERATURE , ENTITY_CATEGORIES ,
11
+ TEMP_CELSIUS )
11
12
from homeassistant .core import HomeAssistant
12
- from homeassistant .helpers .entity import DeviceInfo
13
+ from homeassistant .helpers .entity import DeviceInfo , EntityCategory
13
14
from homeassistant .helpers .entity_platform import AddEntitiesCallback
14
15
from homeassistant .helpers .restore_state import RestoreEntity
15
16
from homeassistant .helpers .typing import ConfigType
18
19
from .const import (CONF_LANGUAGE_SENSOR_NAMES , DOMAIN , LOGGER ,
19
20
LUX_SENSOR_COOLING_THRESHOLD ,
20
21
LUX_SENSOR_DOMESTIC_WATER_TARGET_TEMPERATURE ,
22
+ LUX_SENSOR_HEATING_MIN_FLOW_OUT_TEMPERATURE ,
21
23
LUX_SENSOR_HEATING_TEMPERATURE_CORRECTION ,
22
- LUX_SENSOR_HEATING_THRESHOLD )
24
+ LUX_SENSOR_HEATING_THRESHOLD_TEMPERATURE )
23
25
from .helpers .helper import get_sensor_text
24
26
25
27
# endregion Imports
@@ -57,17 +59,23 @@ async def async_setup_entry(
57
59
if deviceInfoHeating is not None :
58
60
text_heating_threshold = get_sensor_text (lang , 'heating_threshold' )
59
61
text_correction = get_sensor_text (lang , 'correction' )
62
+ text_min_flow_out_temperature = get_sensor_text (lang , 'min_flow_out_temperature' )
60
63
entities += [
61
64
LuxtronikNumber (
62
65
hass , luxtronik , deviceInfoHeating ,
63
66
number_key = LUX_SENSOR_HEATING_TEMPERATURE_CORRECTION ,
64
67
unique_id = 'heating_temperature_correction' , name = f"{ text_temp } { text_correction } " ,
65
- icon = 'mdi:plus-minus-variant' , unit_of_measurement = TEMP_CELSIUS , min_value = - 5.0 , max_value = 5.0 , step = 0.5 , mode = MODE_BOX ),
68
+ icon = 'mdi:plus-minus-variant' , unit_of_measurement = TEMP_CELSIUS , min_value = - 5.0 , max_value = 5.0 , step = 0.5 , mode = MODE_BOX , entity_category = None ),
66
69
LuxtronikNumber (
67
70
hass , luxtronik , deviceInfoHeating ,
68
- number_key = LUX_SENSOR_HEATING_THRESHOLD ,
71
+ number_key = LUX_SENSOR_HEATING_THRESHOLD_TEMPERATURE ,
69
72
unique_id = 'heating_threshold_temperature' , name = f"{ text_heating_threshold } " ,
70
- icon = 'mdi:download-outline' , unit_of_measurement = TEMP_CELSIUS , min_value = 5.0 , max_value = 12.0 , step = 0.5 , mode = MODE_BOX )
73
+ icon = 'mdi:download-outline' , unit_of_measurement = TEMP_CELSIUS , min_value = 5.0 , max_value = 12.0 , step = 0.5 , mode = MODE_BOX , entity_category = EntityCategory .CONFIG ),
74
+ LuxtronikNumber (
75
+ hass , luxtronik , deviceInfoHeating ,
76
+ number_key = LUX_SENSOR_HEATING_MIN_FLOW_OUT_TEMPERATURE ,
77
+ unique_id = 'heating_min_flow_out_temperature' , name = f"{ text_min_flow_out_temperature } " ,
78
+ icon = 'mdi:waves-arrow-left' , unit_of_measurement = TEMP_CELSIUS , min_value = 5.0 , max_value = 30.0 , step = 0.5 , factor = 0.1 , mode = MODE_BOX , entity_category = EntityCategory .CONFIG )
71
79
]
72
80
73
81
deviceInfoDomesticWater = hass .data [f"{ DOMAIN } _DeviceInfo_Domestic_Water" ]
@@ -117,6 +125,7 @@ def __init__(
117
125
step : float = None , # | None = None,
118
126
mode : Literal ["auto" , "box" , "slider" ] = MODE_AUTO ,
119
127
entity_category : ENTITY_CATEGORIES = None ,
128
+ factor : float = 1.0 ,
120
129
) -> None :
121
130
"""Initialize the number."""
122
131
self ._hass = hass
@@ -128,19 +137,20 @@ def __init__(
128
137
self ._attr_device_class = device_class
129
138
self ._attr_name = name
130
139
self ._icon = icon
131
- self ._attr_unit_of_measurement = unit_of_measurement
140
+ self ._attr_native_unit_of_measurement = unit_of_measurement
132
141
self ._attr_state_class = state_class
133
142
134
143
self ._attr_device_info = deviceInfo
135
144
self ._attr_mode = mode
136
145
137
146
if min_value is not None :
138
- self ._attr_min_value = min_value
147
+ self ._attr_native_min_value = min_value
139
148
if max_value is not None :
140
- self ._attr_max_value = max_value
149
+ self ._attr_native_max_value = max_value
141
150
if step is not None :
142
- self ._attr_step = step
151
+ self ._attr_native_step = step
143
152
self ._attr_entity_category = entity_category
153
+ self ._factor = factor
144
154
145
155
@property
146
156
def icon (self ): # -> str | None:
@@ -152,11 +162,25 @@ def update(self):
152
162
self ._luxtronik .update ()
153
163
154
164
@property
155
- def value (self ) -> float :
156
- """Return the state of the entity ."""
157
- return self ._luxtronik .get_value (self ._number_key )
165
+ def native_value (self ):
166
+ """Return the current value ."""
167
+ return self ._luxtronik .get_value (self ._number_key ) * self . _factor
158
168
159
- def set_value (self , value : float ) -> None :
169
+ # @property
170
+ # def value(self) -> float:
171
+ # """Return the state of the entity."""
172
+ # return self._luxtronik.get_value(self._number_key) * self._factor
173
+
174
+ async def async_set_native_value (self , value ):
160
175
"""Update the current value."""
176
+ if self ._factor != 1.0 :
177
+ value = int (value / self ._factor )
161
178
self ._luxtronik .write (self ._number_key .split ('.' )[1 ], value )
162
179
self .schedule_update_ha_state (force_refresh = True )
180
+
181
+ # def set_value(self, value: float) -> None:
182
+ # """Update the current value."""
183
+ # if self._factor != 1.0:
184
+ # value = int(value / self._factor)
185
+ # self._luxtronik.write(self._number_key.split('.')[1], value)
186
+ # self.schedule_update_ha_state(force_refresh=True)
0 commit comments