Skip to content

History graph card: allow color customization for "line" graphs#51802

Open
ildar170975 wants to merge 14 commits intohome-assistant:devfrom
ildar170975:history-graph-color
Open

History graph card: allow color customization for "line" graphs#51802
ildar170975 wants to merge 14 commits intohome-assistant:devfrom
ildar170975:history-graph-color

Conversation

@ildar170975
Copy link
Copy Markdown
Contributor

@ildar170975 ildar170975 commented Apr 30, 2026

Breaking change

Proposed change

Currently the only way to customize colors in history-graph (particularly – for linear state-history-chart-line) – defining --graph-color variables in a custom theme.
But this way has limitations:
-- cannot customize colors only for a particular card (unless card-mod is used);
-- cannot customize a color for a particular entity, a color depends on an index.
There were many requests in Community for adding a possibility to define colors in the history-graph config directly.

Related:
#18494
https://community.home-assistant.io/t/changing-colors-of-the-history-graph/219535
#11054
#11188
https://github.com/orgs/home-assistant/discussions/168

This PR contains:

  1. Support of color option in history-graph card.
  2. A corresponding color input field added in UI editor.
  3. The mentioned color input field is disabled for assumingly not-numerical entities. Means – colors can be only defined for assumingly numerical entities: for counter/input_number/number domains, for sensors with defined unit_of_measurement & state_class attributes, but sensorNumericDeviceClasses is not accounted for simplicity. Anyway, if a user defines the color option for a timeline graph – this option will not be accounted as meaningless. Similarly, the color option cannot be defined for climate & water_heater entities due to a complex presentation, a default colors generation is used.
  4. The added color option is optional. If it is not defined for some entity – a default color generation is used for this entity.
  5. Options of the history-graph card are automatically placed in yaml in a correct consistent order.
  6. There are few formats can be used to define a color option in yaml: lightgreen (web color), light-green (HA theme color transformed into --light-green-color CSS var and then resolved from a current theme), #ff00ff (hex), rgb(0,0,255) (RGB). Note that a red color will be processed as a --red-color variable (a value may differ from a red web color).
  7. Colors are respected for statistics “augmented” parts.

Similar - for Statistics graph card: #51824

Docs are updated - home-assistant/home-assistant.io#45123.

UI editor (layout can be changed due to #51749):
изображение

Default & customized colors:
изображение

Different color formats used in yaml:
изображение

History + statistics:
изображение

Disabled color option:
изображение

Screenshots

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • I have followed the perfect PR recommendations
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

To help with the load of incoming pull requests:

@ildar170975 ildar170975 changed the title History graph color History graph card: allow color customization for "line" graphs Apr 30, 2026
@ildar170975 ildar170975 marked this pull request as ready for review April 30, 2026 08:30
@ildar170975 ildar170975 marked this pull request as draft April 30, 2026 08:35
@ildar170975 ildar170975 marked this pull request as ready for review April 30, 2026 17:00
@ildar170975 ildar170975 marked this pull request as draft May 1, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant