Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Add random color to each entity #224

Open
AleXSR700 opened this issue Sep 12, 2024 · 0 comments
Open

[FR] Add random color to each entity #224

AleXSR700 opened this issue Sep 12, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@AleXSR700
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
It is more of a visual optimization than a problem, but it would be nice if there was a config setting that would add random colors to each entity. Ideally for parents and children and only if no manual color is defined.

Describe the solution you'd like
A clear and concise description of what you want to happen.
Add config setting like color_random: true that automatically assigns each entity (that has no defined color: property) a random color.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

I wrote myself a short jinja template that does this for me, but since the random function updates every few seconds, it is a bit of a pain to copy and of course: it is far less elegant than having a built in feature :)

{% set sensors = states.sensor | selectattr('entity_id', 'search', 'energy_today') %}
  {% set filtered_sensors = sensors | selectattr('entity_id', 'search', 'energy_today(_\d+)?$') %}
  {% if filtered_sensors %}
{% for sensor in filtered_sensors %}
{{ "- type: entity" }}
  {{ "children: []" }}
  {{ "entity_id: " + sensor.entity_id }}{% set random_color = "rgb(" ~ range(0, 256) | random ~ "," ~ range(0, 256) | random ~ "," ~ range(0, 256) | random ~ ")" %}
  {{ "color: " + random_color }}{% endfor %}
{% endif %}

Additional context
Add any other context or screenshots about the feature request here.

@AleXSR700 AleXSR700 changed the title Add random color to each entity [FR] Add random color to each entity Sep 17, 2024
@MindFreeze MindFreeze added the enhancement New feature or request label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants