88import pytest
99
1010from freezegun .api import FrozenDateTimeFactory
11- from homeassistant .components .climate .const import HVACMode
11+ from homeassistant .components .climate import (
12+ DOMAIN as CLIMATE_DOMAIN ,
13+ HVACMode ,
14+ SERVICE_SET_HVAC_MODE ,
15+ SERVICE_SET_PRESET_MODE ,
16+ SERVICE_SET_TEMPERATURE ,
17+ )
1218from homeassistant .core import HomeAssistant
1319from homeassistant .exceptions import HomeAssistantError , ServiceValidationError
1420
@@ -174,8 +180,8 @@ async def test_adam_climate_adjust_negative_testing(
174180
175181 with pytest .raises (HomeAssistantError ):
176182 await hass .services .async_call (
177- "climate" ,
178- "set_temperature" ,
183+ CLIMATE_DOMAIN ,
184+ SERVICE_SET_TEMPERATURE ,
179185 {"entity_id" : "climate.zone_lisa_wk" , "temperature" : 25 },
180186 blocking = True ,
181187 )
@@ -186,8 +192,8 @@ async def test_adam_climate_entity_climate_changes(
186192) -> None :
187193 """Test handling of user requests in adam climate device environment."""
188194 await hass .services .async_call (
189- "climate" ,
190- "set_temperature" ,
195+ CLIMATE_DOMAIN ,
196+ SERVICE_SET_TEMPERATURE ,
191197 {"entity_id" : "climate.zone_lisa_wk" , "temperature" : 25 },
192198 blocking = True ,
193199 )
@@ -197,8 +203,8 @@ async def test_adam_climate_entity_climate_changes(
197203 )
198204
199205 await hass .services .async_call (
200- "climate" ,
201- "set_temperature" ,
206+ CLIMATE_DOMAIN ,
207+ SERVICE_SET_TEMPERATURE ,
202208 {
203209 "entity_id" : "climate.zone_lisa_wk" ,
204210 "hvac_mode" : "heat" ,
@@ -213,15 +219,15 @@ async def test_adam_climate_entity_climate_changes(
213219
214220 with pytest .raises (ServiceValidationError ):
215221 await hass .services .async_call (
216- "climate" ,
217- "set_temperature" ,
222+ CLIMATE_DOMAIN ,
223+ SERVICE_SET_TEMPERATURE ,
218224 {"entity_id" : "climate.zone_lisa_wk" , "temperature" : 150 },
219225 blocking = True ,
220226 )
221227
222228 await hass .services .async_call (
223- "climate" ,
224- "set_preset_mode" ,
229+ CLIMATE_DOMAIN ,
230+ SERVICE_SET_PRESET_MODE ,
225231 {"entity_id" : "climate.zone_lisa_wk" , "preset_mode" : "away" },
226232 blocking = True ,
227233 )
@@ -231,8 +237,8 @@ async def test_adam_climate_entity_climate_changes(
231237 )
232238
233239 await hass .services .async_call (
234- "climate" ,
235- "set_hvac_mode" ,
240+ CLIMATE_DOMAIN ,
241+ SERVICE_SET_HVAC_MODE ,
236242 {"entity_id" : "climate.zone_lisa_wk" , "hvac_mode" : "heat" },
237243 blocking = True ,
238244 )
@@ -243,8 +249,8 @@ async def test_adam_climate_entity_climate_changes(
243249
244250 with pytest .raises (HomeAssistantError ):
245251 await hass .services .async_call (
246- "climate" ,
247- "set_hvac_mode" ,
252+ CLIMATE_DOMAIN ,
253+ SERVICE_SET_HVAC_MODE ,
248254 {
249255 "entity_id" : "climate.zone_thermostat_jessie" ,
250256 "hvac_mode" : "dry" ,
@@ -263,8 +269,8 @@ async def test_adam_climate_off_mode_change(
263269 assert state
264270 assert state .state == HVACMode .OFF
265271 await hass .services .async_call (
266- "climate" ,
267- "set_hvac_mode" ,
272+ CLIMATE_DOMAIN ,
273+ SERVICE_SET_HVAC_MODE ,
268274 {
269275 "entity_id" : "climate.slaapkamer" ,
270276 "hvac_mode" : "heat" ,
@@ -279,8 +285,8 @@ async def test_adam_climate_off_mode_change(
279285 assert state
280286 assert state .state == HVACMode .HEAT
281287 await hass .services .async_call (
282- "climate" ,
283- "set_hvac_mode" ,
288+ CLIMATE_DOMAIN ,
289+ SERVICE_SET_HVAC_MODE ,
284290 {
285291 "entity_id" : "climate.kinderkamer" ,
286292 "hvac_mode" : "off" ,
@@ -295,8 +301,8 @@ async def test_adam_climate_off_mode_change(
295301 assert state
296302 assert state .state == HVACMode .HEAT
297303 await hass .services .async_call (
298- "climate" ,
299- "set_hvac_mode" ,
304+ CLIMATE_DOMAIN ,
305+ SERVICE_SET_HVAC_MODE ,
300306 {
301307 "entity_id" : "climate.logeerkamer" ,
302308 "hvac_mode" : "heat" ,
@@ -378,8 +384,8 @@ async def test_anna_climate_entity_climate_changes(
378384) -> None :
379385 """Test handling of user requests in anna climate device environment."""
380386 await hass .services .async_call (
381- "climate" ,
382- "set_temperature" ,
387+ CLIMATE_DOMAIN ,
388+ SERVICE_SET_TEMPERATURE ,
383389 {"entity_id" : "climate.anna" , "target_temp_high" : 30 , "target_temp_low" : 20 },
384390 blocking = True ,
385391 )
@@ -390,8 +396,8 @@ async def test_anna_climate_entity_climate_changes(
390396 )
391397
392398 await hass .services .async_call (
393- "climate" ,
394- "set_preset_mode" ,
399+ CLIMATE_DOMAIN ,
400+ SERVICE_SET_PRESET_MODE ,
395401 {"entity_id" : "climate.anna" , "preset_mode" : "away" },
396402 blocking = True ,
397403 )
@@ -401,17 +407,17 @@ async def test_anna_climate_entity_climate_changes(
401407 )
402408
403409 await hass .services .async_call (
404- "climate" ,
405- "set_hvac_mode" ,
410+ CLIMATE_DOMAIN ,
411+ SERVICE_SET_HVAC_MODE ,
406412 {"entity_id" : "climate.anna" , "hvac_mode" : "auto" },
407413 blocking = True ,
408414 )
409415 assert mock_smile_anna .set_schedule_state .call_count == 0
410416 # hvac_mode is already auto so not called.
411417
412418 await hass .services .async_call (
413- "climate" ,
414- "set_hvac_mode" ,
419+ CLIMATE_DOMAIN ,
420+ SERVICE_SET_HVAC_MODE ,
415421 {"entity_id" : "climate.anna" , "hvac_mode" : "heat_cool" },
416422 blocking = True ,
417423 )
0 commit comments