Update central config Number temp entity
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
"extensions": [
|
"extensions": [
|
||||||
"ms-python.python",
|
"ms-python.python",
|
||||||
"ms-python.pylint",
|
"ms-python.pylint",
|
||||||
// already included into ms-python.python
|
// Doesn't work (crash). Default in python is to use Jedi see Settings / Python / Default Language
|
||||||
// "ms-python.vscode-pylance",
|
// "ms-python.vscode-pylance",
|
||||||
"ms-python.isort",
|
"ms-python.isort",
|
||||||
"ms-python.black-formatter",
|
"ms-python.black-formatter",
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ async def reload_all_vtherm(hass):
|
|||||||
api: VersatileThermostatAPI = VersatileThermostatAPI.get_vtherm_api(hass)
|
api: VersatileThermostatAPI = VersatileThermostatAPI.get_vtherm_api(hass)
|
||||||
if api:
|
if api:
|
||||||
await api.reload_central_boiler_entities_list()
|
await api.reload_central_boiler_entities_list()
|
||||||
|
await api.init_vtherm_links()
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
@@ -146,6 +147,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
|
|
||||||
await api.reload_central_boiler_entities_list()
|
await api.reload_central_boiler_entities_list()
|
||||||
|
await api.init_vtherm_links()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -160,6 +162,7 @@ async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
|||||||
api: VersatileThermostatAPI = VersatileThermostatAPI.get_vtherm_api(hass)
|
api: VersatileThermostatAPI = VersatileThermostatAPI.get_vtherm_api(hass)
|
||||||
if api is not None:
|
if api is not None:
|
||||||
await api.reload_central_boiler_entities_list()
|
await api.reload_central_boiler_entities_list()
|
||||||
|
await api.init_vtherm_links()
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
|||||||
@@ -2722,3 +2722,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity):
|
|||||||
|
|
||||||
if self._motion_on:
|
if self._motion_on:
|
||||||
self._attr_preset_modes.append(PRESET_ACTIVITY)
|
self._attr_preset_modes.append(PRESET_ACTIVITY)
|
||||||
|
|
||||||
|
# Re-applicate the last preset if any to take change into account
|
||||||
|
if self._attr_preset_mode:
|
||||||
|
await self._async_set_preset_mode_internal(self._attr_preset_mode, True)
|
||||||
|
|||||||
@@ -227,7 +227,9 @@ class ActivateBoilerThresholdNumber(
|
|||||||
return f"VersatileThermostat-{self.name}"
|
return f"VersatileThermostat-{self.name}"
|
||||||
|
|
||||||
|
|
||||||
class CentralConfigTemperatureNumber(NumberEntity, RestoreEntity):
|
class CentralConfigTemperatureNumber(
|
||||||
|
NumberEntity, RestoreEntity
|
||||||
|
): # pylint: disable=abstract-method
|
||||||
"""Representation of one temperature number"""
|
"""Representation of one temperature number"""
|
||||||
|
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
@@ -318,35 +320,19 @@ class CentralConfigTemperatureNumber(NumberEntity, RestoreEntity):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@overrides
|
@overrides
|
||||||
async def async_set_native_value(self, value: float) -> None:
|
def set_native_value(self, value: float) -> None:
|
||||||
"""Change the value"""
|
"""The value have change from the Number Entity in UI"""
|
||||||
|
float_value = float(value)
|
||||||
|
old_value = float(self._attr_native_value)
|
||||||
|
if float_value == old_value:
|
||||||
|
return
|
||||||
|
|
||||||
# TODO implements the native value change -> reload values for all central config
|
self._attr_value = self._attr_native_value = float_value
|
||||||
# based VTherm
|
|
||||||
# if self.my_climate is None:
|
|
||||||
# _LOGGER.warning(
|
|
||||||
# "%s - cannot change temperature because VTherm is not initialized", self
|
|
||||||
# )
|
|
||||||
# return
|
|
||||||
|
|
||||||
#
|
# We have to reload all VTherm for which uses the central configuration
|
||||||
# float_value = float(value)
|
api: VersatileThermostatAPI = VersatileThermostatAPI.get_vtherm_api(self.hass)
|
||||||
# old_value = float(self._attr_native_value)
|
# Update the VTherms
|
||||||
#
|
self.hass.create_task(api.init_vtherm_links())
|
||||||
# if float_value == old_value:
|
|
||||||
# return
|
|
||||||
#
|
|
||||||
# self._attr_value = self._attr_native_value = float_value
|
|
||||||
#
|
|
||||||
# self.async_write_ha_state()
|
|
||||||
#
|
|
||||||
# # Update the VTherm
|
|
||||||
# self.hass.create_task(
|
|
||||||
# self.my_climate.service_set_preset_temperature(
|
|
||||||
# self._preset_name.replace("_temp", ""), self._attr_native_value, None
|
|
||||||
# )
|
|
||||||
|
|
||||||
# )
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"VersatileThermostat-{self.name}"
|
return f"VersatileThermostat-{self.name}"
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ class VersatileThermostatAPI(dict):
|
|||||||
async def init_vtherm_links(self):
|
async def init_vtherm_links(self):
|
||||||
"""INitialize all VTherms entities links
|
"""INitialize all VTherms entities links
|
||||||
This method is called when HA is fully started (and all entities should be initialized)
|
This method is called when HA is fully started (and all entities should be initialized)
|
||||||
|
Or when we need to reload all VTherm links (with Number temp entities, central boiler, ...)
|
||||||
"""
|
"""
|
||||||
await self.reload_central_boiler_binary_listener()
|
await self.reload_central_boiler_binary_listener()
|
||||||
await self.reload_central_boiler_entities_list()
|
await self.reload_central_boiler_entities_list()
|
||||||
@@ -161,7 +162,8 @@ class VersatileThermostatAPI(dict):
|
|||||||
)
|
)
|
||||||
if component:
|
if component:
|
||||||
for entity in component.entities:
|
for entity in component.entities:
|
||||||
await entity.init_presets(self.find_central_configuration())
|
if hasattr(entity, "init_presets"):
|
||||||
|
await entity.init_presets(self.find_central_configuration())
|
||||||
|
|
||||||
async def reload_central_boiler_binary_listener(self):
|
async def reload_central_boiler_binary_listener(self):
|
||||||
"""Reloads the BinarySensor entity which listen to the number of
|
"""Reloads the BinarySensor entity which listen to the number of
|
||||||
|
|||||||
Reference in New Issue
Block a user