HA 2024.9.3 and issue 508 (#510)
* HA 2024.9.3 and issue 508 * Fix strings trailing spaces --------- Co-authored-by: Jean-Marc Collin <jean-marc.collin-extern@renault.com>
This commit is contained in:
@@ -14,6 +14,6 @@
|
|||||||
"quality_scale": "silver",
|
"quality_scale": "silver",
|
||||||
"requirements": [],
|
"requirements": [],
|
||||||
"ssdp": [],
|
"ssdp": [],
|
||||||
"version": "6.2.9",
|
"version": "6.3.0",
|
||||||
"zeroconf": []
|
"zeroconf": []
|
||||||
}
|
}
|
||||||
@@ -612,11 +612,21 @@ class UnderlyingClimate(UnderlyingEntity):
|
|||||||
if not self.is_initialized:
|
if not self.is_initialized:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Issue 508 we have to take care of service set_temperature or set_range
|
||||||
|
target_temp = self.cap_sent_value(temperature)
|
||||||
|
if (
|
||||||
|
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||||
|
in self._underlying_climate.supported_features
|
||||||
|
):
|
||||||
data = {
|
data = {
|
||||||
ATTR_ENTITY_ID: self._entity_id,
|
ATTR_ENTITY_ID: self._entity_id,
|
||||||
"temperature": self.cap_sent_value(temperature),
|
"target_temp_high": target_temp,
|
||||||
"target_temp_high": max_temp,
|
"target_temp_low": target_temp,
|
||||||
"target_temp_low": min_temp,
|
}
|
||||||
|
else:
|
||||||
|
data = {
|
||||||
|
ATTR_ENTITY_ID: self._entity_id,
|
||||||
|
"temperature": target_temp,
|
||||||
}
|
}
|
||||||
|
|
||||||
await self._hass.services.async_call(
|
await self._hass.services.async_call(
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
"content_in_root": false,
|
"content_in_root": false,
|
||||||
"render_readme": true,
|
"render_readme": true,
|
||||||
"hide_default_branch": false,
|
"hide_default_branch": false,
|
||||||
"homeassistant": "2024.6.1"
|
"homeassistant": "2024.9.3"
|
||||||
}
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
homeassistant==2024.6.1
|
homeassistant==2024.9.3
|
||||||
|
|||||||
@@ -435,6 +435,86 @@ class MagicMockClimate(MagicMock):
|
|||||||
return 19
|
return 19
|
||||||
|
|
||||||
|
|
||||||
|
class MagicMockClimateWithTemperatureRange(MagicMock):
|
||||||
|
"""A Magic Mock class for a underlying climate entity"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def temperature_unit(self): # pylint: disable=missing-function-docstring
|
||||||
|
return UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hvac_mode(self): # pylint: disable=missing-function-docstring
|
||||||
|
return HVACMode.HEAT
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hvac_action(self): # pylint: disable=missing-function-docstring
|
||||||
|
return HVACAction.IDLE
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_temperature(self): # pylint: disable=missing-function-docstring
|
||||||
|
return 15
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_temperature(self): # pylint: disable=missing-function-docstring
|
||||||
|
return 14
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_temperature_step( # pylint: disable=missing-function-docstring
|
||||||
|
self,
|
||||||
|
) -> float | None:
|
||||||
|
return 0.5
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_temperature_high( # pylint: disable=missing-function-docstring
|
||||||
|
self,
|
||||||
|
) -> float | None:
|
||||||
|
return 35
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_temperature_low( # pylint: disable=missing-function-docstring
|
||||||
|
self,
|
||||||
|
) -> float | None:
|
||||||
|
return 7
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hvac_modes( # pylint: disable=missing-function-docstring
|
||||||
|
self,
|
||||||
|
) -> list[str] | None:
|
||||||
|
return [HVACMode.HEAT, HVACMode.OFF, HVACMode.COOL]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fan_modes( # pylint: disable=missing-function-docstring
|
||||||
|
self,
|
||||||
|
) -> list[str] | None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def swing_modes( # pylint: disable=missing-function-docstring
|
||||||
|
self,
|
||||||
|
) -> list[str] | None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fan_mode(self) -> str | None: # pylint: disable=missing-function-docstring
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def swing_mode(self) -> str | None: # pylint: disable=missing-function-docstring
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self): # pylint: disable=missing-function-docstring
|
||||||
|
return ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||||
|
|
||||||
|
@property
|
||||||
|
def min_temp(self): # pylint: disable=missing-function-docstring
|
||||||
|
return 10
|
||||||
|
|
||||||
|
@property
|
||||||
|
def max_temp(self): # pylint: disable=missing-function-docstring
|
||||||
|
return 31
|
||||||
|
|
||||||
|
|
||||||
class MockSwitch(SwitchEntity):
|
class MockSwitch(SwitchEntity):
|
||||||
"""A fake switch to be used instead real switch"""
|
"""A fake switch to be used instead real switch"""
|
||||||
|
|
||||||
|
|||||||
@@ -657,8 +657,8 @@ async def test_bug_272(
|
|||||||
{
|
{
|
||||||
"entity_id": "climate.mock_climate",
|
"entity_id": "climate.mock_climate",
|
||||||
"temperature": 17.5,
|
"temperature": 17.5,
|
||||||
"target_temp_high": 30,
|
# "target_temp_high": 30,
|
||||||
"target_temp_low": 15,
|
# "target_temp_low": 15,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@@ -687,8 +687,8 @@ async def test_bug_272(
|
|||||||
{
|
{
|
||||||
"entity_id": "climate.mock_climate",
|
"entity_id": "climate.mock_climate",
|
||||||
"temperature": 15, # the minimum acceptable
|
"temperature": 15, # the minimum acceptable
|
||||||
"target_temp_high": 30,
|
# "target_temp_high": 30,
|
||||||
"target_temp_low": 15,
|
# "target_temp_low": 15,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@@ -714,8 +714,8 @@ async def test_bug_272(
|
|||||||
{
|
{
|
||||||
"entity_id": "climate.mock_climate",
|
"entity_id": "climate.mock_climate",
|
||||||
"temperature": 19, # the maximum acceptable
|
"temperature": 19, # the maximum acceptable
|
||||||
"target_temp_high": 30,
|
# "target_temp_high": 30,
|
||||||
"target_temp_low": 15,
|
# "target_temp_low": 15,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@@ -924,3 +924,92 @@ async def test_bug_339(
|
|||||||
assert api.nb_active_device_for_boiler == 1
|
assert api.nb_active_device_for_boiler == 1
|
||||||
|
|
||||||
entity.remove_thermostat()
|
entity.remove_thermostat()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("expected_lingering_timers", [True])
|
||||||
|
async def test_bug_508(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
skip_hass_states_is_state,
|
||||||
|
skip_turn_on_off_heater,
|
||||||
|
skip_send_event,
|
||||||
|
):
|
||||||
|
"""Test that it not possible to set the target temperature under the min_temp setting"""
|
||||||
|
|
||||||
|
tz = get_tz(hass) # pylint: disable=invalid-name
|
||||||
|
now: datetime = datetime.now(tz=tz)
|
||||||
|
|
||||||
|
entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN,
|
||||||
|
title="TheOverClimateMockName",
|
||||||
|
unique_id="uniqueId",
|
||||||
|
# default value are min 15°, max 31°, step 0.1
|
||||||
|
data=PARTIAL_CLIMATE_CONFIG, # 5 minutes security delay
|
||||||
|
)
|
||||||
|
|
||||||
|
# Min_temp is 10 and max_temp is 31 and features contains TARGET_TEMPERATURE_RANGE
|
||||||
|
fake_underlying_climate = MagicMockClimateWithTemperatureRange()
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
|
||||||
|
), patch(
|
||||||
|
"custom_components.versatile_thermostat.underlyings.UnderlyingClimate.find_underlying_climate",
|
||||||
|
return_value=fake_underlying_climate,
|
||||||
|
), patch(
|
||||||
|
"homeassistant.core.ServiceRegistry.async_call"
|
||||||
|
) as mock_service_call:
|
||||||
|
entity = await create_thermostat(hass, entry, "climate.theoverclimatemockname")
|
||||||
|
|
||||||
|
assert entity
|
||||||
|
|
||||||
|
assert entity.name == "TheOverClimateMockName"
|
||||||
|
assert entity.is_over_climate is True
|
||||||
|
assert entity.hvac_mode is HVACMode.OFF
|
||||||
|
# The VTherm value and not the underlying value
|
||||||
|
assert entity.target_temperature_step == 0.1
|
||||||
|
assert entity.target_temperature == entity.min_temp
|
||||||
|
assert entity.is_regulated is True
|
||||||
|
|
||||||
|
assert mock_service_call.call_count == 0
|
||||||
|
|
||||||
|
# Set the hvac_mode to HEAT
|
||||||
|
await entity.async_set_hvac_mode(HVACMode.HEAT)
|
||||||
|
|
||||||
|
# Not In the accepted interval -> should be converted into 10 (the min) and send with target_temp_high and target_temp_low
|
||||||
|
await entity.async_set_temperature(temperature=8.5)
|
||||||
|
|
||||||
|
# MagicMock climate is already HEAT by default. So there is no SET_HAVC_MODE call
|
||||||
|
assert mock_service_call.call_count == 1
|
||||||
|
mock_service_call.assert_has_calls(
|
||||||
|
[
|
||||||
|
call.async_call(
|
||||||
|
"climate",
|
||||||
|
SERVICE_SET_TEMPERATURE,
|
||||||
|
{
|
||||||
|
"entity_id": "climate.mock_climate",
|
||||||
|
# "temperature": 17.5,
|
||||||
|
"target_temp_high": 10,
|
||||||
|
"target_temp_low": 10,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
with patch("homeassistant.core.ServiceRegistry.async_call") as mock_service_call:
|
||||||
|
# Not In the accepted interval -> should be converted into 10 (the min) and send with target_temp_high and target_temp_low
|
||||||
|
await entity.async_set_temperature(temperature=32)
|
||||||
|
|
||||||
|
# MagicMock climate is already HEAT by default. So there is no SET_HAVC_MODE call
|
||||||
|
assert mock_service_call.call_count == 1
|
||||||
|
mock_service_call.assert_has_calls(
|
||||||
|
[
|
||||||
|
call.async_call(
|
||||||
|
"climate",
|
||||||
|
SERVICE_SET_TEMPERATURE,
|
||||||
|
{
|
||||||
|
"entity_id": "climate.mock_climate",
|
||||||
|
"target_temp_high": 31,
|
||||||
|
"target_temp_low": 31,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user