async def test_fetch_period_api_with_entity_glob_exclude(hass, hass_client):
    'Test the fetch period view for history.'
    (await hass.async_add_executor_job(init_recorder_component, hass))
    (await async_setup_component(hass, 'history', {'history': {'exclude': {'entity_globs': ['light.k*'], 'domains': 'switch', 'entities': 'media_player.test'}}}))
    (await hass.async_add_executor_job(hass.data[recorder.DATA_INSTANCE].block_till_done))
    hass.states.async_set('light.kitchen', 'on')
    hass.states.async_set('light.cow', 'on')
    hass.states.async_set('light.match', 'on')
    hass.states.async_set('switch.match', 'on')
    hass.states.async_set('media_player.test', 'on')
    (await hass.async_block_till_done())
    (await hass.async_add_executor_job(trigger_db_commit, hass))
    (await hass.async_block_till_done())
    (await hass.async_add_executor_job(hass.data[recorder.DATA_INSTANCE].block_till_done))
    client = (await hass_client())
    response = (await client.get(f'/api/history/period/{dt_util.utcnow().isoformat()}'))
    assert (response.status == 200)
    response_json = (await response.json())
    assert (len(response_json) == 2)
    assert (response_json[0][0]['entity_id'] == 'light.cow')
    assert (response_json[1][0]['entity_id'] == 'light.match')
Test the fetch period view for history.
async def test_fetch_period_api_with_entity_glob_exclude(hass, hass_client):
    
    (await hass.async_add_executor_job(init_recorder_component, hass))
    (await async_setup_component(hass, 'history', {'history': {'exclude': {'entity_globs': ['light.k*'], 'domains': 'switch', 'entities': 'media_player.test'}}}))
    (await hass.async_add_executor_job(hass.data[recorder.DATA_INSTANCE].block_till_done))
    hass.states.async_set('light.kitchen', 'on')
    hass.states.async_set('light.cow', 'on')
    hass.states.async_set('light.match', 'on')
    hass.states.async_set('switch.match', 'on')
    hass.states.async_set('media_player.test', 'on')
    (await hass.async_block_till_done())
    (await hass.async_add_executor_job(trigger_db_commit, hass))
    (await hass.async_block_till_done())
    (await hass.async_add_executor_job(hass.data[recorder.DATA_INSTANCE].block_till_done))
    client = (await hass_client())
    response = (await client.get(f'/api/history/period/{dt_util.utcnow().isoformat()}'))
    assert (response.status == 200)
    response_json = (await response.json())
    assert (len(response_json) == 2)
    assert (response_json[0][0]['entity_id'] == 'light.cow')
    assert (response_json[1][0]['entity_id'] == 'light.match')