Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mini-graph-card

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mini-graph-card

A minimalistic and customizable graph card for Home Assistant Lovelace UI

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Lovelace Mini Graph Card

A minimalistic and customizable graph card for Home Assistant Lovelace UI.

The card works with entities from within the sensor domain and displays the sensors current state as well as a line graph representation of the history.

Preview

Install

Simple install

  1. Download and copy mini-graph-card-bundle.js from the latest release into your config/www directory.

  2. Add a reference to mini-graph-card-bundle.js inside your ui-lovelace.yaml.

resources:
  - url: /local/mini-graph-card-bundle.js?v=0.2.1
    type: module

CLI install

  1. Move into your config/www directory

  2. Grab mini-graph-card-bundle.js

$ wget https://github.com/kalkih/mini-graph-card/releases/download/v0.2.1/mini-graph-card-bundle.js
  1. Add a reference to mini-graph-card-bundle.js inside your ui-lovelace.yaml.
resources:
  - url: /local/mini-graph-card-bundle.js?v=0.2.1
    type: module

(Optional) Add to custom updater

  1. Make sure you've the custom_updater component installed and working.

  2. Add a new reference under card_urls in your custom_updater configuration in configuration.yaml.

custom_updater:
  card_urls:
    - https://raw.githubusercontent.com/kalkih/mini-graph-card/master/tracker.json

Updating

If you have a version older than v0.0.8 installed, please delete the current files and follow the installation instructions again.

  1. Find your mini-graph-card-bundle.js file in config/www or wherever you ended up storing it.

  2. Replace the local file with the latest one attached in the latest release.

  3. Add the new version number to the end of the cards reference url in your ui-lovelace.yaml like below.

resources:
  - url: /local/mini-graph-card-bundle.js?v=0.2.1
    type: module

You may need to empty the browsers cache if you have problems loading the updated card.

Using the card

Options

Card options
NameTypeDefaultSinceDescription
typestringrequiredv0.0.1custom:mini-graph-card.
entitiesstring/listrequiredv0.0.1Single entity id as a string or multiple entities in a list, see entities object for additional entity options.
iconstringoptionalv0.0.1Set a custom icon from any of the available mdi icons.
namestringoptionalv0.0.1Set a custom name which is displayed beside the icon.
unitstringoptionalv0.0.1Set a custom unit of measurement.
more_infobooleantruev0.0.1Set to false to disable the "more info" dialog popup when pressing on the card.
groupbooleanfalsev0.2.0Disable paddings and box-shadow, useful when nesting the card.
hours_to_showinteger24v0.0.2Specify how many hours the line graph should render.
points_per_hourinteger1v0.2.0Specify amount of data points the graph should render for every hour, (basically the detail/accuracy of the graph).
showlistoptionalv0.2.0List of UI elements to display/hide, for available items see available show options.
animatebooleanfalsev0.2.0Add a reveal animation to the graph.
heightnumber150v0.0.1Set a custom height of the line graph.
line_widthnumber5v0.0.1Set the thickness of the line.
line_colorstring/listvar(--accent-color)v0.0.1Set a custom color for the graph line, provide a list of colors for multiple graph entries.
decimalsintegeroptionalv0.0.9Specify the exact number of decimals to show for states.
hour24booleanfalsev0.2.1Set to true to display times in 24-hour format.
font_sizenumber100v0.0.3Adjust the font size of the state displayed, as percentage of the original size.
align_headerstringdefaultv0.2.0Set the alignment of the header, left, right, center or default.
align_iconstringrightv0.2.0Set the alignment of the icon, left, right or state.
align_statestringleftv0.2.0Set the alignment of the current state, left, right or center.
line_color_abovelistoptionalv0.2.0Set thresholds for different line graph colors, see Line color object.
line_color_belowlistoptionalv0.2.0Set thresholds for different line graph colors, see Line color object.
Entities object

Providing options are optional, entities can be listed directly, see example below.

NameTypeDefaultDescription
entitystringrequiredEntity id of the sensor.
namestringoptionalSet a custom display name, defaults to entity's friendly_name.
show_statestringoptionalDisplay the current state of the sensor.
entities:
  - sensor.temperature
  - entity: sensor.pressure
    name: Pressure
    show_state: true
  - sensor.humidity
Available show options

All options are optional.

NameDefaultparameterDescription
nametruetrue / falseDisplay name
icontruetrue / falseDisplay icon
statetruetrue / falseDisplay current state
graphtruetrue / falseDisplay the graph
filltruetrue / falseDisplay the graph fill
pointshovertrue / false / hoverDisplay graph data points
legendtruetrue / falseDisplay the graph legend (only shown when graph contains multiple entities)
extremafalsetrue / falseDisplay max/min information
labelsfalsetrue / falseDisplay Y-axis labels
Line color object

See adaptive line color for example usage.

NameTypeDefaultDescription
valuenumberrequiredThe threshold at where the color should apply if state is above/below.
colorstringrequiredColor to apply to line graph, most formats supported (hex, rgb, rgba or just the name of the color etc.)

Example usage

Single entity card
- type: custom:mini-graph-card
  entities: sensor.illumination

Single entity card

Alternative style
# Example
- type: custom:mini-graph-card
  entities: sensor.illumination
  location_icon: left
  location_state: center
  show:
    fill: false

Alternative style

Multiple entities card
- type: custom:mini-graph-card
  name: SERVER
  icon: mdi:server
  entities:
    - entity: sensor.server_total
      name: TOTAL
    - sensor.server_sent
    - sensor.server_received

Multiple entities card

Show data from the past week

Use the hours_to_show option to specify how many hours of history the graph should represent. Use the points_per_hour option to specify the accuracy/detail of the graph.

- type: custom:mini-graph-card
  entities: sensor.living_room_temp
  name: LIVONG ROOM
  hours_to_show: 168
  points_per_hour: 0.25

Show data from the past week

Graph only card

Use the show option to show/hide UI elements.

- type: custom:mini-graph-card
  entities: sensor.humidity
  show:
    icon: false
    name: false
    state: false
Horizontally stacked cards

You can stack cards horizontally by using one or more horizontal-stack(s).

- type: horizontal-stack
  cards:
    - type: custom:mini-graph-card
      entities: sensor.humidity
      line_color: blue
      line_width: 8
      font_size: 75
    - type: custom:mini-graph-card
      entities: sensor.illumination
      line_color: '#e74c3c'
      line_width: 8
      font_size: 75
    - type: custom:mini-graph-card
      entities: sensor.temperature
      line_color: var(--accent-color)
      line_width: 8
      font_size: 75

Horizontally stacked cards

Adaptive line color

Have the line color change with the current state. When listing more than one color entry, place them in order from low -> high for line_color_above and high -> low for line_color_below.

- type: custom:mini-graph-card
  entities: sensor.sensor_temperature
  line_color_above:
    - value: 10
      color: yellow
    - value: 20
      color: orange
    - value: 30
      color: red
  line_color_below:
    - value: -10
      color: white
    - value: -20
      color: lightblue
    - value: -30
      color: blue
    - value: -50
      color: "#000000"

Development

Clone this repository into your config/www folder using git.

$ git clone https://github.com/kalkih/mini-graph-card.git

Add a reference to the card in your ui-lovelace.yaml.

resources:
  - url: /local/mini-graph-card/mini-graph-card-bundle.js
    type: module

Generate the bundle

Requires nodejs & npm

Move into the mini-graph-card repo, checkout the dev branch & install dependencies.

$ cd mini-graph-card && git checkout dev && npm install

Edit the source, build by running

$ npm run build

The mini-graph-card-bundle.js will be rebuilt and ready.

For convenience, you can have the source build itself on file change by running

$ npm run watch

If you plan to submit a PR, please base it on the .dev` branch

Getting errors?

Make sure you have javascript_version: latest in your configuration.yaml under frontend:.

Make sure you have the latest versions of mini-graph-card.js & mini-graph-lib.js.

If you have issues after updating the card, try clearing your browser cache.

If you have issues displaying the card in older browsers, try changing type: module to type: js at the card reference in ui-lovelace.yaml.

License

This project is under the MIT license.

Keywords

FAQs

Package last updated on 07 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc