Skip to content

Make Display Priority 0 Hide Vehicles#5321

Draft
shivam-sh wants to merge 1 commit into
teslamate-org:mainfrom
shivam-sh:shivam/minimal-dashboard-visibility
Draft

Make Display Priority 0 Hide Vehicles#5321
shivam-sh wants to merge 1 commit into
teslamate-org:mainfrom
shivam-sh:shivam/minimal-dashboard-visibility

Conversation

@shivam-sh
Copy link
Copy Markdown

Summary

This exposes the existing per-car display_priority setting in Settings as a small “Visualization” section and reuses that same field for Grafana dashboard visibility.

Cars with display_priority > 0 continue to appear in dashboard car selectors, ordered by display_priority. Setting the car to hidden stores display_priority = 0, so no new setting column or migration is needed.

Rationale

The goal is to let users keep a car in TeslaMate and continue managing it in Settings, while hiding it from Grafana dashboard selectors when it should not appear in visualizations.

This keeps dashboard visibility and dashboard ordering represented by one existing field instead of introducing a separate show_in_dashboards setting.

Changes

  • Add a “Visualization” section to per-car Settings.
  • Add controls for:
    • Show in dashboards
    • Display priority
  • Filter built-in Grafana car_id variables with display_priority > 0.
  • Preserve existing dashboard ordering by display_priority.
  • Add Settings LiveView coverage for updating visibility and priority.

Verification

  • mix test
  • MIX_ENV=test mix ci
  • mix gettext.extract --check-up-to-date
  • git diff --check
  • Parsed all built-in dashboard JSON files and verified all 22 car_id variables use the visibility filter.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 3, 2026

CLA assistant check
All committers have signed the CLA.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 3, 2026

Deploy Preview for teslamate ready!

Name Link
🔨 Latest commit 7df31c7
🔍 Latest deploy log https://app.netlify.com/projects/teslamate/deploys/69f7c6f85a130c000889b64a
😎 Deploy Preview https://deploy-preview-5321--teslamate.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@git-anish
Copy link
Copy Markdown

git-anish commented May 5, 2026

tested and verified locally. Both new settings work, hiding the cars is possible and so is reordering them.

Screenshot 2026-05-04 at 9 53 26 PM Screenshot 2026-05-04 at 9 53 10 PM

@git-anish
Copy link
Copy Markdown

@swiffer @JakobLichterfeld thoughts on this?

@swiffer
Copy link
Copy Markdown
Collaborator

swiffer commented May 15, 2026

not sure i like mixing display_priority and show_in_dashboards by reusing the display_priority field.

in #5188 we've started sorting the vehicles in the teslamate settings by display_priority - that means all vehicles with prio 0 will be shown first (instead of last which would be expected).

This PR looks good to me UI-wise (exposing display_priority, new toggle and grouped in Visualization) - the backend related changes still look larger than needed and overall this PR now is in between two different to approaches overall which makes it hard to review.

@JakobLichterfeld
Copy link
Copy Markdown
Member

JakobLichterfeld commented May 15, 2026

not sure i like mixing display_priority and show_in_dashboards by reusing the display_priority field.

Same here, and with tendency to dislike it, as this are separate use cases.

the backend related changes still look larger than needed and overall this PR now is in between two different to approaches overall which makes it hard to review.

Only can echo this and repeat from here:
#5300 (comment)

Not sure how to proceed with this AI slop and bloat.

Combined with switching git usernames I tend to close and block.

@JakobLichterfeld JakobLichterfeld marked this pull request as draft May 15, 2026 13:24
@JakobLichterfeld JakobLichterfeld added note:discussion Details or approval are up for discussion area:dashboard Related to a Grafana dashboard area:teslamate Related to TeslaMate core labels May 15, 2026
@git-anish
Copy link
Copy Markdown

git-anish commented May 20, 2026

Combined with switching git usernames I tend to close and block.

Hey Jacob, this PR is from my brother.... him and I decided to work on this together since we both use teslamate. I'll wait for him to chime in.

https://www.linkedin.com/in/anish5/

https://www.linkedin.com/in/shivam-sh/

@brianmay
Copy link
Copy Markdown
Collaborator

not sure i like mixing display_priority and show_in_dashboards by reusing the display_priority field.

I am uneasy with this also.

We are reusing one attribute for two different purposes. Which means for example that if you want to hide a value can no longer store the display_priority anymore. Maybe trivial here, but makes me uneasy.

My LLM said "When a car is hidden, the priority input is disabled (not submitted). When re-enabling, the fallback logic returns 1, silently discarding any previously set custom priority."

I asked my LLM, and it pointed out some other potential issues:

High — NULL display_priority breaks all dashboards on upgrade
The new WHERE display_priority > 0 filter excludes NULL values (SQL treats NULL > 0 as false). No migration backfills existing rows, so any car created before this column was introduced will disappear from all Grafana dashboards after upgrading. Fix: add a migration to backfill display_priority = 1, or change the filter to WHERE display_priority > 0 OR display_priority IS NULL.

Medium — LiveView bypasses the Vehicles GenServer
Log.update_car/2 is called directly from the LiveView (index.ex:195, index.ex:207) rather than going through the Vehicles GenServer, which also calls Log.update_car/2 and caches the car struct. This creates a potential state coordination gap where a subsequent Tesla API sync could overwrite the setting.

I haven't investigated these in too much detail, but I think they do deserve some attention.

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

Labels

area:dashboard Related to a Grafana dashboard area:teslamate Related to TeslaMate core note:discussion Details or approval are up for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants