Giter Club home page Giter Club logo

flex-horseshoe-card's Introduction

Personal Note, april 2023

Getting up to speed again with my custom cards after some difficult years!

First commit is compatibility for Home Assistant 2023.4. I missed that one in my testcard view. For some reason I fixed the HA version to some 2023.3 version in my docker compose file. And in that case you can docker compose pull but nothing is updated...


hacs_badge GitHub release (latest by date) GitHub Release Date

Flexible Horseshoe Card

Flexible looks-like-a-horseshoe card for Home Assistant Lovelace UI

The Lovelace view of the above examples is in the repository in the examples folder.
So you can see how these layouts are done


v0.8.0 is the first public release of this card. Be gentle with it!


Introduction

The flexible horseshoe card can display data from entities and attributes from the sensor and other domains. It displays the current state and for the primary entity it fills the horseshoe with a color depending on the min and max values of the state and the configured color stops and styling.

The main perk of this card is it's flexibility. It is able to position a number of things where YOU want it using a layout specification for each object you want on the card:

Feature Description
Any number of entities For each entity, the attribute, units, icon, name, area and tap action can be specified.

There is currently no limit imposed on the number of entities in this card. I'm using max. 3 entities in the examples, but there is no problem using more.
Any number of circles, horizontal and vertical lines To function as a divider between values or background for values.
The layout of the card You can specify each object with a relative position on the card
Animations, dynamic behaviour You can specify what happens if an entity changes state like change color, or execute a CSS animation. There are predefined animations.
Several ways to color the horseshoe From single, fixed color, to a gradient depending on a list of colorstops
Actions Handle click actions per entity to for instance switch a light on/off

Table of contents


Some examples

Normal, flat UI

Cards in a standard vertical stack / horizontal stack - 2 cards per row - combination.

Legend:

  • (3), showing a single attribute from a darksky sensor, a unit (temperature), an area and horizontal line
  • (4), showing three attributes from a darksky sensor (temperature, humidity and air pressure), units, two icons, a name and a horizontal line
  • (5), showing three sensors from system monitoring (ram used, ram used percentage and ram free), two sensor names ("in use" and "free"), a horizontal line and a vertical line.
  • (6), same as (5), bit with different horizontal and vertical line and different fill style for the horseshoe.

All cards use different styling for filling the horseshoe with a color.

Some extreme, industrial look, 3D UI

Using the same cards as above, but with a predefined set of filters applied. In this case the card--dropshadow-heavy--sepia90 class filter for the card_filter variable.

Again, cards in a standard vertical stack / horizontal stack - 2 cards per row - combination.

Another Example

It scales, as it is based on SVG

Using a single card in a row. Card scales to maximum width of the vertical stack card. No changes required for text size, icons, lines and state & attribute values. All thanks to SVG.

Yes, you can interact with it. Switching lights is no problem!

For each entity a tap_action can be defined. The default is the known show-more info dialog. This can be changed in executing a service for instance.

Combined with animations and states, you can alter the appearance of objects. The card containts a list of predefined animations, or you just create your own!

Install

Install via HACS

hacs_badge

Manual install

  1. Download and copy flex-horseshoe-card.js from github into your config/www directory.

  2. If using the editor UI: Add a reference to flex-horseshoe-card.js inside your ui-lovelace.yaml or at the top of the raw config editor UI.

  3. If using yaml mode, add a reference in the resources.yaml file that is !included in your ui-lovelac.yaml file

resources:
- url: /community_plugin/flex-horseshoe-card/flex-horseshoe-card.js
  type: module

Using the card

The preferred method of using this card is by decluttering card templates. You define the layout and default options in this template and use the template in your Lovelace config. This config stays clean this way: you only specify the entities, attributes, units and icons which are displayed according to the layout defined in the template.

The advice will become obvious once you scroll throught the list of card options 😄

A basic example

This is the card 1 of the examples. It shows the basic definition for the flexible horseshoe card using the darksky sensor with the temperature attribute and its unit and decimals.

- type: 'custom:flex-horseshoe-card'
  entities:
    - entity: weather.dark_sky
      attribute: temperature
      decimals: 1
      unit: '°C'
      area: De Maan
  show:
    horseshoe_style: 'lineargradient'
  layout:
    states:
       # Refers to the first entity in the list, ie index 0
       # State value is positioned at (50%,60%) with a large font size
       # The size of the units are automatically calculated at 60% of the
       # state value font size and shifted upwards.
       # The default font color is the theme defined primary-text-color.
      - id: 0
        entity_index: 0
        xpos: 50
        ypos: 60
        styles:
          - font-size: 3.5em;
    areas:
       # Refers to the first entity in the list, ie index 1
       # Area value is positioned at (50%,35%) with font-size 1.5 and
       # an opacity of 80%.
       # The default font color is the theme defined primary-text-color.
      - id: 0
        entity_index: 0
        xpos: 50
        ypos: 35
        styles:
          - font-size: 1.5em;
          - opacity: 0.8;

  # Scale set to -10 to +40 degrees celcius
  horseshoe_scale:
    min: -10
    max: 40
  # color stop list with two colors. With the `lineargradient` fill style, only the
  # colors are used. The thresholds are ignored with this setting.
  color_stops:
    10: 'red'
    18: 'blue'

Extending the basic example with two more entities and a horizontal line

This is card 4 of the examples. It extends the basic definition of card 1 with two more attributes from the darksky sensor and adds a horizontal line as a divider. We also swap the area with the name of the first entity.

- type: 'custom:flex-horseshoe-card'
  entities:
    - entity: weather.dark_sky
      attribute: temperature
      decimals: 1
      name: '4: Ut Weer'
      unit: '°C'
    - entity: weather.dark_sky
      attribute: humidity
      decimals: 0
      unit: '%'
      icon: mdi:water-percent
    - entity: weather.dark_sky
      attribute: pressure
      decimals: 0
      unit: 'hPa'
      icon: mdi:gauge
  show:
    horseshoe_style: 'lineargradient'
  layout:
    hlines:
      # A horizontal line. Not connected to an entity
      - id: 0
        xpos: 50
        ypos: 42
        length: 40
        styles:
          - stroke: var(--primary-text-color);
          - stroke-width: 5;
          - stroke-linecap: round;
          - opacity: 0.7;
    states:
      # States 0 refers to the first entity in the list, ie index 0
      - id: 0
        entity_index: 0
        xpos: 50
        ypos: 34
        styles:
          - font-size: 3em;
      # States 1 refers to the second entity in the list, ie index 1
      - id: 1
        entity_index: 1
        xpos: 40
        ypos: 57
        styles:
          - text-anchor: start;
          - font-size: 1.5em;
      # States 2 refers to the third entity in the list, ie index 2
      - id: 2
        entity_index: 2
        xpos: 40
        ypos: 72
        styles:
          - text-anchor: start;
          - font-size: 1.5em;
    icons:
      # Icons 0 refers to the second entity in the list, ie index 1
      - id: 0
        entity_index: 1
        xpos: 37
        ypos: 57
        align: end
        size: 1.3
      # Icons 1 refers to the third entity in the list, ie index 2
      - id: 1
        entity_index: 2
        xpos: 37
        ypos: 72
        align: end
        size: 1.3
    names:
      # Names 0 refers to the first entity in the list, ie index 0
      - id: 0
        entity_index: 0
        xpos: 50
        ypos: 95
    
  # Scale set to -10 to +40 degrees celcius
  horseshoe_scale:
    min: -10
    max: 40
  # color stop list with 10 colors defined in the theme. With the `lineargradient` fill style, only the
  # first (16:) and last (25:) colors are used. The thresholds are ignored with this setting.
  color_stops:
    16: '#FFF6E3'
    17: '#FFE9B9'
    18: '#FFDA8A'
    19: '#FFCB5B'
    20: '#FFBF37'
    21: '#ffb414'
    22: '#FFAD12'
    23: '#FFA40E'
    24: '#FF9C0B' 
    25: '#FF8C06' 

Extending the basic example with a lot more options like actions and animations

This is the card 12 of the examples. It displays the wattage (memory sensor is used for this value) and the state of two lights. Both ligts can be switched on and off. The left light uses a predefined animation (yello and zoomout), the right light uses a user defined animation.

Let's see how that looks 😄

- type: 'custom:flex-horseshoe-card'
  entities:
    # Abuse the memory_use_percent sensor as the wattage the bulbs use. Just to show the possibilities
    - entity: sensor.memory_use_percent
      decimals: 0
      name: '12: Two Bulbs'
      area: Hestia
      unit: W
      decimals: 0
      tap_action:
        action: more-info

    # The left light displayed on the card. Index 1
    - entity: light.1st_floor_hall_light              
      name: 'hall'
      icon: mdi:lightbulb
      tap_action:
        action: call-service
        service: light.toggle
        service_data: { "entity_id" : "light.1st_floor_hall_light" }

    # The right light displayed on the card. Index 2
    - entity: light.gledopto
      name: 'opto'
      icon: mdi:lightbulb
      tap_action:
        action: call-service
        service: light.toggle
        service_data: { "entity_id" : "light.gledopto" }

  animations:
    # Animations for the second entity, index 1
    entity.1:
      - state: 'on'
        circles:
          - animation_id: 11
            styles:
              - fill: var(--theme-gradient-color-03);
              - opacity: 0.9;
              - transform-origin: 30% 50%;
              - animation: jello 1s ease-in-out both;
        icons:
          - animation_id: 10
            styles:
              - fill: black;
      - state: 'off'
        circles:
          - animation_id: 11
            reuse: true
            styles:
              - transform-origin: 30% 50%;
              - animation: zoomOut 1s ease-out both;
        icons:
          - animation_id: 10
            styles:
              - fill: var(--primary-text-color);

    # Animations for the third entity, index 2
    entity.2:
      - state: 'on'
        circles:
          - animation_id: 21
            styles:
              - fill: var(--theme-gradient-color-03);
              - stroke-width: 2;
              - stroke: var(--primary-background-color);
              - opacity: 0.9;
              - stroke-dasharray: 94;
              - stroke-dashoffset: 1000;
              - animation: stroke 2s ease-out forwards;

        icons:
          - animation_id: 20
            styles:
              - fill: black;

      - state: 'off'
        circles:
          - animation_id: 21
            styles:
              - fill: var(--primary-background-color);
              - opacity: 0.7;
        icons:
          - animation_id: 20
            styles:
              - fill: var(--primary-text-color);

  show:
    horseshoe_style: 'fixed'
  layout:
    states:
      - id: 0
        entity_index: 0
        animation_id: 0
        xpos: 50
        ypos: 28
        uom_font_size: 1.5
        styles:
          - font-size: 2.5em;
          - opacity: 0.9;
    names:
      - id: 0
        animation_id: 0
        entity_index: 0
        xpos: 50
        ypos: 100
        styles:
          - font-size: 1.2em;
          - opacity: 0.7;
      - id: 1
        animation_id: 1
        entity_index: 1
        xpos: 30
        ypos: 78
        styles:
          - font-size: 1.2em;
      - id: 2
        animation_id: 2
        entity_index: 2
        xpos: 70
        ypos: 78
        styles:
          - font-size: 1.2em;
    icons:
      - id: 0
        animation_id: 10
        xpos: 30
        ypos: 55
        entity_index: 1
        icon_size: 3.5
        styles:
          - color: var(--primary-text-color);;
      - id: 1
        animation_id: 20
        xpos: 70
        ypos: 55
        entity_index: 2
        icon_size: 3.5
        styles:
          - color: var(--primary-text-color);;
    circles:
      - animation_id: 3
        xpos: 30
        ypos: 50
        radius: 35
        styles:
          - fill: var(--primary-background-color);
      - animation_id: 11
        xpos: 30
        ypos: 50
        radius: 30
        entity_index: 1

      - animation_id: 2
        xpos: 70
        ypos: 50
        radius: 35
        styles:
          - fill: var(--primary-background-color);
      - animation_id: 21
        xpos: 70
        ypos: 50
        radius: 30
        entity_index: 2

  horseshoe_scale:
    min: 0
    max: 100
    color: 'var(--primary-background-color)'
  horseshoe_state:
    color: '#FFDA8A'
  color_stops:
    0: '#FFF6E3'
    10: '#FFE9B9'
    20: '#FFDA8A'
    30: '#FFCB5B'
    40: '#FFBF37'
    50: '#ffb414'
    60: '#FFAD12'
    70: '#FFA40E'
    80: '#FF9C0B' 
    90: '#FF8C06' 
  # The @keyframes stroke runs the stroke animation for the second lightbulb, entity light.gledopto
  style: |
    @keyframes stroke { to { stroke-dashoffset: 0; } }

Card Options

Main Card required, defaulted and pure optional sections

The Card Options are divided into Sections. To give a clear overview of which of the sheer number of sections are required, optional with defaults and optional, the following table is made.

The examples section shows 12 examples of card definitions, from basic to using all available options!

Note: The examples will get decluttering templates as an example too, to show how you can better manage and maintain the all the card layouts without loosing overview in the Lovelace views.

Each section might have it's own required, defaulted and optional properties.

Name Required Optional /w
defaults
Optional Since Description
type v0.8.0 custom:flex-horseshoe-card.
entities v0.8.0 One or more sensor entities in a list. See entities section for requirements.
layout v0.8.0 You MUST of course specify where each item is positioned on the card. See available layout options for requirements.
horseshoe_scale some v0.8.0 Specifies the scale configuration, like min, max, width and color of the scale. See horseshoe scale for requirements.
color_stops v0.8.0 Set thresholds for horseshoe gradients and colormapping. See color stops for requirements.
horseshoe_state v0.8.0 Specifies the horseshoe width, and fixed color. See horseshoe state for requirements.
show v0.8.0 Determines what is shown, like the scale and the horseshoe style. See available show options for requirements.
card_filter v0.8.0
entities tap_action v0.8.0 How to respond to a mouse-click or tap. See available tap actions for requirements.
animations v0.8.0 You can specify animations / dynamic behaviour depending on the state of an entity. Circles, lines and icons can be controlled depending on the state of a given entity. See available animation options for requirements.

Entities section

Available entity options

Name Type Default Since Description
attribute string optional v0.8.0 The attribute to be used for the entity.
unit string optional v0.8.0 Specifies the entity or attribute unit to be displayed.
decimals number optional v0.8.0 Specifies the decimals to format the entity or attribute value.
name string optional v0.8.0 Name used for entity or attribute. Overwrites the friendly_name attribute.
area string optional v0.8.0 Area used for entity or attribute.
tap_action action object optional v0.8.0 How to respond to a mouse-click or tap. See available tap actions for requirements.

Example 1, displaying an entity:

entities:
  - entity: sensor.memory_use_percent
    decimals: 0
    icon: mdi:memory
    name: '5: RAM Usage'
    area: Hestia

Example 2, displaying an attribute:

entities:
  - entity: weather.dark_sky
    attribute: temperature
    units: '°C'
    icon: mdi:temperature
    decimals: 1
    name: 'Temperature'

Action object options

(changed to be identical to mini graph card)

Name Type Default Options Since Description
action string more-info more-info, navigate, call-service, none v0.8.0 Action to perform
service string none Any service v0.8.0 Service to call (e.g. media_player.toggle) when action is defined as call-service
service_data object none Any service data v0.8.0 Service data to include with the service call (e.g. entity_id: media_player.office)
navigation_path string none Any path v0.8.0 Path to navigate to (e.g. /lovelace/0/) when action is defined as navigate

Example 3: a light switch:

entities:
  - entity: light.1st_floor_hall_light
    name: 'hall'
    icon: mdi:lightbulb
    tap_action:
      action: call-service
      service: light.toggle
      service_data: { "entity_id" : "light.1st_floor_hall_light" }

Layout section

Available layout options

The layout options determine where the objects are located on the card, and their initial appearance like font, font size, color, width, fill color, stroke color, etc.

Name Type Default Since Description
Layout object layout object required v0.8.0 Entity objects:
  • states for displaying a entity or attribute value
  • names for the name of the entity
  • icons for the entity icons
Graphic objects:
  • circles for circles
  • hlines and vlines for drawing lines.

Layout object options

Name Type Default Options Since Description
id number not used yet v0.8.0 Identifies the object.
xpos percentage required percentage 0..100 v0.8.0 Relative x-position in card. A value of 50 (%) places the object in the middle of the x-axis
ypos percentage required percentage 0..100 v0.8.0 Relative y-position in card. A value of 50 (%) places the object in the middle of the y-axis
length
(lines only)
percentage required percentage 0.100 v0.8.0 Relative length of a line. A value of 50 (%) means the line is half the size of the card's width
radius
(circles only)
pixels required > 1 / < 200 v0.8.0 Specifies the radius of the circle in pixels.
icon_size
(icons only)
em value required a value of 1 = 12px v0.8.0 Specifies the size of the icon in em units. A calculation takes care of positioning the icon
align
(icons only)
position middle start/ middle/ end v0.8.0 Specifies the alignment of the icon relative to the xpos and ypos. Functions idential to the text-anchorcss property. Used in positioning calculations for the icon.
entity_index number required N/A v0.8.0 Refers to the 0-based index in the entity list which the layout is connected to
animation_id number optional an Id v0.8.0 Identifies an animation in the animations section. It connects this layout object with dynamic behaviour
styles list optional any valid css entry v0.8.0 specify a list of css values to style the object. Must be terminated with a semicolon ;

Example layout entry

The following layout is a part of card 5. For more complete examples, see the examples section

Another Example

  • xpos, ypos and length are percentages
  • state layout 0 is connected to entity 0, ie the first entity in the entities section
  • name layout 0 is also connected to entity 0
layout:
  hlines:
    - id: 0
      xpos: 50
      ypos: 38
      length: 40
      styles:
        - stroke: var(--theme-gradient-color-01);
        - stroke-width: 5;
        - opacity: 0.9;
        - stroke-linecap: round;
  vlines:
    - id: 0
      xpos: 50
      ypos: 56
      length: 20
      styles:
        - stroke: white;
        - opacity: 0.5;
        - stroke-width: 2;
        - stroke-linecap: round;
  states:
    - id: 0
      entity_index: 0
      xpos: 50
      ypos: 30
      styles:
        - font-size: 3em;
        - opacity: 0.9;
  names:
    - id: 0
      entity_index: 0
      xpos: 50
      ypos: 100
      styles:
        - font-size: 1.2em;

Horseshoe section

Horseshoe scale options

Name Type Default Options Since Description
min number required v0.8.0 Minimum value of the scale / horseshoe
max number required v0.8.0 Maximum value of the scale / horseshoe
color color var(--primary-background-color) any # or var color v0.8.0 Color of the scale and tickmarks, if enabled through show.scale_tickmarks option.
width pixels 6 size in pixels v0.8.0 Width of scale

Example:

horseshoe_scale:
  min: 0
  max: 100
  width: 6
  color: 'var(--primary-background-color)'

Horseshoe state options

Name Type Default Options Since Description
color color required any valid color v0.8.0 Color of horseshoe if show.horseshoe_style = fixed
width pixels 12 size in pixels v0.8.0 Width of horseshoe

Example:

horseshoe_state:
  width: 12
  color: 'var(--theme-gradient-color-01)'

Horseshoe color stops

Name Type Default Options Since Description
color_stops list required v0.8.0 List of colorstop value and colors. Colors can be specified using:
  • A standard hex #RRGGBB color
  • An RGB() or RGBA() color
  • A HSL()or HSLA() color
  • A named CSS color, ie white
  • A css variable defined in the theme, ie something like var(--color)

Example:

Showing a list of colorstop thresholds (0..90) and the colorstop colors, in this case a gradient colorlist from the theme

color_stops:
  0: 'var(--theme-gradient-color-01)'
  10: 'var(--theme-gradient-color-02)'
  20: 'var(--theme-gradient-color-03)'
  30: 'var(--theme-gradient-color-04)'
  40: 'var(--theme-gradient-color-05)'
  50: 'var(--theme-gradient-color-06)'
  60: 'var(--theme-gradient-color-07)'
  70: 'var(--theme-gradient-color-08)'
  80: 'var(--theme-gradient-color-09)'
  90: 'var(--theme-gradient-color-10)'

Horseshoe fill styles

The horseshoe can be filled in different ways. Almost all use the color_stop colors to determine the color of the horseshoe. Not all use the actual color_stop thresholds to determine the color, but just use the color_stop colors.

The next table describes how the fill styles work:

Option Requires uses color_stop threshold Uses entity value Since Description
autominmax color_stops list with at least 2 values uses min and max of scale v0.8.0 Autominmax uses the min and max values to calculate a gradient color using the first and last color in the colorstop list and the actual value of the entity or attribute.
fixed horseshoe_state .color v0.8.0 Fills the shoe with a single color
colorstop color_stops list with at least 2 values v0.8.0 Fills the shoe with the colorstop color depending on the colorstop value and the value of the state
colorstopgradient color_stops list with at least 2 values v0.8.0 Same as colorstop, but a gradient is used between colorstops
lineargradient color_stops list with at least 2 values v0.8.0 Uses the first and last entry in the color_stops list to display a linear gradient. It always shows the full gradient from start to end color, independent of the states value.

The fill style is set in the show section of the card:

show:
  horseshoe_style: 'lineargradient'

Animations section

Available animation options

Animations are optional, and are driven by state changes of a given entity or attribute.

Name Type Default Since Description
entity. string required v0.8.0 Entity index (zero based) which triggers the animation. In the form of entity.1 for the SECOND entity in the entity list. If an attribute is specified, the attribute triggers the animation.
state string required v0.8.0 specifies the state like 'on', or 'off' the animation is meant for
circles, hlines, vlines, icons list required v0.8.0 list of objects with animations

Available circle, hline, vline, icon animation styles

Name Type Default Since Description
animation_id number required v0.8.0 the unique (for this card) animation_id. Is also referred to by the layout.
styles css properties list required v0.8.0 list of pure css styles for this object. MUST contain a ';' at the end of the line!
reuse boolean false v0.8.0 Default the previous animation style is cleared. By setting reuse to true, the previous animation style is preserved by the new animation. This can be handy if this animation starts where the previous animation left off.
For instance a color: the 'on' state sets the circle to orange. The 'off' state keeps the color, but zooms out.

Predefined animations

Name Type Since Example definition in the styles section of the animation
bounce attention v0.8.0 styles:
- animation: bounce 1s ease-in-out both;
- transform-origin: center bottom;
flash attention v0.8.0 styles:
- animation: flash 1s ease-in-out both;
- transform-origin: center;
headShake attention v0.8.0 styles:
- animation: headShake 1s ease-in-out both;
- transform-origin: center;
heartBeat attention v0.8.0 styles:
- animation: heartBeat 1.3s ease-in-out both;
- transform-origin: center;
jello attention v0.8.0 styles:
- animation: jello 1s ease-in-out both;
- transform-origin: center;
pulse attention v0.8.0 styles:
- animation: pulse 1s ease-in-out both;
- transform-origin: center;
rubberBand attention v0.8.0 styles:
- animation: rubberBand 1s ease-in-out both;
- transform-origin: center;
shake attention v0.8.0 styles:
- animation: shake 1s ease-in-out both;
- transform-origin: center;
swing attention v0.8.0 styles:
- animation: swing 1s ease-in-out both;
- transform-origin: top center;
tada attention v0.8.0 styles:
- animation: tada 1s ease-in-out both;
- transform-origin: center;
wobble attention v0.8.0 styles:
- animation: wobble 1s ease-in-out both;
- transform-origin: center;
zoomOut zooming v0.8.0 styles:
- animation: zoomOut 1s ease-out both;
- transform-origin: center;
zoomIn zooming v0.8.0 styles:
- animation: zoomIn 1s ease-out both;
- transform-origin: center;

Example of animation for card 11:

- type: 'custom:flex-horseshoe-card'
  entities:
    - entity: sensor.memory_use_percent
    - entity: light.1st_floor_hall_light              
  animations:
    entity.1:
      - state: 'on'
        circles:
          - animation_id: 10
            styles:
              - fill: var(--theme-gradient-color-08);
              - opacity: 0.9;
              - animation: jello 1s ease-in-out both;
              - transform-origin: center;
        icons:
          - animation_id: 0
            styles:
              - fill: black;
      - state: 'off'
        circles:
          - animation_id: 10
            reuse: true
            styles:
              - transform-origin: center;
              - animation: zoomOut 1s ease-out both;
        icons:
          - animation_id: 0
            styles:
              - fill: var(--primary-text-color);

User defined animations

You can define your own animations too. Pick a unique name, add the animation to the style: section of the card, and off you go. Example Card 12, the bulb named "OPTO" has such a user defined animation: you see something running around if the light is switched on.

There are at least a few great places for example animations:

Example of Card 12

- type: 'custom:flex-horseshoe-card'
  entities:
    - entity: sensor.memory_use_percent
    - entity: light.1st_floor_hall_light              
    - entity: light.gledopto

  animations:
    entity.2:
      - state: 'on'
        circles:
          - animation_id: 3
            styles:
              - fill: var(--theme-gradient-color-03);
              - stroke-width: 2;
              - stroke: var(--primary-background-color);
              - opacity: 0.9;
              - stroke-dasharray: 94;
              - stroke-dashoffset: 1000;
              - animation: stroke 2s ease-out forwards;

        icons:
          - animation_id: 1
            styles:
              - fill: black;

      - state: 'off'
        circles:
          - animation_id: 3
            styles:
              - fill: var(--primary-background-color);
              - opacity: 0.7;
        icons:
          - animation_id: 1
            styles:
              - fill: var(--primary-text-color);
  # The @keyframes stroke runs the stroke animation for the second lightbulb, entity light.gledopto
  style: |
    ha-card {
      box-shadow: var(--theme-card-box-shadow);
    }
    @keyframes stroke { to { stroke-dashoffset: 0; } }

Show section

Available show options

All options are optional.

Name Default Parameter Since Description
scale_tickmarks true true / false v0.8.0 Display scale
horseshoe_style autominmax fixed / autominmax/ colorstop / colorstopgradient/ lineargradient v0.8.0 Fill style. Most fill styles need the colorstop list to be specified. See horseshoe fill style list for a description.

Card Filter section

There are some predefined css filters which you can use to give the full card a different look. Besides the predefined, you can also define you rown using the style: section of the yaml card definition and refer to that class as the card_filter:

Name Default Parameter Since Description
card_filter card--dropshadow-none card--dropshadow-none/ card--dropshadow-medium--opaque--sepia90 / card--dropshadow-heavy--sepia90 / card--dropshadow-heavy / card--dropshadow-medium--sepia90/ card--dropshadow-medium / card--dropshadow-light--sepia90 / card--dropshadow-light / card--dropshadow-down-and-distant v0.8.0 List of drop-shadows and sepia colorization using css filters on the full card.

Currently only tested on the darkslategrey / wheat Nyx theme

Examples section

The full view with all 12 examples is in the examples folder of this repository.

Three examples are included in this readme for easy access. Most examples use the Darksy sensor or the Home Assistant system monitor. A few use lights, which you have to replace with your own of course.

Furthermore, theme defined variables are used:

  theme-card-box-shadow: 'var(--shadow-elevation-2dp_-_box-shadow)'

and:

  theme-gradient-color-01: '#FFF6E3'
  theme-gradient-color-02: '#FFE9B9'
  theme-gradient-color-03: '#FFDA8A'
  theme-gradient-color-04: '#FFCB5B' 
  theme-gradient-color-05: '#FFBF37' 
  theme-gradient-color-06: '#ffb414' 
  theme-gradient-color-07: '#FFAD12' 
  theme-gradient-color-08: '#FFA40E' 
  theme-gradient-color-09: '#FF9C0B' 
  theme-gradient-color-10: '#FF8C06' 
  theme-gradient-color-11: '#FF8305' 

Define your own, or alter the example cards!

Design your OWN card

I hope you have found enough examples and inspiration to design your own horseshoe layout, with nice colors and functional animations. I just might include some of the community designs in this section 😄

End notes

License

This project is under the MIT license.

Credits

The making of this card wouldn't be possible without an incredible number of resources I used to find solutions for the things I wanted to do with this card. Credits in random order:

  • The Home Assitant dev site with a simple example of creating a lit-element card
  • Implementation examples from the community like the mini-graph-card, button-card and gauge-card
  • The greatest site for CSS, css-tricks
  • The back-to-school site for HTML, CSS and Javascript: w3schools
  • Stackoverflow for so many solutions for specific problems
  • Codepen for so many, many, many small CSS, SVG and HTML examples for things I didn't now how they worked
  • jsfiddle for so many, many, many small CSS, SVG and HTML examples for things I didn't now how they worked
  • designshack for all sorts of inspirations & designs
  • pinterest for color palettes and more
  • CSS animations for beginners
  • Animate.css, where the predefined animations come from!
  • The interactive site from Ana Travis, Animista for all your animations.
  • The Material design palette generator which saved me a lot of time.
  • An RGB Color Gradient Maker

Personal Note

Many, many, many years ago in the last century I learned to code C and Pascal. To make this card I had to learn the basics of a lot of new things like Javascript, HTML, CSS and the lit-element web component. The above resources where invaluable to accomplish this.

flex-horseshoe-card's People

Contributors

amoebelabs avatar lau-ie avatar lgtm-migrator avatar wrt54g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flex-horseshoe-card's Issues

Icon color by state

Hello, thanks for this great card! I've been trying to build a card that shows the state of a few switches by icon color. Based on examples 11 and 12, it looks like icon color should change by state within the animations section, but I have tried repeatedly and can't get it to work.

I took the sample code for #12 and used it as is, except to replace the entities with my own, and the card shows up with white icons only. The state changes when you click on the icon, and the circle changes per the animations, but the icon stays white.

In the example file, the icon color in the automation section is set to switch from white to primary text color. In the icon section (under layout) the icon color is set to primary text color.

I have changed all of the colors in both the animation and layout/icon sections to red, blue, black and yellow. Only the colors applied in the layout/icon section change anything, but still no change with state.

If I remove the style/color from layout/icons section, the color of the icons reverts to white again, and still no change with state.

Am I doing something wrong, has this functionality been deprecated, or is this a bug? The code is rather long and is literally the Two Bulbs code from the sample file, changed to my entities, and with 'white' changed to 'black' in the icon section of animations. Let me know if you want me to post it anyway.

Thanks in advance!

it does not work (vlines: hlines: names :)

Hello! Can someone tell me, it doesn't work (vlines: hlines: names :) when using these attributes, the card simply doesn't appear on the page, there are no errors, it just disappears. In the example below, only hlines: is specified, but this also doesn't work with others.
2020-08-25_18-14-57

Cards won't show after HA update

Hi,

After HA update to 0.106 the cards don't show anymore. It seems that it's something related with hlines/vlines configuration because if I remove those lines it starts working. Any suggestion?

Regards.

No horseshoe scale defined

I installed the card via HACS, added the URL to the lovelace resources and copied your basic example. All I see is "No horseshoe scale defined". After removing various elements to see if other messages show up, I ended with this:

      - type: 'custom:flex-horseshoe-card'
        entities:
          - entity: weather.dark_sky
            attribute: temperature
            decimals: 1
            unit: °C
            area: De Maan
        layout:
          horseshoe_scale:
            min: -10
            max: 40

image

I am using HA V0.102.2 and the build in lovelace editor. I'm not using the decluttering card...

inoperation

The latest version of HA requires manual configuration. The existing reference configuration is invalid.

HACS support

This is awesome, id love to see this in hacs so it’s easier for folks to discover and for others to track updates

No call service with browser mod is calling

As the new version of Hassio 2021.1.3 and browser_mod are released, is not possible to use Tap_action with the call service for the browser_mod popup service. I know that other custom cards has the same problems but new released was done in order to use the fire-dom-event option instead of classic call service. Is it in program to do the same upgrade for this fantastic card that I use everywhere?
Thanks you

HACS install don't work.

I tried the install via HACS, but after a restart there is no horseshoe card.
A manual card with the code from this side gives the error "No card type found".

Is this project dead?

Card layout issue in App Home Assistant on Android tablet

I am using the flex horseshoe card on an Android tablet. When I open Home Assistant in Chrome, Firefox or Edge, the layout is correct. When I open Home assistant on my tablest with the App, the laytout is wrong. The problem is that the icons are placed incorrectly. The size of the icon is also larger. How can this be solved?
Oke
NotOke

Invert color_stops value > color to color > value

To make color_stops to work with config template card variables the variable needs to be the value in the yaml list.

This does not work:

  color_stops:
    "${states['sensor.electricity_price'].attributes.min_price}": 'green'
    "${states['sensor.electricity_price'].attributes.min_price}": 'blue'

Should be:

  color_stops:
    'green': "${states['sensor.electricity_price'].attributes.min_price}"
    'blue': "${states['sensor.electricity_price'].attributes.min_price}"

Horshoe to support negative and positive numbers

Hi AmoebeLabs

Your component is incredibly useful for displaying Battery Details as used for Solar Storage. It is literally the best way to show it!!!

But I have a small request - please would it be possible to have the horshoe curve support drawing from the middle apex to the left depending on a negative or positive number. That would immediately transfer this into the most useful component for a battery as you could see whether it is charging or discharging.

If you can show me where in the code it draws the curve, I can try to figure it out.

image

Thanks
Wayne

lineargradient ignores all but first and last defined colorstop

observed on release version: v 0.9.0

[repro]

  1. set horseshoe fill style to use: lineargradient
  2. provide a list of numerous (several more than 2) colorstops

[result]

  1. the gradient is created using only the first and last defined colorstop, none of the in-between colorstop colors are used or displayed

[expect]

  1. multiple defined colorstops should result in multiple gradients between each of the defined colorstop values

Add capability to set size or ratio of card

is there a way to set the size or ratio horizontal vs. vertical dimensions so, when put in a horizontal stack with others you can control how tall/wide it is to match the others ?

Incredible Lovelace card, but is it still supported?

This card is incredible and I'd love to use it extensively, however I am reluctant if it is no longer supported. @AmoebeLabs I hope you have recovered from your illness and are now in great health! If not best wishes on your recovery. Are you planning on maintaining your awesome creation?

Compatibility

Hello,
This looks amazing!
However it does not work on the latest HA.
Is it supose to work or should I wait for a updated version ?

Late edit: Works ... I just need to pay more attention :)

Not able to hide unit of measurement

Currently I couldn't find any option to disable the card to show the unit of measurement for an entity. I one card I'd like to show my download speeds, which is in combination with the mesaurement unit quite large for one line:
350 Mbit/s

I was not able to manually set the attribute unit to empty (e.g. unit: '') or just leave the whole attribute out of code. In both cases the default measurement unit was chosen. I think following lines must be adapted to allow at least unit: '':

_buildUom(entityState, entityConfig) {
return (
entityConfig.unit
|| entityState.attributes.unit_of_measurement
|| ''
);
}

Expected solution:

  1. Either the card should automatically wrap the unit to a next line
  2. Offer a manual CSS option to wrap the unit to a next line
  3. Deactivate the card to show the unit of measurement

⚠️ Information: Future card configuration changes.

Hi.

A change in how lovelace cards are set up in Home Assistant 0.105 increases performance, but enables cards to accidentally modify their own configuration in the loaded lovelace configuration.

I'm going through the cards in the HACS default repository, and noticed that your card may be susceptible to this. Looking through your code it seems you may modify parts of the config object passed to your card in setConfig.

The result could be that your card does not work well with the GUI editors or that parts of the configuration start showing up multiple times.

At some point in the future, it is likely that the configuration will be frozen before being passed to setConfig. At this point, your card will fail entirely when it tries to modify the configuration object.

There are several ways to fix/protect agains this problem.

The best is to restructure setConfig such that the configuration is never modified.
Other alternatives are to make a copy of the configuration and work on that instead.

setConfig(config) {
  config = { ...config }; // This works for simple configurations not containing arrays or objects
...
import { deepClone } from "deep-clone-simple";
// https://github.com/balloob/deep-clone-simple

setConfig(config) {
  config = deepClone(config); // This is a safe and fast method
...

or

setConfig(config) {
  config = JSON.parse(JSON.stringify(config)); // This uses built-in functions, but may be slower than deepClone
  ...

Please note that I have not tested your card agains Home Assistant 0.105 or later, but just quickly looked through the code. If I'm mistaken in my assessment, I appologize for taking your time.

See thomasloven/hass-config#6 for more info.

Issue with mobile app since latest update

I have a problem since the mobile app update to 2022.6.0. It's working fine with browser version and worked in mobile app before.
Pushing the now "invisible" fan button in mobile app gives me the following error:

Logger: frontend.js.latest.202206010
Source: components/system_log/__init__.py:190
First occurred: 08:54:06 (1 occurrences)
Last logged: 08:54:06

https://xxxxxxxxxxx.duckdns.org:8123/hacsfiles/flex-horseshoe-card/flex-horseshoe-card.js?hacstag=1111111111:222:333 Uncaught TypeError: Cannot read properties of undefined (reading 'action')

Mobile app:
mobile

Browser:
browser

Lovelace-Configuration:

type: custom:mod-card
card_mod:
  style: |
    restriction-card {
      --lock-margin-left: 88%;
    }
card:
  type: custom:restriction-card
  restrictions:
    block: true
  condition:
    entity: sensor.i3s_120_remaining_battery_percent
    value: 30
    operator: <
  card:
    type: custom:flex-horseshoe-card
    entities:
      - entity: sensor.i3s_location_temp
        decimals: 1
        name: ' '
        tap_action:
          action: more-info
      - entity: input_boolean.virtual_i3s_climate
        icon: mdi:fan
        tap_action:
          action: call-service
          service: input_boolean.toggle
          service_data:
            entity_id: input_boolean.virtual_i3s_climate
      - entity: switch.virtual_i3s_climate
      - entity: sensor.i3s_loc
        tap_action:
          action: more-info
    animations:
      entity.1:
        - state: 'on'
          icons:
            - animation_id: 0
              styles:
                - color: var(--paper-item-icon-active-color);
        - state: 'off'
          icons:
            - animation_id: 0
              styles:
                - color: var(--primary-text-color);
      entity.2:
        - state: 'on'
          icons:
            - animation_id: 0
              styles:
                - color: var(--text-primary-color);
          circles:
            - animation_id: 1
              styles:
                - fill: var(--cool-blue);
        - state: 'off'
          circles:
            - animation_id: 1
              styles:
                - fill: var(--primary-background-color);
    show:
      horseshoe_style: colorstopgradient
    layout:
      states:
        - id: 0
          entity_index: 0
          xpos: 50
          ypos: 42
          styles:
            - font-size: 3.5em;
            - text-transform: none;
            - font-weight: 500;
        - id: 1
          entity_index: 3
          xpos: 50
          ypos: 95
          styles:
            - text-transform: lowercase;
            - font-size: 1.6em;
            - font-weight: 500;
            - letter-spacing: inherit;
      hlines:
        - id: 0
          xpos: 50
          ypos: 51
          length: 50
          styles:
            - stroke: var(--primary-text-color);
            - stroke-width: 5;
            - stroke-linecap: round;
            - opacity: 0.7;
      names:
        - id: 0
          entity_index: 0
          xpos: 50
          ypos: 95
          styles:
            - text-transform: lowercase;
            - font-size: 1.6em;
            - font-weight: 500;
            - letter-spacing: inherit;
      icons:
        - id: 0
          entity_index: 1
          animation_id: 0
          xpos: 50
          ypos: 74
          icon_size: 3.8
      circles:
        - id: 0
          entity_index: 2
          animation_id: 1
          xpos: 50
          ypos: 68.5
          radius: 25
    horseshoe_scale:
      min: -20
      max: 60
      width: 10
    horseshoe_state:
      width: 14
    color_stops:
      '10': orange
      '18': var(--cool-blue)
      '25': orange
      '35': red
      '-20': red
    card_mod:
      style: |
        ha-card {
          padding: 12px !important;
        }

Arrange changes in every device

I´m having this issue, the same card config changes depending the device is vieweing, and even in the same mobile if it´s in portrait or landscape orientation
PC
PC
Phone Landscape
landscape
Phone Portrait
portrait

No layout defined error

I am getting an error when trying to use this:

EAAD6010-9C69-4039-B342-3EAD5AA57763

I am running 0.99.2 and I have restarted since installing. Any idea what this error means?

Lovelace refresh on iPhone

Hi

I have used and adapted the “Flexible Horseshoe Card for Lovelace” from Hacs. On my pc this works perfectly. When i use it on my iPhone i have a problem.
The intention is if you click eg the icon “silent”, that the color changes from orange to red or vice versa.
On my iPhone that only happens when I refresh my image by pulling the image down.

What could be the problem?
is the card too extensive or are there other causes?

My card:
Flexible Horseshoe Card for Lovelace
flex-horsesshoe-card.yaml.txt

Convert lineal input_number slider to input_number flex-horseshoe slider

I could not make it work as a command, just as a sensor, I mean:
lovelace -> automation -> cover Not Working
cover -> automation -> lovelace Working
Is it that flex-horseshoe cars do not yet have this feature?

To control a cover it is neccessary to use horse circle (first entity) as a command.

FR: Make value changes smoothly

It would be nice if the value of the horseshoe changes smoothly and don't jump to the next value.
Like in the custom gauge card.
If you have sensors that change frequently fast, like from a solar system.

Thanks for this great card and your time.

version 0.9.1

@AmoebeLabs
Not really an issue: I've modified the code with the follows:

  • release : 0.9.1 (candidate)
  • by : Fabio Salvicchi
  • date : 17 March 2021
  • log : - no uppercase translation for card's name, is up to you choose the case
  •           - added a new horseshoe_style named 'colorstoplineargradient'; it display a gradient
    
  •             from the first color_stop to the value's corrispondent color_stop
    

Is there a way to send you the code for your approbation?

Thank you for your great job!

Icon position wrong on Android tablet

Hi,

I hope your recovery is going well.

I'm using your Horseshoe card and on a browser or the companion app on IOS the postion of the icons is shown correct.
How ever on my (Android) wall tablet the icons are in the wrong position.
IOS:
iOS

Android
Android

Any ideas or suggestions how to fix this?

Cannot read property 'setConfig' of undefined

I try not to open issues that skew towards support, but I've double checked that I followed the instructions before coming here.

Error

When creating a simple "getting started" card, the following error is thrown:

image

I am running the latest version of Home Assistant Home Assistant 0.105.5 on HassOS in a VM.

- type: 'custom:flex-horseshoe-card'
  entities:
    - entity: sensor.glances_ram_used
      icon: 'mdi:memory'
      name: RAM Usage

Verifying Dependencies

I have restarted the Home Assistant Server several times since this was installed.

I can confirm the sensor.glances_ram_used entity itself exists and works, here a screenshot underneath another card using the same entity:

image

I've double checked that the script source is being loaded at the top of the UI resources:

image

Finally, I double checked that the file is where it is supposed to be:

image

color stops not working

My current code is as follows:

type: custom:flex-horseshoe-card
entities:
  - entity: sensor.air_quality_index
    name: Air Quality
    attribute: state
    decimals: 1
show:
  horseshoestyle: colorstopgradient
layout:
  states:
    - id: 0
      entity_index: 0
      xpos: 50
      ypos: 60
  //  areas: null
  //    - id: 0
  //      entity_index: 0
  //      xpos: 50
  //      ypos: 35
  names:
    - id: 0
      entity_index: 0
      xpos: 50
      ypos: 35
horseshoe_scale:
  min: 0
  max: 300
color_stops:
  '0': '#24E79F'
  '20': '#FEC428'
  '50': '#FD702F'
  '100': '#F42254'
  '150': '#C522A7'
  '200': '#9717FB'

but the color stays light blue. When I try to remove the single-quotes in the editor, HA keeps adding them back in. That may be the issue, but not sure how to resolve.

Thank you

Use sensor value as min/max horseshoe_scale

Hi,
I would find it useful to be able to use a sensor or a template as min and max values for horseshoe_scale.
Something like:

horseshoe_scale:
  min: 0
  max: sensor.target_time

or:

horseshoe_scale:
  min: 0
  max: {{states('sensor.target_time')}}

It's possible?

By(t)e

Decluttering templates icons on mobile

Hello,
Everything works perfect, but when I use the decluttering templates, on mobile devices, the icons dont show on the screen .
I understand this might be a decluttering-card issues, but wondering if anyone has this issue and a possible workaround !?

doesn't work (vlines: hlines: names :)

Hello! Can someone tell me, it doesn't work (vlines: hlines: names :) when using these attributes, the card simply doesn't appear on the page, there are no errors, it just disappears. In the example below, only hlines: is specified, but this also doesn't work with others.
2020-08-25_18-14-57

Lowercase letters

Would love the ability to use lowercase letters in names! Thanks for the hard work so far!

entity_id undefined in mobile app

Strange behaviour for me. Getting the following error with HASS 2021.9.6 and this integration (0.9.0) on click on the icon / circle.
Everything works fine in Chrome on PC and Chrome on Android mobile (no error in the log), but in the app I get the following error:

Logger: frontend.js.latest.202108300
Source: components/system_log/init.py:190
First occurred: 12:28:54 (1 occurrences)
Last logged: 12:28:54
https://aa.bb.org/hacsfiles/flex-horseshoe-card/flex-horseshoe-card.js?hacstag=abcdefghijklmnopqrstuvwxyz Uncaught TypeError: Cannot read properties of undefined (reading 'entity_id')

My configuration for the card is attached: card.txt

Mobile app:

mobile_app

Chrome (PC):

pc

Crashes the HA 0.117 on HASSIO

This crashes the HA 0.117 , with frontend loading for ever , only way to resolve is to delete the re install the HACS.

Any suggestions let me know.

Layout: icons: size: 1.2 does not work on android tablet.

I want to change the size of an icon according to the example.
icons:
# Icons 0 refers to the second entity in the list, ie index 1
- id: 0
entity_index: 1
xpos: 37
ypos: 57
align: end
size: 1.3
This works fine on PC and iPhone.
This does not work on an android tablet.
What is the solution for this?

Cannot add property tap_action, object is not extensible

Hi,
after the update to HA 0.106.6 I receive the following error: Cannot add property tap_action, object is not extensible

Screenshot 2020-03-11 at 14 18 33

Can you help me to resove this issue?

My configuration is the following:

                type: entities
                title: {{name}}
                show_header_toggle: false
                entities:
                  - type: custom:layout-card
                    layout: horizontal
                    column_num: 2
                    cards:
                      - type: 'custom:flex-horseshoe-card'
                        entities:
                          {% if room_sensor %}
                          - entity: sensor.{{ room_sensor }}_battery
                            decimals: 0
                            unit: '%'
                            icon: mdi:gauge
                          - entity: sensor.{{ room_sensor }}_temperature
                            decimals: 1
                            unit: '°C'
                          - entity: sensor.{{ room_sensor }}_humidity
                            decimals: 0
                            unit: '%'
                            icon: mdi:water-percent
                          - entity: sensor.{{ room_sensor }}_pressure
                            decimals: 0
                            unit: 'hPa'
                            icon: mdi:gauge
                          {% endif %}
                          {% if external_sensor %}
                          - entity: sensor.{{ external_sensor }}_battery_level
                            decimals: 0
                            unit: '%'
                            icon: mdi:gauge
                          - entity: sensor.{{ external_sensor }}_temperature
                            decimals: 1
                            unit: '°C'
                          {% endif %}
                        show:
                          horseshoe_style: 'lineargradient'
                        layout:
                          {% if room_sensor %}
                          hlines:
                            # A horizontal line. Not connected to an entity
                            - id: 0
                              xpos: 50
                              ypos: 42
                              length: 40
                              styles:
                                - stroke: var(--primary-text-color);
                                - stroke-width: 5;
                                - stroke-linecap: round;
                                - opacity: 0.7;
                          {% endif %}
                          states:
                          {% if room_sensor %}
                            # States 0 refers to the first entity in the list, ie index 0
                            - id: 0
                              entity_index: 1
                              xpos: 50
                              ypos: 34
                              styles:
                                - font-size: 2em;
                            # States 1 refers to the second entity in the list, ie index 1
                            - id: 1
                              entity_index: 2
                              xpos: 40
                              ypos: 57
                              styles:
                                - text-anchor: start;
                                - font-size: 1.5em;
                            # States 2 refers to the third entity in the list, ie index 2
                            - id: 2
                              entity_index: 3
                              xpos: 40
                              ypos: 72
                              styles:
                                - text-anchor: start;
                                - font-size: 1.5em;
                          icons:
                            # Icons 0 refers to the second entity in the list, ie index 1
                            - id: 0
                              entity_index: 2
                              xpos: 37
                              ypos: 57
                              align: end
                              size: 1.3
                            # Icons 1 refers to the third entity in the list, ie index 2
                            - id: 1
                              entity_index: 3
                              xpos: 37
                              ypos: 72
                              align: end
                              size: 1.3
                          {% endif %}
                          {% if external_sensor %}
                            - id: 0
                              entity_index: 1
                              xpos: 50
                              ypos: 60
                              styles:
                                - font-size: 3em;
                          {% endif %}
                        # Scale set to -10 to +40 degrees celcius
                        horseshoe_scale:
                          min: 0
                          max: 100
                        # color stop list with 10 colors defined in the theme. With the `lineargradient` fill style, only the
                        # first (16:) and last (25:) colors are used. The thresholds are ignored with this setting.
                        color_stops:
                          00: '#D60036'
                          10: '#CD1930'
                          20: '#C4322B'
                          30: '#BC4B25'
                          40: '#B36420'
                          50: '#AB7D1B'
                          60: '#A29615'
                          70: '#99AF10'
                          80: '#91C80A'
                          90: '#88E105'
                          100: '#80FA00'
                        style: |
                          ha-card {
                            box-shadow: var(--theme-card-box-shadow);
                          }

Thank you very much in advance

TypeError: inColor is undefined

Hassio 0.101.0
Flex-horseshoe: 0.8.3

Every once in a while, i have this error on logs:
https://XX.XX.XX.XX:8123/community_plugin/flex-horseshoe-card/flex-horseshoe-card.js:1914:12 TypeError: inColor is undefined
and when this error is caught, only the first flex-horseshoe below disappears. I have to restart HA a couple of times to make it appear again:

      - cards:
          - color_stops:
              '200': '#FFF6E3'
              '400': '#FFE9B9'
              '600': '#FFDA8A'
              '800': '#FFCB5B'
              '1000': '#FFBF37'
              '1200': '#ffb414'
              '1400': '#FFAD12'
              '1600': '#FFA40E'
              '1800': '#FF9C0B'
              '1900': '#FF8C06'
            entities:
              - attribute: power
                decimals: 0
                entity: sensor.termosifon_power
                name: Termosifon
                unit: W
              - attribute: energy
                decimals: 1
                entity: sensor.monthly_termosifon_energy
                icon: 'mdi:power-plug'
                unit: kWh
              - attribute: current
                decimals: 2
                entity: sensor.termosifon_current
                icon: 'mdi:gauge'
                unit: A
            horseshoe_scale:
              max: 2000
              min: 0
            layout:
              hlines:
                - id: 0
                  length: 40
                  styles:
                    - stroke: var(--primary-text-color);
                    - stroke-width: 5;
                    - stroke-linecap: round;
                    - opacity: 0.7;
                  xpos: 50
                  ypos: 42
              icons:
                - align: end
                  entity_index: 1
                  id: 0
                  size: 1.3
                  xpos: 37
                  ypos: 57
                - align: end
                  entity_index: 2
                  id: 1
                  size: 1.3
                  xpos: 37
                  ypos: 72
              names:
                - entity_index: 0
                  id: 0
                  xpos: 50
                  ypos: 95
              states:
                - entity_index: 0
                  id: 0
                  styles:
                    - font-size: 3em;
                  xpos: 50
                  ypos: 34
                - entity_index: 1
                  id: 1
                  styles:
                    - text-anchor: start;
                    - font-size: 1.5em;
                  xpos: 40
                  ypos: 57
                - entity_index: 2
                  id: 2
                  styles:
                    - text-anchor: start;
                    - font-size: 1.5em;
                  xpos: 40
                  ypos: 72
            show:
              horseshoe_style: colorstopgradient
            type: 'custom:flex-horseshoe-card'
          - color_stops:
              '0': '#FFF6E3'
              '800': '#FFE9B9'
              '1600': '#FFDA8A'
              '2400': '#FFCB5B'
              '3200': '#FFBF37'
              '4000': '#ffb414'
              '4800': '#FFAD12'
              '5600': '#FFA40E'
              '6400': '#FF9C0B'
              '7200': '#FF8C06'
            entities:
              - attribute: power
                decimals: 0
                entity: sensor.aeon_hem_power
                name: Home Total
                unit: W
              - attribute: energy
                decimals: 1
                entity: sensor.monthly_home_energy
                icon: 'mdi:power-plug'
                unit: kWh
              - attribute: current
                decimals: 0
                entity: sensor.aeon_hem_current
                icon: 'mdi:gauge'
                unit: A
            horseshoe_scale:
              max: 8000
              min: 0
            layout:
              hlines:
                - id: 0
                  length: 40
                  styles:
                    - stroke: var(--primary-text-color);
                    - stroke-width: 5;
                    - stroke-linecap: round;
                    - opacity: 0.7;
                  xpos: 50
                  ypos: 42
              icons:
                - align: end
                  entity_index: 1
                  id: 0
                  size: 1.3
                  xpos: 37
                  ypos: 57
                - align: end
                  entity_index: 2
                  id: 1
                  size: 1.3
                  xpos: 37
                  ypos: 72
              names:
                - entity_index: 0
                  id: 0
                  xpos: 50
                  ypos: 95
              states:
                - entity_index: 0
                  id: 0
                  styles:
                    - font-size: 3em;
                  xpos: 50
                  ypos: 34
                - entity_index: 1
                  id: 1
                  styles:
                    - text-anchor: start;
                    - font-size: 1.5em;
                  xpos: 40
                  ypos: 57
                - entity_index: 2
                  id: 2
                  styles:
                    - text-anchor: start;
                    - font-size: 1.5em;
                  xpos: 40
                  ypos: 72
            show:
              horseshoe_style: colorstopgradient
            type: 'custom:flex-horseshoe-card'
        type: horizontal-stack

entityConfig is undefined : the page is blank

Hi,
Hassio ver. 0.105.5 and flex-horseshoe-card downloaded from HACS 1 hour ago.

The simple card is blank, no messages on log, on Developers Tools page :
flex-horseshoe-card.js:1703:1 TypeError: entityConfig is undefined

Also your examples page is blank. Any help ? Thanks for your work.

id: tests
title: Test page
icon: 'mdi:battery-charging'
panel: true
path: test

cards:

  - type: vertical-stack
    cards:

    - !include
      - ../includes/titles.yaml
      - title: 'TEST'

    - type: custom:flex-horseshoe-card
      entities:
        - entity:  display.wall_tablet
          attribute: battery_level
          units: '%'
          icon: mdi:battery
          name: 'Batteria'              
        - entity:  display.wall_tablet
          attribute: battery_charging
          icon: mdi:battery-charging
          name: 'In carica'
      show:
        horseshoe_style: lineargradient          
      layout:
        hlines:
          - id: 0
            xpos: 50
            ypos: 42
            length: 40
            styles:
              - stroke: var(--primary-text-color);
              - stroke-width: 5;
              - stroke-linecap: round;
              - opacity: 0.7;
        states:
          - id: 0
            entity_index: 0
            xpos: 50
            ypos: 34
            styles:
              - font-size: 3em;
          - id: 1
            entity_index: 1
            xpos: 40
            ypos: 57
            styles:
              - text-anchor: start;
              - font-size: 1.5em;
        icons:
          - id: 0
            entity_index: 1
            xpos: 37
            ypos: 57
            align: end
            size: 1.3
          - id: 1
            entity_index: 2
            xpos: 37
            ypos: 72
            align: end
            size: 1.3
        names:
          - id: 0
            entity_index: 0
            xpos: 50
            ypos: 95

      horseshoe_scale:
        min: -10
        max: 40

      color_stops:
        16: '#FFF6E3'
        17: '#FFE9B9'
        18: '#FFDA8A'
        19: '#FFCB5B'
        20: '#FFBF37'
        21: '#ffb414'
        22: '#FFAD12'
        23: '#FFA40E'
        24: '#FF9C0B' 
        25: '#FF8C06' 


Off-line, No internet, no web connection

i am able to see the custom:flex-horseshoe-card when i am connected to the web but in my case i run my HomeAssistance without internet

Is there a way to run it without the web?

Template sensors don't render. Nothing is shown in that case

As shown in this post: https://community.home-assistant.io/t/lovelace-flexible-horseshoe-card-donut-graph-flexible-layout-multiple-entities-actions-animations-including-next-gen-experimental-examples/137850/47, template sensors using a value_template don't render.

Sensor is defined as:

      esxi_vm0_datastore1_total_capacity:
        friendly_name: 'VM0 Used Disk Space - Datastore 1'
        value_template: "{{ states['sensor.esxi_datastore_datastore1'].attributes.total_space_gb + states['sensor.esxi_datastore_vms_datastore'].attributes.total_space_gb | round () }}"
        unit_of_measurement: 'GBs'

Add configurable per item drop shadows (2/2)

Second part of #4

Add per item drop shadows. It should replace and/or complement the CSS filter which is applied to the full SVG.

  • Texts should be ok
  • The horseshoe also
  • Icons too
  • Lines require special treatment: horizontal lines don't have a height, where vertical line don't have a width. In those cases, nothing is rendered...

An example with hard-coded svg filters shows this, without per item filters:

image

And with filters, but the line doesn't show any drop shadow...
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.