Giter Club home page Giter Club logo

dual-gauge-card's Introduction

Dual gauge card

Two gauges in one, built mostly with CSS.

MIT license hacs_badge

dual-gauge-card-screenshot

Heavily inspired by ciotlosm's gauge-card, but completly written from scratch.

Installation

Use HACS (recommended) or download dual-gauge-card.js and place it in your www directory.

In your ui-lovelace.yaml add this:

  - url: /community_plugin/dual-gauge-card/dual-gauge-card.js
    type: js

If you don't use HACS please change the url accordingly.

Config

Name Type Default Description
title string Common title
min int 0 minimum value
max int 100 maximum value
colors object color config (optional)
background_color string background color of the gauges
shadeInner bool true shade (darken) colors of the inner gauge by 25%
cardwidth int 300 width of the card in pixels (see below)
outer object config for the outer gauge
inner object config for the inner gauge

gauge config

Both gauges have the same attributes:

Name Type Default Description
entity string entity id
attribute string use this attribute of the entity instead of its state (optional)
label string label for this gauges value (optional)
unit object unit to add to the value (optional)
min int minimum value
max int maximum value
colors object color config (optional)

cardwidth

You may use the config value cardwidth to set the overall width of the card as an absolute value in pixels. All elements of the gauge are sized relative to this so that the gauge scales to this, but the card is not responsive for now, i.e. it doesn't resize automatically.

color config

Colors can be configured as list of pairs of each a color and a minimum value.

If a gauges value is greater than or equal to one of those minimum values, the according color is used for that gauge. If no color is found, the last color in the list is used as a fallback. To use a single color regardless of the value just use a single list entry with any value to always trigger the fallback.

By default, colors for the inner gauge are shaded by 25% (see option shadeInner).

The list is automatically sorted so you don't need to do that in your config - but I recommend it anyways.

common config vs. individual config

Colors, as well as the min and max values, may be configured once for both gauges or individually for each gauge. Individual values override common values.

Example

The example on the screenshot is configured like this:

- type: custom:dual-gauge-card
  title: Living room
  min: -20
  max: 40
  outer:
    entity: climate.living_room
    attribute: current_temperature
    label: "Current"
    unit: "°C"
  inner:
    entity: climate.living_room
    label: "Target"
    attribute: temperature
    unit: "°C"
  colors:
    - color: "var(--label-badge-red)"
      value: 27.5
    - color: "var(--label-badge-green)"
      value: 25
    - color: "var(--label-badge-yellow)"
      value: 18
    - color: "var(--label-badge-blue)"
      value: 0
    - color: "var(--paper-blue-400)"
      value: -40

In this example, the outer gauge has individual min and max values and uses default colors, whereas the inner gauge has individual colors and uses the common min and max values.

- type: custom:dual-gauge-card
  title: Living room
  min: -20
  max: 40
  outer:
    entity: climate.living_room
    attribute: current_temperature
    label: "Current"
    unit: "°C"
    min: -30
    max: 50
  inner:
    entity: climate.living_room
    label: "Target"
    attribute: temperature
    unit: "°C"
    colors:
      - color: "var(--label-badge-green)"
        value: 25
      - color: "var(--label-badge-yellow)"
        value: 18
      - color: "var(--label-badge-blue)"
        value: 0

dual-gauge-card's People

Contributors

rocka84 avatar virtuall avatar superforno avatar ktibow avatar optama avatar lebherz avatar

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.