Newbie Q: How Do I Check the Source Entity for a Statistical Helper?

Maybe a dumb beginner question, but where the heck do you find the source for a statistical helper using the web interface? I was expecting something like a “source_entity:” or similar.

I’ve looked under Settings > Devices & Services > Helpers > [My Helper] in the “statistical options”, and also checked Developer Tools > STATES, but neither seems to show what source entity the helper is actually using.

Any ideas?

Once you have created it using the UI it does not appear there is a way to view this information.

Thanks! Is there another way to find out the source? I have three very similar ones and want to delete two of them.

Look in config/.storage/core.entity_registry

Be very careful. Have a backup or copy the file somewhere else before opening. One wrong character in that file can prevent home assistant from starting.

1 Like

Actually a bit more complex than that.

The core.entity_registry will help you find the config_entry_id of the statistics sensor.

      {"aliases":[],"area_id":null,"categories":{},"capabilities":{"state_class":"measurement"},"config_entry_id":"01JVSH8WASP16AXAT7YPD7H0FV","config_subentry_id":null,"created_at":"2025-05-21T13:42:05.402758+00:00","device_class":null,"device_id":null,"disabled_by":null,"entity_category":null,"entity_id":"sensor.home_temperature_average","hidden_by":null,"icon":null,"id":"7d4c14834a4c54756c800e470bf4e513","has_entity_name":false,"labels":[],"modified_at":"2025-05-21T13:42:05.407770+00:00","name":null,"options":{"conversation":{"should_expose":true}},"original_device_class":"temperature","original_icon":"mdi:calculator","original_name":"Home Temperature Average","platform":"statistics","supported_features":0,"translation_key":null,"unique_id":"01JVSH8WASP16AXAT7YPD7H0FV","previous_unique_id":null,"unit_of_measurement":null}

"config_entry_id":"01JVSH8WASP16AXAT7YPD7H0FV"

You then need to take that ID to core.config_entries, find the matching entry_id, and get the sensor from the options:

  {"created_at":"2025-05-21T13:42:05.401722+00:00","data":{},"disabled_by":null,"discovery_keys":{},"domain":"statistics","entry_id":"01JVSH8WASP16AXAT7YPD7H0FV","minor_version":1,"modified_at":"2025-05-21T13:42:05.401724+00:00","options":{"entity_id":"sensor.home_temperature","keep_last_sample":false,"name":"Home Temperature Average","percentile":50.0,"precision":2.0,"sampling_size":10.0,"state_characteristic":"average_linear"},"pref_disable_new_entities":false,"pref_disable_polling":false,"source":"user","subentries":[],"title":"Home Temperature Average","unique_id":null,"version":1}

"entity_id":"sensor.home_temperature"

Unfortunately I’ve had a PR to show this information in the UI waiting for like 9 months, but it’s just sitting not getting reviewed :stuck_out_tongue_closed_eyes: :skull:

2 Likes

Thanks for the feedback! Yeah, I noticed that too. I found some references online and tried fetching helper info via WebSocket using "config/entity_registry/list" and "config_entries/get", but the result is missing "options" -> "entity_id" like below which does exist in the files.

Why is that, one might wonder? It’s just an informational field, right? Any updates on that PR you suggested?

 #
 # Snippet from $HOME/homeassistant/.storage/core.config_entries
 #
 {
    "created_at": "2025-05-20T21:24:05.575140+00:00",
    "data": {},
    "disabled_by": null,
    "discovery_keys": {},
    "domain": "statistics",
    "entry_id": "01JVQF0GY7PVN0RA5Q3RJ7WSYT",
    "minor_version": 1,
    "modified_at": "2025-05-20T21:24:05.575146+00:00",
    "options": {
        "entity_id": "sensor.dsmr_reading_electricity_currently_delivered",
        "keep_last_sample": false,
        "max_age": {
        "hours": 0,
        "minutes": 1,
        "seconds": 0
        },
        "name": "helper test",
        "percentile": 50.0,
        "precision": 3.0,
        "sampling_size": 400.0,
        "state_characteristic": "mean"
    },
    "pref_disable_new_entities": false,
    "pref_disable_polling": false,
    "source": "user",
    "title": "Helper Test",
    "unique_id": null,
    "version": 1
}

Anyway, I put together a little python helper script (see list_statistics_helper_entries.py below) that lists all Statistic Helpers along with their corresponding source entity. You just need to copy the files core.config_entries and core.entity_registry with scp from $HOME/homeassistant/.storage, and run the script in the same folder.

Btw, is there any other way to access core.config_entries and core.entity_registry, like via the API or something similar?

list_statistics_helper_entries.py
# list_statistics_helper_entries.py 
import json
from tabulate import tabulate

# File locations
CONFIG_ENTRIES_PATH =  "core.config_entries"
ENTITY_REGISTRY_PATH = "core.entity_registry"

#
# Open file
#
def load_json(path):
    try:
        with open(path, encoding="utf-8") as f:
            return json.load(f)
    except FileNotFoundError:
        print(f"File not found: {path}")
        return None

#
#  map config_entry_id -> entity_id from file core.entity_registry
#
def build_entity_map(entity_registry):
    entity_map = {}
    for entity in entity_registry.get("data", {}).get("entities", []):
        if entity.get("platform") == "statistics":
            config_id = entity.get("config_entry_id")
            entity_map[config_id] = entity.get("entity_id")
    return entity_map

#
# Main: load_statistics_helpers
#
def load_statistics_helpers():
    config_data = load_json(CONFIG_ENTRIES_PATH)
    entity_data = load_json(ENTITY_REGISTRY_PATH)
 
    # check file open status
    if not config_data or not entity_data:
        return

    entries = config_data.get("data", {}).get("entries", [])
    entity_map = build_entity_map(entity_data)

    # Get only statistics helpers..
    stats_entries = [e for e in entries if e.get("domain") == "statistics"]

    if not stats_entries:
        print("No statistical helpers found.")
        return

    rows = []
    for entry in stats_entries:
        entry_id = entry.get("entry_id", "-")
        title = entry.get("title", "-")
        options = entry.get("options", {})
        source_entity = options.get("entity_id", "-")
        stat_type = options.get("state_characteristic", "-")
        sampling_size = options.get("sampling_size", "–")
        precision = options.get("precision", "–")
        max_age = options.get("max_age", {})
        max_age_str = f"{max_age.get('hours',0)}h {max_age.get('minutes',0)}m {max_age.get('seconds',0)}s"

        # Match to entity_id if found
        entity_id = entity_map.get(entry_id, "-")

        rows.append([
            title,
            entity_id,
            source_entity,
            stat_type,
            sampling_size,
            precision,
            max_age_str,
            entry_id
        ])

    print(tabulate(
        rows,
        headers=[
            "Helper Name",
            "Helper Entity",
            "Source Entity",
            "Stat Type",
            "Samples",
            "Precision",
            "Max Age",
            "Config Entry ID"
        ]
    ))

if __name__ == "__main__":
    load_statistics_helpers()

And the output look like this:

Helper Name                         Helper Entity                              Source Entity                                        Stat Type
----------------------------------  -----------------------------------------  ---------------------------------------------------  --------------
DSMR hourly power usage statistics  sensor.dsmr_hourly_power_usage_statistics  sensor.dsmr_reading_electricity_currently_delivered  average_linear
Power Usage Last Hour               sensor.power_usage_last_hour               sensor.dsmr_reading_electricity_currently_delivered  mean
Power Usage Last Minute             sensor.power_usage_last_minute             sensor.dsmr_reading_electricity_currently_delivered  mean
Power Usage Last 24 h               sensor.power_usage_last_24_h               sensor.dsmr_reading_electricity_currently_delivered  mean
Helper Test                         sensor.helper_test                         sensor.dsmr_reading_electricity_currently_delivered  mean