Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion ha_docs_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,22 @@ def __init__(self, ha_api: HomeAssistantAPI, config: Dict, styled: bool = True):
self.custom_sections = config.get('custom_sections', {})
self.exclusions = config.get('exclusions', {})

def _filter_excluded_entities(self):
"""Apply exclusions config to self.states. Called once after states are loaded."""
if not hasattr(self, 'exclusions') or not self.exclusions:
return
original_count = len(self.states)
self.states = [
s for s in self.states
if not self._should_exclude_entity(
s['entity_id'],
s.get('attributes', {}).get('friendly_name', ''),
''
)
]
excluded = original_count - len(self.states)
if excluded > 0:
print(f" 🚫 Excluded {excluded} entities ({original_count} -> {len(self.states)})")
def _should_exclude_entity(self, entity_id: str, friendly_name: str = "", area: str = "") -> bool:
"""Check if entity should be excluded based on config"""
import re
Expand Down Expand Up @@ -236,6 +252,7 @@ def fetch_data(self):

print(" 📡 Fetching entity states...")
self.states = self.ha.get_states()
self._filter_excluded_entities()

print(" 📡 Fetching services...")
self.services = self.ha.get_services()
Expand Down Expand Up @@ -1545,4 +1562,4 @@ def main():


if __name__ == '__main__':
main()
main()