Since_last_boot gone, now how to?

They do appear first time. I’m on a powerful system and a semi new phone though.

Mine’s not bad…
image

Hmmm… same system. What are you using for your DB?

Standard SQL Lite I’m afraid…
Could that make a difference?

Well that seems to be the difference between our setups. I use maria db on a separate server.

It just feels more like a frontend ‘issue’ to me.
Pressing F5 makes the lines disappear.
Simply navigating away to another tab and then back again makes them reappear.

I’m not losing too much sleep over this. It’s just a bit annoying…

Ok, so I just checked, and yes. I’m actually having the same issue. I was going off memory before. This must be new in .111

I’m still on .110

So i’m rejiggering the card. It has something to do with using the elements card to display the graph. I’m in the process of moving the card into the button card. Romrider fixed an update issue so we don’t need to use picture elements anymore. I’ll post the card when I’m done. Currently, it look’s like it’s loading instantly when all inside 1 card.

Ok, here it is. I renamed aspect to aspect_ratio to conform with the rest of my UI. You no longer need the transparent image either.

# lovelace_gen

{% set color = color|default('var(--paper-item-icon-active-color)') %}
{% set aspect_ratio = aspect_ratio|default('1/1') %}

type: custom:button-card
aspect_ratio: {{ aspect_ratio }}
entity: {{ entity }}
icon: {{ icon }}
color: var(--paper-item-icon-color)
show_name: true
show_label: true
show_icon: true
show_last_changed: true
size: 70%
tap_action:
  action: more-info
  haptic: light
styles:
  icon:
  - opacity: 0.3
  - width: 100%
  img_cell:
  - top: 0%
  - left: 30%
  - position: absolute
  - z-index: 2
  grid:
  - grid-template-areas: '"info info" "n n" "l l"'
  - grid-template-columns: 40% 1fr
  - grid-template-rows: 1fr min-content min-content
  - position: relative
  card:
  - padding: 10px
  - border-radius: 15px
  - z-index: 0
  name:
  - justify-self: start
  - align-self: end
  - font-weight: bold
  - font-family: Helvetica 
  - font-size: 12px
  - text-align: start
  - background-image: linear-gradient(to right, white 0%, white 80%, rgba(0,0,0,0))
  - -webkit-background-clip: text
  - -webkit-text-fill-color: transparent
  - position: relative
  - display: inline-block
  - width: 100%
  - align-content: start
  - text-align: start
  - text-overflow: unset
  - z-index: 5
  label:
  - justify-self: start
  - align-self: end
  - font-weight: bold
  - font-family: Helvetica 
  - font-size: 12px
  - text-align: start
  - background-image: linear-gradient(to right, var(--paper-item-icon-color) 0%, var(--paper-item-icon-color) 80%, rgba(0,0,0,0))
  - -webkit-background-clip: text
  - -webkit-text-fill-color: transparent
  - position: relative
  - display: inline-block
  - width: 100%
  - align-content: start
  - text-align: start
  - text-overflow: unset
  - z-index: 5
  custom_fields:
    plot:
    - position: absolute
    - top: 55%
    - left: 50%
    - width: calc(100% + 25px)
    - transform: translate(-50%, calc(-50% + 10px))
    - z-index: 3
    - --paper-card-background-color: 'rgba(0, 0, 0, 0.0)'
    - --ha-card-background: "rgba(0, 0, 0, 0.0)"
    - --ha-card-box-shadow: 'none'
    - pointer-events: none
    info:
    - align-self: start
    - width: 40%
    - z-index: 5
custom_fields:
  plot:
    card:
      type: custom:mini-graph-card
      entities:
        - {{ entity }}
      group: true
      points_per_hour: 1
      hour24: true
      line_color: {{ color }}
      line_width: 10
      hours_to_show: 24
      update_interval: 600
      show:
        name: false
        icon: false
        state: false
        points: false
        legend: false
        average: false
        extrema: false
        labels: false
        fill: false
        labels_secondary: false
        name_adaptive_color: false
        icon_adaptive_color: false
  info: >
    [[[
      var entity_id = (entity === undefined) ? 'Invalid Entity' : entity.entity_id;
      var statestr = (entity === undefined || entity.state === undefined) ? null : entity.state;
      var units = (statestr && entity.attributes.unit_of_measurement) ? entity.attributes.unit_of_measurement : null;
      var date = (statestr && entity.attributes.device_class === 'timestamp') ? new Date(statestr) : null;
      var value;
      if (statestr && date === null) {
        if (statestr.split('.').length - 1 <= 1){
          var test = parseFloat(parseFloat(statestr).toFixed(2));
          value = (isNaN(test)) ? null : test;
          // test if units are in the state because some sensors are stupid.  Looking
          //   at you synology.
          const expr = /[^-.0-9]+/;
          var has_units = expr.test(statestr.trim());
          // console.log(`${entity_id}: "${statestr}" ${matches}`);
          if (value && has_units)
            units = statestr.replace(/[.0-9]+/, ''); 
        }
      }
      // console.log(`${entity_id}: ${statestr}, ${units}, ${date}, ${value}`);
      const length = 50;
      const width = 3;
      var radius = length / 2;
      if (date){
        let now = new Date();
        var tdelta = Math.floor((now - date)/1000);
        // console.log(`${entity_id}: ${tdelta}`);
        function plural(descriptor, divisor){
          var ret = Math.floor(tdelta/divisor);
          return (ret == 1) ? [ret, descriptor] : [ret, `${descriptor}s`];
        }
        var values;
        if (tdelta < 60)
          values = plural('second', 1);
        else if (tdelta < 60 * 60)
          values = plural('minute', 60);
        else if (tdelta < 60 * 60 * 24)
          values = plural('hour', 60 * 60);
        else if (tdelta < 7 * 60 * 60 * 24)
          values = plural('day', 60 * 60 * 24);
        else
          values = plural('week', 7 * 60 * 60 * 24);
        return `
          <svg viewBox="0 0 50 50">
            <circle cx="25" cy="25" r="${radius}" fill="{{ color }}" />
            <text x="50%" y="43%" fill="var(--paper-card-background-color)" font-weight="bold" font-size="14" text-anchor="middle" alignment-baseline="middle">${values[0]}<tspan x="50%" dy="1.2em" font-size="10" font-weight="normal" >${values[1]}</tspan>
            </text>
          </svg>
          `;
      }
      else if (value && units && units === '%') {
        radius = (length - 3) / 2;
        const circumference = radius * 2 * Math.PI;
        return `
          <svg viewBox="0 0 50 50">
            <circle cx="25" cy="25" r="${radius}" fill="none" stroke="var(--paper-item-icon-color)" opacity="0.5" stroke-width="${width}" />
            <circle style="
                transform: rotate(-90deg);
                transform-origin: 50% 50%;
                stroke-dasharray: ${circumference};
                stroke-dashoffset: ${circumference - value / 100 * circumference};
              "
              id="c_brightness" cx="25" cy="25" r="${radius}" stroke="var(--paper-item-icon-active-color)" stroke-width="${width}" fill="none" stroke-linecap="round" />
            <text x="50%" y="54%" fill="var(--primary-text-color)" font-weight="bold" font-size="14" text-anchor="middle" alignment-baseline="middle">${value}<tspan font-size="10" font-weight="normal" >%</tspan>
            </text>
          </svg>
          `;
        }
      else if (value && units && units.includes('°')) {
        return `
          <svg viewBox="0 0 50 50">
            <circle cx="25" cy="25" r="${radius}" fill="{{ color }}" />
            <text x="50%" y="54%" fill="var(--paper-card-background-color)" font-weight="bold" font-size="14" text-anchor="middle" alignment-baseline="middle">${value}<tspan font-size="10" font-weight="normal" >${units}</tspan>
            </text>
          </svg>
          `;
      }
      else if (value && units && units.length > 1) {
        var y = (String(value).length > units.length) ? "50%" : "43%";
        return `
          <svg viewBox="0 0 50 50">
            <circle cx="25" cy="25" r="${radius}" fill="{{ color }}" />
            <text x="50%" y="${y}" fill="var(--paper-card-background-color)" font-weight="bold" font-size="14" text-anchor="middle" alignment-baseline="middle">${value}<tspan x="50%" dy="1.2em" font-size="10" font-weight="normal" >${units}</tspan>
            </text>
          </svg>
          `;
        }
      else if (value) {
        return `
          <svg viewBox="0 0 50 50">
            <circle cx="25" cy="25" r="${radius}" fill="{{ color }}" />
            <text x="50%" y="54%" fill="var(--paper-card-background-color)" font-weight="bold" font-size="14" text-anchor="middle" alignment-baseline="middle">${value}<tspan font-size="10" font-weight="normal" >${units}</tspan>
            </text>
          </svg>
          `;
      }
      return `
          <svg viewBox="0 0 50 50">
            <circle cx="25" cy="25" r="${radius}" fill="{{ color }}" />
            <text x="50%" y="54%" fill="var(--paper-card-background-color)" font-weight="bold" font-size="14" text-anchor="middle" alignment-baseline="middle">${statestr}
            </text>
          </svg>
          `; 
    ]]]
1 Like

Nice…
Thanks.

FYI theres a visual History bug that will be fixed in .111.3. Might have caused the problems.

Except as I said, I’m on 110.
In any case your new implementation is a lot cleaner!

Right but I don’t know how far the history bug goes back. I can only state that it wasn’t in 110.3