MCPcopy Index your code
hub / github.com/JonahKr/power-distribution-card

github.com/JonahKr/power-distribution-card @v3.0.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.0.2 ↗ · + Follow
275 symbols 394 edges 41 files 12 documented · 4%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

power-distribution-card

GitHub package.json version Actions Status GitHub license hacs_badge Buy Me A Coffee

Inspired by e3dc-logo

The Lovelace Card for visualizing power distributions.

Table of Contents


Installation

Installation via HACS

  1. Make sure the HACS custom component is installed and working.
  2. Search for power-distribution-card and add it through HACS
  3. Refresh home-assistant.

Manual installation

  1. Download the latest release of the power-distribution-card
  2. Place the file in your config/www folder
  3. Include the card code in your ui-lovelace-card.yaml ```yaml resources:
    • url: /local/power-distribution-card.js type: module `` Or alternatively set it up via the UI:Configuration -> Lovelace Dashboards -> Resources (TAB)` For more guidance check out the docs.

Configuration

Presets

Every Sensor you want to add has to use one of the Presets. You can add as many of these as you want.

mdi-battery-outline mdi-electirc-car mdi-lightbulb mdi-transmission-tower mdi-home-assistant mdi-hydro-power mdi-pool mdi-lightning-bolt-outline mdi-solar-power mdi-wind-turbine mdi-radiator
battery car_charger consumer grid home hydro pool producer solar wind heating
Any Home Battery e.g. E3dc, Powerwall Any Electric Car Charger A custom home power consumer The interface to the power grid Your Home's power consumption Hydropower setup like Turbulent pool heater or pump custom home power producer Power coming from Solar Power coming from Wind Radiators

The presets consumer and producer enable to add any custom device into your Card with just a bit of tweaking.

Simple Configuration 🛠️

With Version 2.0 a Visual Editor got introduced. You can find the Card in your Card Selector probably at the bottom. From there on you can configure your way to your custom Card. The easiest way to get your Card up and running, is by defining the entities for the presets directly.

! Please Check for every Sensor: positive sensor values = production, negative values = consumption
! If this is the other way around in your Case, check the `invert_value` setting (Advanced Configuration)!

Placeholder

By submitting an empty entity_id and preset, you will generate a plain transparent placeholder item which can be used to further customize your layout. Alternatively you can use the provided placeholder preset.

YAML Only

If you are a real hardcore YAML connoisseur here is a basic example to get things started:

type: 'custom:power-distribution-card'
title: Title
animation: flash
entities:
  - entity: sensor.e3dc_home
    preset: home
  - entity: sensor.e3dc_solar
    preset: solar
  - entity: sensor.e3dc_battery
    preset: battery
center:
  type: bars
  bars:
    - preset: autarky
      name: autarky
    - preset: ratio
      name: ratio

You can find all options for every entity here. If you want to further modify the center panel youz can find the documentation here.

Animation

For the animation you have 3 options: flash, slide, none

type: 'custom:power-distribution-card'
animation: 'slide'

Center Panel

For customizing the Center Panel you basically have 3 Options:

None 🕳️

the void

Bars 📊

Bars have the following Settings: | Setting | type | example | description | | --------------------- |:-------------:|:-----------------:| :------------| | bar_color | string | red, #C1C1C1 | You can pass any string that CSS will accept as a color. | | bar_bg_color | string | red, #C1C1C1 | The Background Color of the Bar. You can pass any string that CSS will accept as a color. | | entity | string | sensor.ln_autarky | You can specify the entity_id here as well. Required when preset is not autarky or ratio. | | invert_value | bool | false | This will invert the value received from HASS. | | lower_bound | number | 0 | Lower bound for bar fill scaling (default: 0). Values at or below this show an empty bar. | | name | string | Eigenstrom | Feel free to change the displayed name of the element. | | preset | 'autarky' | 'ratio' | '' | autarky | autarky/ratio auto-calculate from entity totals. Use '' (empty string) with an entity for a custom bar. | | tap_action | Action Config | Configuration | Single tap action for item. | | double_tap_action | Action Config | Configuration | Double tap action for item. | | unit_of_measurement | string | W , kW | Default: %; The Unit of the sensor value. Should be detected automatically! | | upper_bound | number | 100 | Upper bound for bar fill scaling (default: 100). Values at or above this show a full bar. |

Cards 🃏

Cards couldn't yet be included in the Visual editor in a nice way. I am working on it though. Feel free to open a Issue with suggestions. To add a card you can simply replace the center part in the Code Editor. Be aware though: While you can switch between none and card without any issues, switching to Bars will override your settings.

For example you could insert a glance card:

center:
  type: card
  card:
    type: glance
    entities:
      - sensor.any_Sensor

Entity Configuration ⚙️

There are alot of settings you can customize your sensors with:

Setting type example description
attribute string deferredWatts A Sensor can have multiple attributes. If one of them is your desired value to display, add it here.
arrow_color object {smaller:'red'} You can Change the Color of the arrow dependant on the value. (Bigger, Equal and Smaller)
calc_excluded boolean true If the Item should be excluded from ratio/autarky calculations.
color_threshold number 0, -100, 420.69 The value at which the coloring logic switches on. (default: 0)
consumer boolean true Marks this entity as a power consumer. Negative values contribute to the consumption total used by autarky/ratio bars.
decimals number 0, 2 The Number of Decimals shown. (default: 2)
display_abs boolean true Display values as absolute (non-negative) numbers. Defaults to true when a preset is used.
double_tap_action Action Config Configuration Double tap action for item.
entity string sensor.e3dc_grid You can specify the entity_id here as well.
hide_arrows bool true Toggles the visibility of the arrows.
icon string mdi:dishwasher Why not change the displayed Icon to any MDI one?
icon_color object {smaller:'red'} You can Change the Color of the icon dependant on the value. (Bigger, Equal and Smaller)
invert_arrow bool true This will change the arrows direction to the opposite one.
invert_value bool false This will invert the value received from HASS. This affects calculations as well!
name string dishwasher Feel free to change the displayed name of the element.
producer boolean true Marks this entity as a power producer. Positive values contribute to the production total used by autarky/ratio bars.
secondary_info_attribute string min_temp Requires secondary_info_entity. Displays the attribute value instead of the sensor state.
secondary_info_decimals number 1

Extension points exported contracts — how you extend this code

ActionHandlerMock (Interface)
(no doc) [2 implementers]
src/action-handler.ts
HASSDomEvents (Interface)
(no doc)
src/types.ts
NavigateOptions (Interface)
(no doc)
src/utils/hass-types/navigate.ts
HaDurationData (Interface)
(no doc)
src/editor/ha-form.ts
ActionHandlerElement (Interface)
(no doc)
src/action-handler.ts
PDCConfig (Interface)
(no doc)
src/types.ts
ActionHandlerOptions (Interface)
(no doc)
src/utils/hass-types/action_handler.ts
HaFormBaseSchema (Interface)
(no doc)
src/editor/ha-form.ts

Core symbols most depended-on inside this repo

localize
called by 23
src/localize/localize.ts
fireEvent
called by 17
src/utils/hass-types/fire_event.ts
fireCustomEvent
called by 10
src/utils/index.ts
_state
called by 8
src/power-distribution-card.ts
forwardHaptic
called by 8
src/utils/hass-types/haptics.ts
_val
called by 5
src/power-distribution-card.ts
showToast
called by 5
src/utils/hass-types/toast.ts
_formatValue
called by 4
src/power-distribution-card.ts

Shape

Interface 142
Method 76
Function 38
Class 14
Enum 5

Languages

TypeScript100%

Modules by API surface

src/editor/ha-form.ts54 symbols
src/utils/hass-types/homeassistant.ts45 symbols
src/power-distribution-card.ts22 symbols
src/utils/hass-types/lovelace.ts18 symbols
src/editor/editor.ts16 symbols
src/action-handler.ts13 symbols
src/utils/hass-types/action.ts12 symbols
src/types.ts12 symbols
src/editor/items-editor.ts11 symbols
src/editor/bar-editor.ts10 symbols
src/utils/hass-types/show-dialog-box.ts7 symbols
src/editor/item-editor.ts7 symbols

For agents

$ claude mcp add power-distribution-card \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page