Skip to content

perf: server-side aggregate sensors and client-side optimizations#152

Open
flatline-84 wants to merge 3 commits into
Thank-you-Linus:mainfrom
flatline-84:performance-improvements
Open

perf: server-side aggregate sensors and client-side optimizations#152
flatline-84 wants to merge 3 commits into
Thank-you-Linus:mainfrom
flatline-84:performance-improvements

Conversation

@flatline-84

@flatline-84 flatline-84 commented Jun 9, 2026

Copy link
Copy Markdown

Summary

Linus Dashboard is great but I find that my tablet struggles with it. Part of it is all my devices, part of it is the tablet is not very good. Hoping to make LD a little quicker. Also did some dev changes since it was hard to get this repo initialized and ready to work in.

  • New sensor platform creates server-side aggregate sensors per domain/floor, reducing home view template evaluations from ~60 to ~3
  • Fix several client-side bottlenecks: O(n²) sorts, sequential area card creation, redundant template computations, and forced per-minute re-evaluations

Changes

Server-side aggregate sensors

  • aggregate.py: constants and pure computation functions (active states, icons, colors)
  • sensor.py: diagnostic sensors, event-driven with 100ms debounce, hidden from default UI
  • Sensors cover global and floor scope; area scope stays client-side

Frontend

  • AggregateChip uses server-side sensor when available (state_attr(...) instead of inlining 100 entity IDs), falls back gracefully if sensor doesn't exist
  • Removed now() from getLastChangedTemplate — was forcing all relative_time() cards to re-evaluate every minute
  • Parallelized HomeView area card creation with Promise.all()
  • Fixed O(n² log n) sort — replaced indexOf() in comparator with pre-built Map
  • Replaced exposedDomainIds.some(...) inner-loop calls with a pre-computed Set
  • Replaced Object.keys(DEVICE_CLASSES).includes() with a module-level Set
  • Added explicit entity_id arrays to AggregateChip and UnavailableChip for faster Mushroom subscriptions

Performance

Metric Before After
Template evaluations per state change ~60 ~3
Jinja2 template size per chip ~2–10KB ~80 bytes
WebSocket subscriptions ~2000 ~20

Test plan

Uh there was no real test plan. I put it in my personal HA with ~2000 entities / ~135 devices and it seemed a little faster? Probably a bit of placebo but I expect this to be a first pass for performance improves

"type": "bind"
}
],
// "mounts": [

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this folder is for?

Comment thread config/configuration.yaml
# Composants essentiels (remplace default_config sans go2rtc)
automation: !include automations.yaml
script: !include scripts.yaml
# automation: !include automations.yaml

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errors booting HA up if these are enabled, since the files don't exist

Comment thread Makefile
# Start Home Assistant
dev:
@echo "📄 Loading environment..."
@if [ ! -e config/custom_components ]; then \

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows LD to be present as an integration in the new HA setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant