Card-mini-map template code

Either I have found a bug or I am too stupid.

Here you can see a minimal example of what it should look like

Sometimes I am so confused that I rebuilt the example code directly.


And I also used the documentation code.
But still: No line

The best I have managed so far was this. Here I got a few lines for the first time. But of course they are nonsensical
grafik

Now yours. Bug or personal stupidity :wink:

Not a bug hehe :joy::joy:

The latter, I’m afraid.

In your first screenshot, the dict_attribute is merely a string that looks like a dictionary. How did you create that?

In your final screenshot, you can’t use dot notation to access dictionary items that begin with a digit or contain special characters. Either use dict_attribute['07:00'] if the card supports it, or rename your dict items to avoid this, such as t0700.

Thank you for your “honesty” :wink:
rebuilt manually. As I said: Desperate act to rebuild the documentation 100%.

template:
  - sensor:
      - name: Solar forecast values today
        state: >
          {{ “Values found ‘ ~ now().strftime(’%d.%m.%Y %H:%M:%S') }}
        attributes:
          dict_attribute: >
            {
              value_1: 53,
              value_2: 64,
              value_3: 72
            }

Results in the first image.
So 100’% according to the documentation.
Also used the card-mini-map template 1:1. No curve.

New attempt according to your suggestion:

  - sensor:
      - name: Solarprognose Werte Heute
        state: >
          {% set data = state_attr('sensor.solarprognose_raw_json_hourly', 'data') %}
          {% if data %}
            {{ "Werte gefunden " ~ now().strftime('%d.%m.%Y %H:%M:%S') }}
          {% else %}
            no_data
          {% endif %}
        attributes:
          dict_attribute: >
            {% set start_of_today = as_timestamp(now().replace(hour=0, minute=0, second=0, microsecond=0)) | int %}
            {% set end_of_today = as_timestamp(now().replace(hour=23, minute=59, second=59, microsecond=0)) | int %}
            {% set ns = namespace(values_dict="{}") %}
            {% set data = state_attr('sensor.solarprognose_raw_json_hourly', 'data') %}
            
            {% if data %}
              {% for ts, values in data.items() %}
                {% set ts_int = ts | int %}
                {% if ts_int >= start_of_today and ts_int <= end_of_today %}
                  {% set key = "t" ~ ts_int | timestamp_custom('%H%M', false) %}
                  {% set value = values[0] | float %}
                  {% set ns.values_dict = ns.values_dict[:-1] + (', "' ~ key ~ '": ' ~ value | string ~ '}') if ns.values_dict != '{}' else '{"' ~ key ~ '": ' ~ value | string ~ '}' %}
                {% endif %}
              {% endfor %}
            {% endif %}
            
            {{ ns.values_dict }}

then results in the preview:

mini-map

Your first code block above contains incorrect quotes, and does not define a dictionary in the attribute, just a string. You need this to define the dictionary as a Jinja template:

template:
  - sensor:
      - name: Solar forecast values today
        state: >
          {{ "Values found " ~ now().strftime('%d.%m.%Y %H:%M:%S') }}
        attributes:
          dict_attribute: >
            {{ {
                 "value_1": 53,
                 "value_2": 64,
                 "value_3": 72
            } }}

or for a YAML dictionary structure, use:

          dict_attribute: 
            value_1: 53
            value_2: 64
            value_3: 72

I think your final graph is now working, isn’t it? It’s showing values from 0 to 5.3 as you’d expect, and you just need to wait for new values to have a meaningful graph plotted?

ahhrrrrggghhh… I’ve lost my way.

That was a way for ONE line.
The documentary sucks.
You can see a graph or a progression curve.

Then I’ll try my hand at LIST elements. :frowning:

Oh! You’re trying to plot those values as data points on the same curve? I don’t think it works like that: none of the documentation examples shows that. You need to have the values stored in HA at those specific times in its database.

Perhaps explain where the data’s coming from and what you’re trying to achieve?

:face_with_spiral_eyes:

ahhhh… THAT explains why I can’t get any further.

This is solar yield data. (Forecasts.)
They come from a JSON interface.

I don’t want them in the DB under any circumstances, because the forecast is queried every 15 minutes and is constantly changing.

That’s what it’s supposed to be.
1 over all (as in the picture) and once the daily curve.

But then it won’t work with any template in HA?
It doesn’t have to be a mini-map.

Thanks for your previous statement. THAT saves me further pointless hours

Plotly.

nope… I can hardly get any further here either.

Sometimes I have to use static values to get anything at all.

template:
  - sensor:
      - name: Solarprognose Werte Heute
        state: >
          {{ 0 }}  # Der Zustand bleibt eine Zahl
        attributes:
          timestamps: >
            ['08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00']
          values: >
            [0, 0.223, 1.421, 3.266, 4.659, 5.296, 3.991, 0]

Plotys Code:

type: custom:plotly-graph
entities:
  - sensor.solarprognose_werte_heute
layout:
  title: Solarprognose (kW)
  xaxis:
    title: Uhrzeit
    type: category
  yaxis:
    title: Leistung (kW)
    type: linear
    range: [0, 6] 
traces:
  - type: scatter
    mode: lines+markers
    name: Solarprognose
    x: "{{ state_attr('sensor.solarprognose_werte_heute', 'timestamps') }}"
    y: "{{ state_attr('sensor.solarprognose_werte_heute', 'values') }}"

Results in a suitable Y +X axis. But no value
grafik

minmal Plotys: Y axis wrong

type: custom:plotly-graph
entities:
  - entity: sensor.solarprognose_werte_heute


Do you have a template for me with 2-3 numbers that somehow shows a hill-curve?

I don’t, sorry: I’ve never used it. Perhaps post in its topic here:

:smiley: No its not… Stop blaming it on a bug or documentation… :smiling_face_with_tear: