4
4
import copy
5
5
6
6
import pytest
7
- from homeassistant .components .climate import ClimateEntityFeature , HVACAction , HVACMode
7
+ from homeassistant .components .climate import ClimateEntityFeature , HVACMode
8
8
from homeassistant .const import PRECISION_HALVES , PRECISION_TENTHS
9
9
from homeassistant .core import HomeAssistant , State
10
10
from homeassistant .exceptions import NoEntitySpecifiedError
16
16
from custom_components .hvac_group import DOMAIN
17
17
from custom_components .hvac_group .climate import (
18
18
HvacGroupClimateEntity ,
19
+ HvacGroupActuator ,
20
+ HvacGroupCooler ,
21
+ HvacGroupHeater ,
19
22
async_setup_entry ,
20
23
)
21
24
@@ -135,7 +138,7 @@ async def hvac_group(hass: HomeAssistant) -> HvacGroupClimateEntity:
135
138
136
139
mock_async_add_entities .assert_called ()
137
140
138
- hvac_entity : HvacGroupClimateEntity = mock_async_add_entities .call_args [ 0 ] [0 ][0 ]
141
+ hvac_entity : HvacGroupClimateEntity = mock_async_add_entities .call_args . args [0 ][0 ]
139
142
140
143
return hvac_entity
141
144
@@ -144,7 +147,7 @@ async def hvac_group(hass: HomeAssistant) -> HvacGroupClimateEntity:
144
147
async def test_entry (hvac_group : HvacGroupClimateEntity , hass : HomeAssistant ) -> None :
145
148
"""Test component creation."""
146
149
147
- assert hvac_group .temperature_sensor_entity_id == "climate.heater"
150
+ assert hvac_group ._temperature_sensor_entity_id == "climate.heater"
148
151
149
152
assert hvac_group .precision == PRECISION_TENTHS
150
153
assert hvac_group .target_temperature_step == PRECISION_HALVES
@@ -154,47 +157,31 @@ async def test_entry(hvac_group: HvacGroupClimateEntity, hass: HomeAssistant) ->
154
157
assert HVACMode .HEAT not in hvac_group .hvac_modes
155
158
assert HVACMode .COOL not in hvac_group .hvac_modes
156
159
157
- assert hvac_group .hvac_mode == HVACMode .OFF
158
- assert hvac_group .hvac_action == HVACAction .OFF
159
160
160
-
161
- @pytest .mark .asyncio
162
- async def test_sensor_changes (
163
- hvac_group : HvacGroupClimateEntity , hass : HomeAssistant
164
- ) -> None :
165
- """Test behavior after temperature sensor change."""
166
-
167
- with patch ("homeassistant.core.ServiceRegistry.async_call" ) as hass_service_call :
168
- try :
169
- await hvac_group ._async_sensor_changed (
170
- _generate_event (
171
- hass , "climate.heater" , attributes = {"current_temperature" : 21.3 }
172
- )
173
- )
174
- except NoEntitySpecifiedError :
175
- assert hvac_group .current_temperature == 21.3
176
- assert hass_service_call .called
177
- else :
178
- pass
179
-
180
-
181
- @pytest .mark .asyncio
182
- async def test_member_changes (
183
- initialize_actuators , hvac_group : HvacGroupClimateEntity , hass : HomeAssistant
161
+ @pytest .mark .parametrize (
162
+ ("temperature" , "temp_low" , "temp_high" , "actuator_class" , "expected" ),
163
+ [
164
+ (21 , None , None , HvacGroupCooler , 21 ),
165
+ (None , 19 , 26 , HvacGroupCooler , 26 ),
166
+ (21 , None , None , HvacGroupHeater , 21 ),
167
+ (None , 19 , 26 , HvacGroupHeater , 19 ),
168
+ (21 , None , None , HvacGroupActuator , 21 ),
169
+ (None , 12 , 16 , HvacGroupActuator , None ),
170
+ ],
171
+ )
172
+ def test_guess_temperature (
173
+ hass : HomeAssistant , temperature , temp_high , temp_low , actuator_class , expected
184
174
) -> None :
185
- """Test behavior after member min/max temperatures change ."""
186
-
187
- try :
188
- await hvac_group . _async_member_changed (
189
- _generate_event (
190
- hass , "climate.hvac" , attributes = { "min_temp" : 15 , "max_temp" : 32 }
191
- )
175
+ """Test temperature guessing ."""
176
+ actuator = actuator_class ( hass , "test.id" )
177
+ assert (
178
+ actuator . _guess_target_temperature (
179
+ temperature = temperature ,
180
+ target_temp_low = temp_low ,
181
+ target_temp_high = temp_high ,
192
182
)
193
- except NoEntitySpecifiedError :
194
- assert hvac_group .min_temp == 16
195
- assert hvac_group .max_temp == 28
196
- else :
197
- pass
183
+ == expected
184
+ )
198
185
199
186
200
187
@pytest .mark .asyncio
0 commit comments