Testu ok
This commit is contained in:
@@ -971,15 +971,24 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
|
|
||||||
Need to be one of CURRENT_HVAC_*.
|
Need to be one of CURRENT_HVAC_*.
|
||||||
"""
|
"""
|
||||||
if self._is_over_climate and self._underlying_climate:
|
if self._is_over_climate:
|
||||||
return self._underlying_climate.hvac_action
|
# if one not IDLE or OFF -> return it
|
||||||
|
# else if one IDLE -> IDLE
|
||||||
|
# else OFF
|
||||||
|
one_idle = False
|
||||||
|
for under in self._underlyings:
|
||||||
|
if action := under.hvac_action not in [HVACAction.IDLE, HVACAction.OFF]:
|
||||||
|
return action
|
||||||
|
if under.hvac_action == HVACAction.IDLE:
|
||||||
|
one_idle = True
|
||||||
|
if one_idle:
|
||||||
|
return HVACAction.IDLE
|
||||||
|
return HVACAction.OFF
|
||||||
|
|
||||||
if self._hvac_mode == HVACMode.OFF:
|
if self._hvac_mode == HVACMode.OFF:
|
||||||
return HVACAction.OFF
|
return HVACAction.OFF
|
||||||
if not self._is_device_active:
|
if not self._is_device_active:
|
||||||
return HVACAction.IDLE
|
return HVACAction.IDLE
|
||||||
if self._ac_mode:
|
|
||||||
return HVACAction.COOLING
|
|
||||||
return HVACAction.HEATING
|
return HVACAction.HEATING
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -999,7 +1008,7 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
def _is_device_active(self):
|
def _is_device_active(self):
|
||||||
"""Returns true if one underlying is active"""
|
"""Returns true if one underlying is active"""
|
||||||
for under in self._underlyings:
|
for under in self._underlyings:
|
||||||
if under.is_device_active():
|
if under.is_device_active:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -1203,7 +1212,7 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
|
|
||||||
# Delegate to all underlying
|
# Delegate to all underlying
|
||||||
for under in self._underlyings:
|
for under in self._underlyings:
|
||||||
await under.set_have_mode(hvac_mode)
|
await under.set_hvac_mode(hvac_mode)
|
||||||
|
|
||||||
self._hvac_mode = hvac_mode
|
self._hvac_mode = hvac_mode
|
||||||
await self._async_control_heating(force=True)
|
await self._async_control_heating(force=True)
|
||||||
@@ -2441,16 +2450,25 @@ class VersatileThermostat(ClimateEntity, RestoreEntity):
|
|||||||
"window_auto_max_duration": self._window_auto_max_duration,
|
"window_auto_max_duration": self._window_auto_max_duration,
|
||||||
}
|
}
|
||||||
if self._is_over_climate:
|
if self._is_over_climate:
|
||||||
self._attr_extra_state_attributes[
|
self._attr_extra_state_attributes["underlying_climate"] = self._underlyings[
|
||||||
"underlying_climate"
|
0
|
||||||
] = self._climate_entity_id
|
].entity_id
|
||||||
self._attr_extra_state_attributes[
|
self._attr_extra_state_attributes[
|
||||||
"start_hvac_action_date"
|
"start_hvac_action_date"
|
||||||
] = self._underlying_climate_start_hvac_action_date
|
] = self._underlying_climate_start_hvac_action_date
|
||||||
else:
|
else:
|
||||||
self._attr_extra_state_attributes[
|
self._attr_extra_state_attributes[
|
||||||
"underlying_switch"
|
"underlying_switch_1"
|
||||||
] = self._heater_entity_id
|
] = self._underlyings[0].entity_id
|
||||||
|
self._attr_extra_state_attributes["underlying_switch_2"] = (
|
||||||
|
self._underlyings[1].entity_id if len(self._underlyings) > 1 else None
|
||||||
|
)
|
||||||
|
self._attr_extra_state_attributes["underlying_switch_3"] = (
|
||||||
|
self._underlyings[2].entity_id if len(self._underlyings) > 2 else None
|
||||||
|
)
|
||||||
|
self._attr_extra_state_attributes["underlying_switch_4"] = (
|
||||||
|
self._underlyings[3].entity_id if len(self._underlyings) > 3 else None
|
||||||
|
)
|
||||||
self._attr_extra_state_attributes[
|
self._attr_extra_state_attributes[
|
||||||
"on_percent"
|
"on_percent"
|
||||||
] = self._prop_algorithm.on_percent
|
] = self._prop_algorithm.on_percent
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ async def test_bug_66(
|
|||||||
|
|
||||||
assert mock_send_event.call_count == 1
|
assert mock_send_event.call_count == 1
|
||||||
assert mock_heater_on.call_count == 1
|
assert mock_heater_on.call_count == 1
|
||||||
assert mock_heater_off.call_count == 2
|
assert mock_heater_off.call_count == 1
|
||||||
assert mock_condition.call_count == 1
|
assert mock_condition.call_count == 1
|
||||||
|
|
||||||
assert entity.window_state == STATE_ON
|
assert entity.window_state == STATE_ON
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ async def test_window_management_time_enough(
|
|||||||
)
|
)
|
||||||
assert mock_heater_on.call_count == 1
|
assert mock_heater_on.call_count == 1
|
||||||
# One call in turn_oiff and one call in the control_heating
|
# One call in turn_oiff and one call in the control_heating
|
||||||
assert mock_heater_off.call_count == 2
|
assert mock_heater_off.call_count == 1
|
||||||
assert mock_condition.call_count == 1
|
assert mock_condition.call_count == 1
|
||||||
|
|
||||||
assert entity.window_state == STATE_ON
|
assert entity.window_state == STATE_ON
|
||||||
|
|||||||
@@ -144,7 +144,6 @@ class UnderlyingSwitch(UnderlyingEntity):
|
|||||||
class UnderlyingClimate(UnderlyingEntity):
|
class UnderlyingClimate(UnderlyingEntity):
|
||||||
"""Represent a underlying climate"""
|
"""Represent a underlying climate"""
|
||||||
|
|
||||||
_initialDelaySec: int
|
|
||||||
_underlying_climate: ClimateEntity
|
_underlying_climate: ClimateEntity
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -158,6 +157,7 @@ class UnderlyingClimate(UnderlyingEntity):
|
|||||||
entity_type=UnderlyingEntityType.CLIMATE,
|
entity_type=UnderlyingEntityType.CLIMATE,
|
||||||
entity_id=climate_entity_id,
|
entity_id=climate_entity_id,
|
||||||
)
|
)
|
||||||
|
self._underlying_climate = None
|
||||||
|
|
||||||
def find_underlying_climate(self) -> ClimateEntity:
|
def find_underlying_climate(self) -> ClimateEntity:
|
||||||
"""Find the underlying climate entity"""
|
"""Find the underlying climate entity"""
|
||||||
@@ -279,3 +279,10 @@ class UnderlyingClimate(UnderlyingEntity):
|
|||||||
SERVICE_SET_TEMPERATURE,
|
SERVICE_SET_TEMPERATURE,
|
||||||
data, # TODO needed ? context=self._context
|
data, # TODO needed ? context=self._context
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hvac_action(self) -> HVACAction:
|
||||||
|
"""Get the hvac action of the underlying"""
|
||||||
|
if not self.is_initialized:
|
||||||
|
return None
|
||||||
|
return self._underlying_climate.hvac_action
|
||||||
|
|||||||
Reference in New Issue
Block a user