async def test_no_state_change_when_operation_mode_off_2(hass, setup_comp_3): """Test that the switch doesn't turn on when enabled is False.""" calls = _setup_switch(hass, False) common.async_set_temperature(hass, 30) await hass.async_block_till_done() common.async_set_operation_mode(hass, STATE_OFF) await hass.async_block_till_done() _setup_sensor(hass, 35) await hass.async_block_till_done() assert 0 == len(calls)
async def test_precision(hass, setup_comp_10): """Test that setting precision to tenths works as intended.""" common.async_set_operation_mode(hass, STATE_OFF) await hass.async_block_till_done() await hass.services.async_call('climate', SERVICE_TURN_OFF) await hass.async_block_till_done() common.async_set_temperature(hass, 23.27) await hass.async_block_till_done() state = hass.states.get(ENTITY) assert 23.3 == state.attributes.get('temperature')
async def test_running_when_operating_mode_is_off_2(hass, setup_comp_3): """Test that the switch turns off when enabled is set False.""" calls = _setup_switch(hass, True) common.async_set_temperature(hass, 30) await hass.async_block_till_done() common.async_set_operation_mode(hass, STATE_OFF) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] assert HASS_DOMAIN == call.domain assert SERVICE_TURN_OFF == call.service assert ENT_SWITCH == call.data['entity_id']
async def test_turn_off_when_off(hass, setup_comp_9): """Test if climate.turn_off does nothing to a turned off device.""" common.async_set_operation_mode(hass, STATE_OFF) await hass.async_block_till_done() await hass.services.async_call('climate', SERVICE_TURN_OFF) await hass.async_block_till_done() state_heat = hass.states.get(HEAT_ENTITY) state_cool = hass.states.get(COOL_ENTITY) assert STATE_OFF == \ state_heat.attributes.get('operation_mode') assert STATE_OFF == \ state_cool.attributes.get('operation_mode')
async def test_mode_change_ac_trigger_on_not_long_enough_2(hass, setup_comp_5): """Test if mode change turns ac on despite minimum cycle.""" calls = _setup_switch(hass, False) common.async_set_temperature(hass, 25) await hass.async_block_till_done() _setup_sensor(hass, 30) await hass.async_block_till_done() assert 0 == len(calls) common.async_set_operation_mode(hass, STATE_HEAT) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] assert 'homeassistant' == call.domain assert SERVICE_TURN_ON == call.service assert ENT_SWITCH == call.data['entity_id']
async def test_mode_change_ac_trigger_on_not_long_enough_2(hass, setup_comp_5): """Test if mode change turns ac on despite minimum cycle.""" calls = _setup_switch(hass, False) common.async_set_temperature(hass, 25) await hass.async_block_till_done() _setup_sensor(hass, 30) await hass.async_block_till_done() assert 0 == len(calls) common.async_set_operation_mode(hass, climate.STATE_HEAT) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] assert 'homeassistant' == call.domain assert SERVICE_TURN_ON == call.service assert ENT_SWITCH == call.data['entity_id']
async def test_mode_change_heater_trigger_off_not_long_enough( hass, setup_comp_6): """Test if mode change turns heater off despite minimum cycle.""" calls = _setup_switch(hass, True) common.async_set_temperature(hass, 25) await hass.async_block_till_done() _setup_sensor(hass, 30) await hass.async_block_till_done() assert 0 == len(calls) common.async_set_operation_mode(hass, climate.STATE_OFF) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] assert 'homeassistant' == call.domain assert SERVICE_TURN_OFF == call.service assert ENT_SWITCH == call.data['entity_id']
async def test_mode_change_heater_trigger_off_not_long_enough( hass, setup_comp_6): """Test if mode change turns heater off despite minimum cycle.""" calls = _setup_switch(hass, True) common.async_set_temperature(hass, 25) await hass.async_block_till_done() _setup_sensor(hass, 30) await hass.async_block_till_done() assert 0 == len(calls) common.async_set_operation_mode(hass, STATE_OFF) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] assert 'homeassistant' == call.domain assert SERVICE_TURN_OFF == call.service assert ENT_SWITCH == call.data['entity_id']
async def test_operating_mode_cool(hass, setup_comp_3): """Test change mode from OFF to COOL. Switch turns on when temp below setpoint and mode changes. """ common.async_set_operation_mode(hass, STATE_OFF) common.async_set_temperature(hass, 25) _setup_sensor(hass, 30) await hass.async_block_till_done() calls = _setup_switch(hass, False) common.async_set_operation_mode(hass, STATE_COOL) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] assert HASS_DOMAIN == call.domain assert SERVICE_TURN_ON == call.service assert ENT_SWITCH == call.data['entity_id']
async def test_operating_mode_cool(hass, setup_comp_3): """Test change mode from OFF to COOL. Switch turns on when temp below setpoint and mode changes. """ common.async_set_operation_mode(hass, STATE_OFF) common.async_set_temperature(hass, 25) _setup_sensor(hass, 30) await hass.async_block_till_done() calls = _setup_switch(hass, False) common.async_set_operation_mode(hass, climate.STATE_COOL) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] assert HASS_DOMAIN == call.domain assert SERVICE_TURN_ON == call.service assert ENT_SWITCH == call.data['entity_id']
async def test_invalid_operating_mode(log_mock, hass, setup_comp_2): """Test error handling for invalid operation mode.""" common.async_set_operation_mode(hass, 'invalid mode') await hass.async_block_till_done() assert log_mock.call_count == 1