Skip to content

Commit 5c865a2

Browse files
committed
* Add two new params
* Fix code for new ha version
1 parent b10c5f6 commit 5c865a2

File tree

6 files changed

+70
-20
lines changed

6 files changed

+70
-20
lines changed

custom_components/luxtronik/const.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,12 @@ class LuxMode(Enum):
194194
LUX_SENSOR_STATUS1: Final = "calculations.ID_WEB_HauptMenuStatus_Zeile1"
195195
LUX_SENSOR_STATUS3: Final = "calculations.ID_WEB_HauptMenuStatus_Zeile3"
196196

197+
LUX_SENSOR_REMOTE_MAINTENANCE: Final = "parameters.ID_Einst_Fernwartung_akt"
198+
197199
LUX_SENSOR_HEATING_TEMPERATURE_CORRECTION: Final = "parameters.ID_Einst_WK_akt"
198-
LUX_SENSOR_HEATING_THRESHOLD: Final = "parameters.ID_Einst_Heizgrenze_Temp"
200+
LUX_SENSOR_HEATING_THRESHOLD: Final = "parameters.ID_Einst_Heizgrenze"
201+
LUX_SENSOR_HEATING_THRESHOLD_TEMPERATURE: Final = "parameters.ID_Einst_Heizgrenze_Temp"
202+
LUX_SENSOR_HEATING_MIN_FLOW_OUT_TEMPERATURE: Final = "parameters.ID_Einst_Minimale_Ruecklaufsolltemperatur"
199203
LUX_SENSOR_MODE_HEATING: Final = "parameters.ID_Ba_Hz_akt"
200204

201205
LUX_SENSOR_COOLING_THRESHOLD: Final = "parameters.ID_Einst_KuehlFreig_akt"

custom_components/luxtronik/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"domain": "luxtronik2",
33
"name": "Luxtronik",
4-
"version": "2022.05.04",
4+
"version": "2022.08.01",
55
"config_flow": true,
66
"iot_class": "local_polling",
77
"documentation": "https://www.home-assistant.io/integrations/luxtronik",

custom_components/luxtronik/number.py

+38-14
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
from homeassistant.components.sensor import (ENTITY_ID_FORMAT,
88
STATE_CLASS_MEASUREMENT)
99
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)
1112
from homeassistant.core import HomeAssistant
12-
from homeassistant.helpers.entity import DeviceInfo
13+
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
1314
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1415
from homeassistant.helpers.restore_state import RestoreEntity
1516
from homeassistant.helpers.typing import ConfigType
@@ -18,8 +19,9 @@
1819
from .const import (CONF_LANGUAGE_SENSOR_NAMES, DOMAIN, LOGGER,
1920
LUX_SENSOR_COOLING_THRESHOLD,
2021
LUX_SENSOR_DOMESTIC_WATER_TARGET_TEMPERATURE,
22+
LUX_SENSOR_HEATING_MIN_FLOW_OUT_TEMPERATURE,
2123
LUX_SENSOR_HEATING_TEMPERATURE_CORRECTION,
22-
LUX_SENSOR_HEATING_THRESHOLD)
24+
LUX_SENSOR_HEATING_THRESHOLD_TEMPERATURE)
2325
from .helpers.helper import get_sensor_text
2426

2527
# endregion Imports
@@ -57,17 +59,23 @@ async def async_setup_entry(
5759
if deviceInfoHeating is not None:
5860
text_heating_threshold = get_sensor_text(lang, 'heating_threshold')
5961
text_correction = get_sensor_text(lang, 'correction')
62+
text_min_flow_out_temperature = get_sensor_text(lang, 'min_flow_out_temperature')
6063
entities += [
6164
LuxtronikNumber(
6265
hass, luxtronik, deviceInfoHeating,
6366
number_key=LUX_SENSOR_HEATING_TEMPERATURE_CORRECTION,
6467
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),
6669
LuxtronikNumber(
6770
hass, luxtronik, deviceInfoHeating,
68-
number_key=LUX_SENSOR_HEATING_THRESHOLD,
71+
number_key=LUX_SENSOR_HEATING_THRESHOLD_TEMPERATURE,
6972
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)
7179
]
7280

7381
deviceInfoDomesticWater = hass.data[f"{DOMAIN}_DeviceInfo_Domestic_Water"]
@@ -117,6 +125,7 @@ def __init__(
117125
step: float = None, # | None = None,
118126
mode: Literal["auto", "box", "slider"] = MODE_AUTO,
119127
entity_category: ENTITY_CATEGORIES = None,
128+
factor: float = 1.0,
120129
) -> None:
121130
"""Initialize the number."""
122131
self._hass = hass
@@ -128,19 +137,20 @@ def __init__(
128137
self._attr_device_class = device_class
129138
self._attr_name = name
130139
self._icon = icon
131-
self._attr_unit_of_measurement = unit_of_measurement
140+
self._attr_native_unit_of_measurement = unit_of_measurement
132141
self._attr_state_class = state_class
133142

134143
self._attr_device_info = deviceInfo
135144
self._attr_mode = mode
136145

137146
if min_value is not None:
138-
self._attr_min_value = min_value
147+
self._attr_native_min_value = min_value
139148
if max_value is not None:
140-
self._attr_max_value = max_value
149+
self._attr_native_max_value = max_value
141150
if step is not None:
142-
self._attr_step = step
151+
self._attr_native_step = step
143152
self._attr_entity_category = entity_category
153+
self._factor = factor
144154

145155
@property
146156
def icon(self): # -> str | None:
@@ -152,11 +162,25 @@ def update(self):
152162
self._luxtronik.update()
153163

154164
@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
158168

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):
160175
"""Update the current value."""
176+
if self._factor != 1.0:
177+
value = int(value / self._factor)
161178
self._luxtronik.write(self._number_key.split('.')[1], value)
162179
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)

custom_components/luxtronik/switch.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
from homeassistant.components.switch import SwitchEntity
77
from homeassistant.config_entries import ConfigEntry
88
from homeassistant.core import HomeAssistant
9+
from homeassistant.helpers.entity import EntityCategory
910
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1011
from homeassistant.helpers.restore_state import RestoreEntity
1112

1213
from . import LuxtronikDevice
1314
from .binary_sensor import LuxtronikBinarySensor
1415
from .const import (CONF_LANGUAGE_SENSOR_NAMES, DOMAIN, LOGGER,
1516
LUX_SENSOR_MODE_DOMESTIC_WATER, LUX_SENSOR_MODE_HEATING,
16-
LuxMode)
17+
LuxMode, LUX_SENSOR_HEATING_THRESHOLD, LUX_SENSOR_REMOTE_MAINTENANCE)
1718
from .helpers.helper import get_sensor_text
1819

1920
# endregion Imports
@@ -41,16 +42,33 @@ async def async_setup_entry(
4142
lang = config_entry.options.get(CONF_LANGUAGE_SENSOR_NAMES)
4243
entities = []
4344

45+
device_info = hass.data[f"{DOMAIN}_DeviceInfo"]
46+
text_remote_maintenance = get_sensor_text(lang, 'remote_maintenance')
47+
entities += [
48+
LuxtronikSwitch(
49+
hass=hass, luxtronik=luxtronik, deviceInfo=device_info,
50+
sensor_key=LUX_SENSOR_REMOTE_MAINTENANCE, unique_id='remote_maintenance',
51+
name=f"{text_remote_maintenance}", icon='mdi:remote-desktop',
52+
device_class=DEVICE_CLASS_HEAT, entity_category=EntityCategory.CONFIG)
53+
]
54+
55+
4456
deviceInfoHeating = hass.data[f"{DOMAIN}_DeviceInfo_Heating"]
4557
if deviceInfoHeating is not None:
4658
text_heating_mode = get_sensor_text(lang, 'heating_mode_auto')
59+
text_heating_threshold = get_sensor_text(lang, 'heating_threshold')
4760
entities += [
4861
LuxtronikSwitch(
4962
on_state=LuxMode.automatic.value, off_state=LuxMode.off.value,
5063
hass=hass, luxtronik=luxtronik, deviceInfo=deviceInfoHeating,
5164
sensor_key=LUX_SENSOR_MODE_HEATING, unique_id='heating',
5265
name=text_heating_mode, icon='mdi:radiator',
53-
device_class=DEVICE_CLASS_HEAT)
66+
device_class=DEVICE_CLASS_HEAT),
67+
LuxtronikSwitch(
68+
hass=hass, luxtronik=luxtronik, deviceInfo=deviceInfoHeating,
69+
sensor_key=LUX_SENSOR_HEATING_THRESHOLD, unique_id='heating_threshold',
70+
name=f"{text_heating_threshold}", icon='mdi:download-outline',
71+
device_class=DEVICE_CLASS_HEAT, entity_category=EntityCategory.CONFIG)
5472
]
5573

5674
deviceInfoDomesticWater = hass.data[f"{DOMAIN}_DeviceInfo_Domestic_Water"]

custom_components/luxtronik/translations/texts.de.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@
2929
"heat_amount_counter": "W\u00e4rmemenge Z\u00e4hler",
3030
"heat_amount_heating": "W\u00e4rmemenge Heizung",
3131
"heat_amount_domestic_water": "W\u00e4rmemenge Brauchwasser",
32-
"approval_cooling": "K\u00fchlung Freigabe"
32+
"approval_cooling": "K\u00fchlung Freigabe",
33+
"remote_maintenance": "Fernwartung",
34+
"min_flow_out_temperature": "Min.Soll R\u00fccklauf"
3335
}

custom_components/luxtronik/translations/texts.en.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@
2929
"heat_amount_counter": "Heat amount counter",
3030
"heat_amount_heating": "Heat amount heating",
3131
"heat_amount_domestic_water": "Heat amount domestic water",
32-
"approval_cooling": "Approval cooling"
32+
"approval_cooling": "Approval cooling",
33+
"remote_maintenance": "Remote maintenance",
34+
"min_flow_out_temperature": "Min.Target Flow Out"
3335
}

0 commit comments

Comments
 (0)