npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

power-flow-card-ha

v1.1.4

Published

Power Flow visualisation card for Home Assistant Lovelace

Readme

Power Flow Card for Home Assistant

A custom Lovelace card for visualizing real-time energy flow between grid, solar, battery, and home.


Features

  • Animated flow lines with gradient shine and dynamic speed
  • Top labels with live values for Grid, Solar Panel, and Export
  • Supports grid import/export, solar generation, battery charge/discharge
  • Optional EV and battery entities
  • Optional daily grid import value (uses last_period)

Installation

NPM (for React/Vue/other frameworks)

npm install power-flow-card-ha

Then import in your project:

import 'power-flow-card-ha';

HACS (recommended for Home Assistant)

  1. Open HACS → Frontend
  2. Add a custom repository: https://github.com/Kokhungchan/power-flow
  3. Install and add the resource:
    • URL: /hacsfiles/power-flow/power-flow-card.js
    • Type: JavaScript Module

Manual

  1. Copy power-flow-card.js into /config/www/
  2. Add the resource:
    • URL: /local/power-flow-card.js
    • Type: JavaScript Module

Usage in React

Basic Setup

import React, { useEffect, useRef } from 'react';
import 'power-flow-card-ha';

function PowerFlowCard() {
  const cardRef = useRef(null);

  useEffect(() => {
    if (cardRef.current) {
      cardRef.current.setConfig({
        name: 'Home Energy Flow',
        threshold: 10,
        entities: {
          solar_power: 'sensor.solar_power',
          grid_import_power: 'sensor.grid_import',
          grid_export_power: 'sensor.grid_export',
        },
      });

      // Mock Home Assistant object
      cardRef.current.hass = {
        states: {
          'sensor.solar_power': { state: '2500', attributes: { unit_of_measurement: 'W' } },
          'sensor.grid_import': { state: '500', attributes: { unit_of_measurement: 'W' } },
          'sensor.grid_export': { state: '0', attributes: { unit_of_measurement: 'W' } },
        },
      };
    }
  }, []);

  return <power-flow-card ref={cardRef} />;
}

export default PowerFlowCard;

With Custom Styling

import React, { useEffect, useRef } from 'react';
import 'power-flow-card-ha';

function PowerFlowCard() {
  const cardRef = useRef(null);

  useEffect(() => {
    if (cardRef.current) {
      cardRef.current.setConfig({
        name: 'Energy Monitor',
        threshold: 10,
        entities: {
          solar_power: 'sensor.solar_power',
          grid_import_power: 'sensor.grid_import',
          grid_export_power: 'sensor.grid_export',
          battery_charge_power: 'sensor.battery_charge',
          battery_discharge_power: 'sensor.battery_discharge',
        },
        styles: {
          'solar-color': 'orange',
          'grid-import-color': '#00aaff',
          'battery-color': 'purple',
          'card-background': '#2a2a2a',
          'header-font-size': '20px',
        },
      });

      cardRef.current.hass = {
        states: {
          'sensor.solar_power': { state: '3000', attributes: { unit_of_measurement: 'W' } },
          'sensor.grid_import': { state: '200', attributes: { unit_of_measurement: 'W' } },
          'sensor.grid_export': { state: '500', attributes: { unit_of_measurement: 'W' } },
          'sensor.battery_charge': { state: '1000', attributes: { unit_of_measurement: 'W' } },
          'sensor.battery_discharge': { state: '0', attributes: { unit_of_measurement: 'W' } },
        },
      };
    }
  }, []);

  return <power-flow-card ref={cardRef} />;
}

export default PowerFlowCard;

With Real-time Updates

import React, { useEffect, useRef, useState } from 'react';
import 'power-flow-card-ha';

function PowerFlowCard({ solarPower, gridImport, gridExport }) {
  const cardRef = useRef(null);

  useEffect(() => {
    if (cardRef.current) {
      cardRef.current.setConfig({
        name: 'Live Energy Flow',
        threshold: 10,
        entities: {
          solar_power: 'sensor.solar_power',
          grid_import_power: 'sensor.grid_import',
          grid_export_power: 'sensor.grid_export',
        },
      });
    }
  }, []);

  useEffect(() => {
    if (cardRef.current) {
      cardRef.current.hass = {
        states: {
          'sensor.solar_power': { state: String(solarPower), attributes: { unit_of_measurement: 'W' } },
          'sensor.grid_import': { state: String(gridImport), attributes: { unit_of_measurement: 'W' } },
          'sensor.grid_export': { state: String(gridExport), attributes: { unit_of_measurement: 'W' } },
        },
      };
    }
  }, [solarPower, gridImport, gridExport]);

  return <power-flow-card ref={cardRef} />;
}

export default PowerFlowCard;

TypeScript Support

import React, { useEffect, useRef } from 'react';
import 'power-flow-card-ha';

interface PowerFlowCardElement extends HTMLElement {
  setConfig: (config: any) => void;
  hass: any;
}

function PowerFlowCard() {
  const cardRef = useRef<PowerFlowCardElement>(null);

  useEffect(() => {
    if (cardRef.current) {
      cardRef.current.setConfig({
        name: 'Home Energy Flow',
        threshold: 10,
        entities: {
          solar_power: 'sensor.solar_power',
          grid_import_power: 'sensor.grid_import',
          grid_export_power: 'sensor.grid_export',
        },
      });

      cardRef.current.hass = {
        states: {
          'sensor.solar_power': { state: '2500', attributes: { unit_of_measurement: 'W' } },
          'sensor.grid_import': { state: '500', attributes: { unit_of_measurement: 'W' } },
          'sensor.grid_export': { state: '0', attributes: { unit_of_measurement: 'W' } },
        },
      };
    }
  }, []);

  return <power-flow-card ref={cardRef} />;
}

export default PowerFlowCard;

Configuration

Usage example in YAML:

type: custom:power-flow-card
name: Home Energy Flow
threshold: 10
entities:

  solar_power: sensor.sn_3015027172_pv_power
  grid_import_power: sensor.sunny_home_manager_2_metering_power_absorbed
  grid_export_power: sensor.sunny_home_manager_2_metering_power_supplied
  grid_import_daily: sensor.grid_import_daily

  # Optional
  ev_charge_power: sensor.evcc_garage_charge_power
  battery_charge_power: sensor.sn_3017444296_battery_power_charge_total
  battery_discharge_power: sensor.sn_3017444296_battery_power_discharge_total

# Optional: Custom styles
styles:
  solar-color: "orange"
  grid-import-color: "#00aaff"
  battery-color: "purple"
  card-background: "#2a2a2a"
  header-font-size: "20px"

Available Style Options

styles:
  # Flow line colors
  solar-color: "gold"              # Solar flow line color
  grid-import-color: "dodgerblue"  # Grid import line color
  grid-export-color: "limegreen"   # Grid export line color
  battery-color: "cornflowerblue" # Battery line color
  ev-color: "deepskyblue"         # EV charging line color
  
  # Card styling
  card-background: "#1c1c1c"      # Card background color
  card-border-radius: "8px"       # Card border radius
  card-padding: "16px"            # Card padding
  card-shadow: "0 2px 8px rgba(0,0,0,0.3)" # Card shadow
  
  # Header styling
  header-font-size: "18px"        # Header font size
  header-font-weight: "600"       # Header font weight
  header-color: "#fff"            # Header text color
  
  # Label styling
  label-value-font-size: "16px"   # Label value font size
  label-text-font-size: "12px"    # Label text font size

Configuration editor screenshot:

Credits

Based on and inspired by the original work: https://github.com/LordGuenni/power-flow-card

The Illustrator Base for the SVGs was provided by ForsakenConversation