@pytest.mark.parametrize('units, attributes, unit', [(IMPERIAL_SYSTEM, POWER_SENSOR_ATTRIBUTES, 'W'), (METRIC_SYSTEM, POWER_SENSOR_ATTRIBUTES, 'W'), (IMPERIAL_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, '°F'), (METRIC_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, '°C'), (IMPERIAL_SYSTEM, PRESSURE_SENSOR_ATTRIBUTES, 'psi'), (METRIC_SYSTEM, PRESSURE_SENSOR_ATTRIBUTES, 'Pa')])
async def test_list_statistic_ids(hass, hass_ws_client, units, attributes, unit):
    'Test list_statistic_ids.'
    now = dt_util.utcnow()
    hass.config.units = units
    (await hass.async_add_executor_job(init_recorder_component, hass))
    (await async_setup_component(hass, 'history', {'history': {}}))
    (await async_setup_component(hass, 'sensor', {}))
    (await hass.async_add_executor_job(hass.data[recorder.DATA_INSTANCE].block_till_done))
    client = (await hass_ws_client())
    (await client.send_json({'id': 1, 'type': 'history/list_statistic_ids'}))
    response = (await client.receive_json())
    assert response['success']
    assert (response['result'] == [])
    hass.states.async_set('sensor.test', 10, attributes=attributes)
    (await hass.async_block_till_done())
    (await hass.async_add_executor_job(trigger_db_commit, hass))
    (await hass.async_block_till_done())
    (await client.send_json({'id': 2, 'type': 'history/list_statistic_ids'}))
    response = (await client.receive_json())
    assert response['success']
    assert (response['result'] == [{'statistic_id': 'sensor.test', 'unit_of_measurement': unit}])
    hass.data[recorder.DATA_INSTANCE].do_adhoc_statistics(period='hourly', start=now)
    (await hass.async_add_executor_job(hass.data[recorder.DATA_INSTANCE].block_till_done))
    hass.states.async_remove('sensor.test')
    (await hass.async_block_till_done())
    (await client.send_json({'id': 3, 'type': 'history/list_statistic_ids'}))
    response = (await client.receive_json())
    assert response['success']
    assert (response['result'] == [{'statistic_id': 'sensor.test', 'unit_of_measurement': unit}])
    (await client.send_json({'id': 4, 'type': 'history/list_statistic_ids', 'statistic_type': 'dogs'}))
    response = (await client.receive_json())
    assert (not response['success'])
    (await client.send_json({'id': 5, 'type': 'history/list_statistic_ids', 'statistic_type': 'mean'}))
    response = (await client.receive_json())
    assert response['success']
    assert (response['result'] == [{'statistic_id': 'sensor.test', 'unit_of_measurement': unit}])
    (await client.send_json({'id': 6, 'type': 'history/list_statistic_ids', 'statistic_type': 'sum'}))
    response = (await client.receive_json())
    assert response['success']
    assert (response['result'] == [])
Test list_statistic_ids.
@pytest.mark.parametrize('units, attributes, unit', [(IMPERIAL_SYSTEM, POWER_SENSOR_ATTRIBUTES, 'W'), (METRIC_SYSTEM, POWER_SENSOR_ATTRIBUTES, 'W'), (IMPERIAL_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, '°F'), (METRIC_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, '°C'), (IMPERIAL_SYSTEM, PRESSURE_SENSOR_ATTRIBUTES, 'psi'), (METRIC_SYSTEM, PRESSURE_SENSOR_ATTRIBUTES, 'Pa')])
async def test_list_statistic_ids(hass, hass_ws_client, units, attributes, unit):
    
    now = dt_util.utcnow()
    hass.config.units = units
    (await hass.async_add_executor_job(init_recorder_component, hass))
    (await async_setup_component(hass, 'history', {'history': {}}))
    (await async_setup_component(hass, 'sensor', {}))
    (await hass.async_add_executor_job(hass.data[recorder.DATA_INSTANCE].block_till_done))
    client = (await hass_ws_client())
    (await client.send_json({'id': 1, 'type': 'history/list_statistic_ids'}))
    response = (await client.receive_json())
    assert response['success']
    assert (response['result'] == [])
    hass.states.async_set('sensor.test', 10, attributes=attributes)
    (await hass.async_block_till_done())
    (await hass.async_add_executor_job(trigger_db_commit, hass))
    (await hass.async_block_till_done())
    (await client.send_json({'id': 2, 'type': 'history/list_statistic_ids'}))
    response = (await client.receive_json())
    assert response['success']
    assert (response['result'] == [{'statistic_id': 'sensor.test', 'unit_of_measurement': unit}])
    hass.data[recorder.DATA_INSTANCE].do_adhoc_statistics(period='hourly', start=now)
    (await hass.async_add_executor_job(hass.data[recorder.DATA_INSTANCE].block_till_done))
    hass.states.async_remove('sensor.test')
    (await hass.async_block_till_done())
    (await client.send_json({'id': 3, 'type': 'history/list_statistic_ids'}))
    response = (await client.receive_json())
    assert response['success']
    assert (response['result'] == [{'statistic_id': 'sensor.test', 'unit_of_measurement': unit}])
    (await client.send_json({'id': 4, 'type': 'history/list_statistic_ids', 'statistic_type': 'dogs'}))
    response = (await client.receive_json())
    assert (not response['success'])
    (await client.send_json({'id': 5, 'type': 'history/list_statistic_ids', 'statistic_type': 'mean'}))
    response = (await client.receive_json())
    assert response['success']
    assert (response['result'] == [{'statistic_id': 'sensor.test', 'unit_of_measurement': unit}])
    (await client.send_json({'id': 6, 'type': 'history/list_statistic_ids', 'statistic_type': 'sum'}))
    response = (await client.receive_json())
    assert response['success']
    assert (response['result'] == [])