kalkih / mini-graph-card

Minimalistic graph card for Home Assistant Lovelace UI
MIT License
2.95k stars 232 forks source link

Feature request: Use templates in all configuration values #697

Open tensiondriven opened 2 years ago

tensiondriven commented 2 years ago

Love mini-graph-card!

Forgive me if this has been requested. I'd like to be able to use jinja templates in attribute values to, for example, change the lower_bound and upper_bound to be relative to the current value, for example:

type: custom:mini-graph-card
entities:
  - entity: sensor.temperature_2
    name: Outdoor Temp
lower_bound: "{{ states('sensor.temperature_2') }} - 5 | float }}"
upper_bound: "{{ states('sensor.temperature_2') }} + 5 | float }}"
ildar170975 commented 2 years ago

Another case is to select hours_to_show dynamically. Currently I have to use config-template-card for this.

jlsjonas commented 2 years ago

Definitely something to consider; depending on complexity-level, to be considered for 0.12.0

jlsjonas commented 2 years ago

Still considering this for a few elements (like state, icon, ...) for next release; but I'm foreseeing a lot of potential side-effects & complications when adding this to any element inside the graph. Updated the issue for transparency.

ghost commented 2 years ago

+1 for this.

Very useful for upper_bound / lower bound to show multiple graphs on the same scale.

ildar170975 commented 1 year ago

Also for color_thresholds: https://github.com/kalkih/mini-graph-card/issues/834

color_thresholds:
  - value: "{{ ((states.sensor.hallway_temperature.state) | float +0) }}"
    color: '#0066ff'
  - value: "{{ ((states.sensor.hallway_temperature.state) | float +3) }}"
    color: '#d35400'
humanBeer commented 1 year ago

From my post that got merged, I would like to do something like this:

                    show_graph: |
                      {{ states('input_boolean.test_graph_icon') }}
DonCastor commented 1 year ago

Hello team !

After opening this ticket : https://github.com/kalkih/mini-graph-card/issues/943

ildar170975 told me to add my comments here :

I'm trying to do a simple thing, but it seems that i'm taking it on the wrong side!

I have created cards where I display temperature and humidity of the room (on that no issue). The temperature icon, is colored with different values as you can see below :

image

It's working fine and I have the right color with the right temperature. But when I want to apply this scheme to my mini-graph-card, it's not working : I just want to have my graph-line with the same color as my icon...

For that, here is the code :

image

This is driving me crazy, I'm sure it can work, but I don't understand why it is not.

Important : The color_treshold behaviour is not what I want. I want the whole graph to be from the color I put in parameter, not the threshold.

For example, If my temperature is 19, I want the whole graph line in green. If my temperature is 22, I want the whole line to be in red.

This is the difference between the treshold and my question.

Any idea ?

Kind regards.

ildar170975 commented 1 year ago

Any idea ?

Currently dynamic color is not supported by the card. Your possible workaround - place the card inside config-template-card. For details you may ask questions in a dedicated mini-graph-card or config-template-card threads in Community to avoid cluttering this issue.

MRobi1 commented 1 year ago

Another +1 for this FR. Would like the ability to dynamically change the graph color based on an entity's state.

My particular use-case is for climate devices. I'd like the graph to be orange if heating or blue if cooling.

      color: |
        {% if is_state('climate.thermostat_bar','heat') %}
          var(--orange-color)
        {% elif is_state('climate.thermostat_bar','cooling') %}
          var(--blue-color)
        {% endif %}
ildar170975 commented 1 year ago

@MRobi1

dynamically change the graph color based on an entity's state.

Currently this may be done by card-mod: image https://community.home-assistant.io/t/lovelace-mini-graph-card/71385/2316?u=ildar_gabdullin

MRobi1 commented 1 year ago

@ildar170975 Thanks!! I had managed to do it using config-template-card but I use card-mod everywhere else in my dashboard so it would be better for consistency.

Any idea how to handle when you have multiple lines on 1 graph and dynamically set the color of both?? EDIT: Figured it out by adding last-of-type

ildar170975 commented 1 year ago

using config-template-card

Not a good solution - you need to define your graph's sensor as "monitored" in CTC (config-template-card). Also, on every change of the sensor the whole card will flicker.

adding last-of-type

Yes, any possible pseudoclass.

If you need to continue this discussion - please move to the mini-graph community thread to avoid hijacking this issue.

Krzysztonek commented 1 year ago

Here is a one-line excerpt of my card code:

show_hours: 720

I would need to be able to change it from the hard-coded value (here: 720) to any numerical external value being kept in the numerical helper (e.g. input_number.show_hours) or any other numerical entity.

This is basically what I want to achieve (don't look at the syntax, the semantic counts here):

show_hours: Number(states['input_number.show_hours'].state)

Is it possible to have it coded somehow?

ncd7 commented 6 months ago

this would be INCREDIBLY useful for all config fields agreed! another example I have is for the value_factor field -- to be controlled through an input value

cryptk commented 6 months ago

Another use-case for this would be converting a string state into a value that could then be graphed. For example, converting an hvac_action from a climate entity into values. This would allow me to highlight the background of the chart in red or blue depending on if the heating or cooling was running during a time period which I am currently doing with the apexcharts card (but I like the look of this card much better and wish I could replicate this functionality)

FauxPalindrome commented 2 months ago

+1 for this. Been waiting for this for a looong time.

I'd like to be able to dynamically change de number of hours showing.

MaxLeb commented 1 month ago

+1

I don't know if this is here but it would be usefull for name field of each entity. In my case all temperature sensors are numbered to avoid having there names/id linked to a room and I would like to use area_name('sensor.xxx') to avoid changing the graph if I move a sensor to an other room

Anyone with a config-template-card example as a workaround ?