@@ -202,7 +202,7 @@ async def test_set_operation_bad_attr_and_state(
202202 state = hass .states .get (ENTITY_CLIMATE )
203203 assert state .state == "off"
204204 with pytest .raises (vol .Invalid ) as excinfo :
205- await common .async_set_hvac_mode (hass , None , ENTITY_CLIMATE )
205+ await common .async_set_hvac_mode (hass , None , ENTITY_CLIMATE ) # type:ignore[arg-type]
206206 assert (
207207 "expected HVACMode or one of 'off', 'heat', 'cool', 'heat_cool', 'auto', 'dry',"
208208 " 'fan_only' for dictionary value @ data['hvac_mode']" in str (excinfo .value )
@@ -220,10 +220,9 @@ async def test_set_operation(
220220
221221 state = hass .states .get (ENTITY_CLIMATE )
222222 assert state .state == "off"
223- await common .async_set_hvac_mode (hass , "cool" , ENTITY_CLIMATE )
223+ await common .async_set_hvac_mode (hass , HVACMode . COOL , ENTITY_CLIMATE )
224224 state = hass .states .get (ENTITY_CLIMATE )
225225 assert state .state == "cool"
226- assert state .state == "cool"
227226 mqtt_mock .async_publish .assert_called_once_with ("mode-topic" , "cool" , 0 , False )
228227
229228
@@ -245,7 +244,7 @@ async def test_set_operation_pessimistic(
245244 state = hass .states .get (ENTITY_CLIMATE )
246245 assert state .state == STATE_UNKNOWN
247246
248- await common .async_set_hvac_mode (hass , "cool" , ENTITY_CLIMATE )
247+ await common .async_set_hvac_mode (hass , HVACMode . COOL , ENTITY_CLIMATE )
249248 state = hass .states .get (ENTITY_CLIMATE )
250249 assert state .state == STATE_UNKNOWN
251250
@@ -287,7 +286,7 @@ async def test_set_operation_optimistic(
287286 state = hass .states .get (ENTITY_CLIMATE )
288287 assert state .state == "off"
289288
290- await common .async_set_hvac_mode (hass , "cool" , ENTITY_CLIMATE )
289+ await common .async_set_hvac_mode (hass , HVACMode . COOL , ENTITY_CLIMATE )
291290 state = hass .states .get (ENTITY_CLIMATE )
292291 assert state .state == "cool"
293292
@@ -316,13 +315,13 @@ async def test_set_operation_with_power_command(
316315
317316 state = hass .states .get (ENTITY_CLIMATE )
318317 assert state .state == "off"
319- await common .async_set_hvac_mode (hass , "cool" , ENTITY_CLIMATE )
318+ await common .async_set_hvac_mode (hass , HVACMode . COOL , ENTITY_CLIMATE )
320319 state = hass .states .get (ENTITY_CLIMATE )
321320 assert state .state == "cool"
322321 mqtt_mock .async_publish .assert_has_calls ([call ("mode-topic" , "cool" , 0 , False )])
323322 mqtt_mock .async_publish .reset_mock ()
324323
325- await common .async_set_hvac_mode (hass , "off" , ENTITY_CLIMATE )
324+ await common .async_set_hvac_mode (hass , HVACMode . OFF , ENTITY_CLIMATE )
326325 state = hass .states .get (ENTITY_CLIMATE )
327326 assert state .state == "off"
328327 mqtt_mock .async_publish .assert_has_calls ([call ("mode-topic" , "off" , 0 , False )])
@@ -358,12 +357,12 @@ async def test_turn_on_and_off_optimistic_with_power_command(
358357
359358 state = hass .states .get (ENTITY_CLIMATE )
360359 assert state .state == "off"
361- await common .async_set_hvac_mode (hass , "cool" , ENTITY_CLIMATE )
360+ await common .async_set_hvac_mode (hass , HVACMode . COOL , ENTITY_CLIMATE )
362361 state = hass .states .get (ENTITY_CLIMATE )
363362 assert state .state == "cool"
364363 mqtt_mock .async_publish .assert_has_calls ([call ("mode-topic" , "cool" , 0 , False )])
365364 mqtt_mock .async_publish .reset_mock ()
366- await common .async_set_hvac_mode (hass , "off" , ENTITY_CLIMATE )
365+ await common .async_set_hvac_mode (hass , HVACMode . OFF , ENTITY_CLIMATE )
367366 state = hass .states .get (ENTITY_CLIMATE )
368367 assert state .state == "off"
369368
@@ -374,7 +373,7 @@ async def test_turn_on_and_off_optimistic_with_power_command(
374373 mqtt_mock .async_publish .assert_has_calls ([call ("power-command" , "ON" , 0 , False )])
375374 mqtt_mock .async_publish .reset_mock ()
376375
377- await common .async_set_hvac_mode (hass , "cool" , ENTITY_CLIMATE )
376+ await common .async_set_hvac_mode (hass , HVACMode . COOL , ENTITY_CLIMATE )
378377 state = hass .states .get (ENTITY_CLIMATE )
379378 assert state .state == "cool"
380379 await common .async_turn_off (hass , ENTITY_CLIMATE )
@@ -433,7 +432,7 @@ async def test_turn_on_and_off_without_power_command(
433432 else :
434433 mqtt_mock .async_publish .assert_has_calls ([])
435434
436- await common .async_set_hvac_mode (hass , "cool" , ENTITY_CLIMATE )
435+ await common .async_set_hvac_mode (hass , HVACMode . COOL , ENTITY_CLIMATE )
437436 state = hass .states .get (ENTITY_CLIMATE )
438437 assert state .state == "cool"
439438 mqtt_mock .async_publish .reset_mock ()
@@ -460,7 +459,7 @@ async def test_set_fan_mode_bad_attr(
460459 state = hass .states .get (ENTITY_CLIMATE )
461460 assert state .attributes .get ("fan_mode" ) == "low"
462461 with pytest .raises (vol .Invalid ) as excinfo :
463- await common .async_set_fan_mode (hass , None , ENTITY_CLIMATE )
462+ await common .async_set_fan_mode (hass , None , ENTITY_CLIMATE ) # type:ignore[arg-type]
464463 assert "string value is None for dictionary value @ data['fan_mode']" in str (
465464 excinfo .value
466465 )
@@ -555,7 +554,7 @@ async def test_set_swing_mode_bad_attr(
555554 state = hass .states .get (ENTITY_CLIMATE )
556555 assert state .attributes .get ("swing_mode" ) == "off"
557556 with pytest .raises (vol .Invalid ) as excinfo :
558- await common .async_set_swing_mode (hass , None , ENTITY_CLIMATE )
557+ await common .async_set_swing_mode (hass , None , ENTITY_CLIMATE ) # type:ignore[arg-type]
559558 assert "string value is None for dictionary value @ data['swing_mode']" in str (
560559 excinfo .value
561560 )
@@ -649,7 +648,7 @@ async def test_set_target_temperature(
649648
650649 state = hass .states .get (ENTITY_CLIMATE )
651650 assert state .attributes .get ("temperature" ) == 21
652- await common .async_set_hvac_mode (hass , "heat" , ENTITY_CLIMATE )
651+ await common .async_set_hvac_mode (hass , HVACMode . HEAT , ENTITY_CLIMATE )
653652 state = hass .states .get (ENTITY_CLIMATE )
654653 assert state .state == "heat"
655654 mqtt_mock .async_publish .assert_called_once_with ("mode-topic" , "heat" , 0 , False )
@@ -712,7 +711,7 @@ async def test_set_target_temperature_pessimistic(
712711
713712 state = hass .states .get (ENTITY_CLIMATE )
714713 assert state .attributes .get ("temperature" ) is None
715- await common .async_set_hvac_mode (hass , "heat" , ENTITY_CLIMATE )
714+ await common .async_set_hvac_mode (hass , HVACMode . HEAT , ENTITY_CLIMATE )
716715 await common .async_set_temperature (hass , temperature = 35 , entity_id = ENTITY_CLIMATE )
717716 state = hass .states .get (ENTITY_CLIMATE )
718717 assert state .attributes .get ("temperature" ) is None
@@ -744,7 +743,7 @@ async def test_set_target_temperature_optimistic(
744743
745744 state = hass .states .get (ENTITY_CLIMATE )
746745 assert state .attributes .get ("temperature" ) == 21
747- await common .async_set_hvac_mode (hass , "heat" , ENTITY_CLIMATE )
746+ await common .async_set_hvac_mode (hass , HVACMode . HEAT , ENTITY_CLIMATE )
748747 await common .async_set_temperature (hass , temperature = 17 , entity_id = ENTITY_CLIMATE )
749748 state = hass .states .get (ENTITY_CLIMATE )
750749 assert state .attributes .get ("temperature" ) == 17
@@ -1547,14 +1546,14 @@ async def test_set_and_templates(
15471546 assert state .attributes .get ("preset_mode" ) == PRESET_ECO
15481547
15491548 # Mode
1550- await common .async_set_hvac_mode (hass , "cool" , ENTITY_CLIMATE )
1549+ await common .async_set_hvac_mode (hass , HVACMode . COOL , ENTITY_CLIMATE )
15511550 mqtt_mock .async_publish .assert_any_call ("mode-topic" , "mode: cool" , 0 , False )
15521551 assert mqtt_mock .async_publish .call_count == 1
15531552 mqtt_mock .async_publish .reset_mock ()
15541553 state = hass .states .get (ENTITY_CLIMATE )
15551554 assert state .state == "cool"
15561555
1557- await common .async_set_hvac_mode (hass , "off" , ENTITY_CLIMATE )
1556+ await common .async_set_hvac_mode (hass , HVACMode . OFF , ENTITY_CLIMATE )
15581557 mqtt_mock .async_publish .assert_any_call ("mode-topic" , "mode: off" , 0 , False )
15591558 assert mqtt_mock .async_publish .call_count == 1
15601559 mqtt_mock .async_publish .reset_mock ()
0 commit comments