|
18 | 18 | from homeassistant.components.recorder.util import session_scope
|
19 | 19 | from homeassistant.const import Platform
|
20 | 20 | from homeassistant.core import HomeAssistant
|
| 21 | +from homeassistant.helpers import entity_registry as er |
21 | 22 | from homeassistant.util import dt as dt_util
|
22 | 23 | from homeassistant.util.json import json_loads_object
|
23 | 24 |
|
|
41 | 42 | Platform.CAMERA,
|
42 | 43 | Platform.CLIMATE,
|
43 | 44 | Platform.COVER,
|
44 |
| - Platform.DATE, |
45 |
| - Platform.DATETIME, |
46 | 45 | Platform.FAN,
|
47 | 46 | Platform.HUMIDIFIER,
|
48 | 47 | Platform.IMAGE,
|
|
57 | 56 | Platform.SIREN,
|
58 | 57 | Platform.SWITCH,
|
59 | 58 | Platform.TEXT,
|
60 |
| - Platform.TIME, |
61 |
| - Platform.TODO, |
62 |
| - Platform.UPDATE, |
63 | 59 | Platform.VACUUM,
|
64 | 60 | Platform.VALVE,
|
65 |
| - Platform.WAKE_WORD, |
66 | 61 | Platform.WATER_HEATER,
|
67 |
| - Platform.WEATHER, |
68 | 62 | # Helpers with own domain
|
69 | 63 | "counter",
|
70 | 64 | "group",
|
@@ -105,14 +99,17 @@ async def async_predict_common_control(
|
105 | 99 | """
|
106 | 100 | # Get the recorder instance to ensure it's ready
|
107 | 101 | recorder = get_instance(hass)
|
| 102 | + ent_reg = er.async_get(hass) |
108 | 103 |
|
109 | 104 | # Execute the database operation in the recorder's executor
|
110 | 105 | return await recorder.async_add_executor_job(
|
111 |
| - _fetch_with_session, hass, _fetch_and_process_data, user_id |
| 106 | + _fetch_with_session, hass, _fetch_and_process_data, ent_reg, user_id |
112 | 107 | )
|
113 | 108 |
|
114 | 109 |
|
115 |
| -def _fetch_and_process_data(session: Session, user_id: str) -> EntityUsagePredictions: |
| 110 | +def _fetch_and_process_data( |
| 111 | + session: Session, ent_reg: er.EntityRegistry, user_id: str |
| 112 | +) -> EntityUsagePredictions: |
116 | 113 | """Fetch and process service call events from the database."""
|
117 | 114 | # Prepare a dictionary to track results
|
118 | 115 | results: dict[str, Counter[str]] = {
|
@@ -198,6 +195,7 @@ def _fetch_and_process_data(session: Session, user_id: str) -> EntityUsagePredic
|
198 | 195 | entity_id
|
199 | 196 | for entity_id in entity_ids
|
200 | 197 | if entity_id.split(".")[0] in ALLOWED_DOMAINS
|
| 198 | + and ((entry := ent_reg.async_get(entity_id)) is None or not entry.hidden) |
201 | 199 | ]
|
202 | 200 |
|
203 | 201 | if not entity_ids:
|
|
0 commit comments