Skip to content

Commit

Permalink
Initial takeover commit
Browse files Browse the repository at this point in the history
  • Loading branch information
flyrmyr committed Nov 4, 2022
1 parent 96342dc commit 879d538
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 147 deletions.
8 changes: 4 additions & 4 deletions .releaserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ module.exports = {
{
replacements: [
{
files: ["dist/power-flow-card.js"],
from: /Power Flow Card v(\d+\.\d+\.\d+)/,
to: "Power Flow Card v${nextRelease.version}",
files: ["dist/system-flow-card.js"],
from: /System Flow Card v(\d+\.\d+\.\d+)/,
to: "System Flow Card v${nextRelease.version}",
results: [
{
file: "dist/power-flow-card.js",
file: "dist/system-flow-card.js",
hasChanged: true,
numMatches: 2,
numReplacements: 2,
Expand Down
108 changes: 0 additions & 108 deletions CHANGELOG.md

This file was deleted.

30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Power Flow Card
# System Flow Card

[![hacs_badge](https://img.shields.io/badge/HACS-Default-41BDF5.svg?style=flat-square)](https://github.com/hacs/integration)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/ulic75/power-flow-card?style=flat-square)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ulic75/power-flow-card/CI?style=flat-square)
![GitHub all releases](https://img.shields.io/github/downloads/ulic75/power-flow-card/total?style=flat-square)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/ulic75/system-flow-card?style=flat-square)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ulic75/system-flow-card/CI?style=flat-square)
![GitHub all releases](https://img.shields.io/github/downloads/ulic75/system-flow-card/total?style=flat-square)
[![ko-fi support](https://img.shields.io/badge/support-me-ff5e5b?style=flat-square&logo=ko-fi)](https://ko-fi.com/ulic75)

This card for [Home Assistant](https://home-assistant.io/) Dashboards is designed to provide power distribution in an identical style to the Official Energy Distribution card included by Home Assistant.
This card for [Home Assistant](https://home-assistant.io/) Dashboards is designed to provide system distribution in an identical style to the Official Energy Distribution card included by Home Assistant.

![power-flow-2 4 0](https://user-images.githubusercontent.com/5641964/169116530-f5ddefc4-6ee1-46cc-b89e-a8d8fabaa892.png)
![system-flow-2 4 0](https://user-images.githubusercontent.com/5641964/169116530-f5ddefc4-6ee1-46cc-b89e-a8d8fabaa892.png)

## Install

Expand All @@ -19,17 +19,17 @@ This card is available in [HACS](https://hacs.xyz/) (Home Assistant Community St

### Manual install

1. Download and copy `power-flow-card.js` from the [latest release](https://github.com/ulic75/power-flow-card/releases/latest) into your `config/www` directory.
1. Download and copy `system-flow-card.js` from the [latest release](https://github.com/ulic75/system-flow-card/releases/latest) into your `config/www` directory.

2. Add the resource reference as decribed below.

### Add resource reference

If you configure Dashboards via YAML, add a reference to `power-flow-card.js` inside your `configuration.yaml`:
If you configure Dashboards via YAML, add a reference to `system-flow-card.js` inside your `configuration.yaml`:

```yaml
resources:
- url: /local/power-flow-card.js
- url: /local/system-flow-card.js
type: module
```

Expand All @@ -40,8 +40,8 @@ Else, if you prefer the graphical editor, use the menu to add the resource:
3. Click three dot icon
4. Select Resources
5. Hit (+ ADD RESOURCE) icon
6. Enter URL `/local/power-flow-card.js` and select type "JavaScript Module".
(Use `/hacsfiles/power-flow-card/power-flow-card.js` and select "JavaScript Module" for HACS install if HACS didn't do it already)
6. Enter URL `/local/system-flow-card.js` and select type "JavaScript Module".
(Use `/hacsfiles/system-flow-card/system-flow-card.js` and select "JavaScript Module" for HACS install if HACS didn't do it already)

## Using the card

Expand All @@ -54,7 +54,7 @@ I recommend looking at the [Example usage section](#example-usage) to understand

| Name | Type | Default | Description |
| ----------------- | -------- | :----------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| type | `string` | **required** | `custom:power-flow-card`. |
| type | `string` | **required** | `custom:system-flow-card`. |
| entities | `object` | **required** | One or more sensor entities, see [entities object](#entities-object) for additional entity options. |
| title | `string` | | Shows a title at the top of the card. |
| dashboard_link | `string` | | Shows a link to an Energy Dashboard. Should be a url path to location of your choice. If you wanted to link to the built-in dashboard you would enter `/energy` for example. |
Expand Down Expand Up @@ -92,7 +92,7 @@ Can be use with either Grid or Battery configuration. The same `unit_of_measurem
Using combined entities for grid, battery and solor that support positive state values for consumption and negative state values for production.

```yaml
type: custom:power-flow-card
type: custom:system-flow-card
entities:
battery: sensor.battery_in_out
battery_charge: sensor.battery_percent
Expand All @@ -105,7 +105,7 @@ entities:
Using combined entites as above but where the battery and grid entities are inverted (negative = consumption and positive = production).

```yaml
type: custom:power-flow-card
type: custom:system-flow-card
entities:
battery: sensor.battery_in_out
battery_charge: sensor.battery_percent
Expand All @@ -119,7 +119,7 @@ inverted_entities: battery, grid
Using split entities for grid and battery where each consumption and production entity state has a positive value.

```yaml
type: custom:power-flow-card
type: custom:system-flow-card
entities:
battery:
consumption: sensor.battery_out
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Power Flow Card",
"name": "System Flow Card",
"render_readme": true,
"homeassistant": "2021.8.0"
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "power-distribution-card",
"name": "system-flow-card",
"version": "2.5.1",
"description": "A power distribution card for Home Assistant",
"description": "A system flow card for Home Assistant",
"keywords": [
"home-assistant",
"homeassistant",
Expand All @@ -12,14 +12,14 @@
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/ulic75/power-distribution-card.git"
"url": "git+https://github.com/flyrmyr/system-flow-card.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/ulic75/power-distribution-card/issues"
"url": "https://github.com/flyrmyr/system-flow-card/issues"
},
"homepage": "https://github.com/ulic75/power-distribution-card#readme",
"homepage": "https://github.com/flyrmyr/system-flow-card#readme",
"scripts": {
"build": "rollup -c",
"lint": "eslint src/*",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const serveOptions = {

export default [
{
input: "src/power-flow-card.ts",
input: "src/system-flow-card.ts",
output: [
{
dir: "./dist",
Expand Down
6 changes: 3 additions & 3 deletions src/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { version } from "../package.json";

// Log Version
console.groupCollapsed(
`%c⚡ Power Flow Card v${version} is installed`,
`%c⚡ System Flow Card v${version} is installed`,
"color: #488fc2; font-weight: bold"
);
console.log("Readme:", "https://github.com/ulic75/power-flow-card");
console.log("Readme:", "https://github.com/ulic75/system-flow-card");
console.groupEnd();

export const logError = debounce((error: string) => {
console.log(
`%c⚡ Power Flow Card v${version} %cError: ${error}`,
`%c⚡ System Flow Card v${version} %cError: ${error}`,
"color: #488fc2; font-weight: bold",
"color: #b33a3a; font-weight: normal"
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LovelaceCardConfig } from "custom-card-helpers";
import { ComboEntity } from "./type.js";

export interface PowerFlowCardConfig extends LovelaceCardConfig {
export interface SystemFlowCardConfig extends LovelaceCardConfig {
entities: {
battery?: string | ComboEntity;
battery_charge?: string;
Expand Down
18 changes: 9 additions & 9 deletions src/power-flow-card.ts → src/system-flow-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { formatNumber, HomeAssistant } from "custom-card-helpers";
import { css, html, LitElement, svg, TemplateResult } from "lit";
import { customElement, property, query, state } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.js";
import { PowerFlowCardConfig } from "./power-flow-card-config.js";
import { SystemFlowCardConfig } from "./system-flow-card-config.js";
import {
coerceNumber,
coerceStringArray,
Expand All @@ -33,10 +33,10 @@ const MAX_FLOW_RATE = 6;
const MIN_FLOW_RATE = 0.75;
const W_DECIMALS = 1;

@customElement("power-flow-card")
export class PowerFlowCard extends LitElement {
@customElement("system-flow-card")
export class SystemFlowCard extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@state() private _config?: PowerFlowCardConfig;
@state() private _config?: SystemFlowCardConfig;

@query("#battery-grid-flow") batteryGridFlow?: SVGSVGElement;
@query("#battery-home-flow") batteryToHomeFlow?: SVGSVGElement;
Expand All @@ -45,7 +45,7 @@ export class PowerFlowCard extends LitElement {
@query("#solar-grid-flow") solarToGridFlow?: SVGSVGElement;
@query("#solar-home-flow") solarToHomeFlow?: SVGSVGElement;

setConfig(config: PowerFlowCardConfig): void {
setConfig(config: SystemFlowCardConfig): void {
if (
!config.entities ||
(!config.entities.battery &&
Expand Down Expand Up @@ -907,14 +907,14 @@ const windowWithCards = window as unknown as Window & {
};
windowWithCards.customCards = windowWithCards.customCards || [];
windowWithCards.customCards.push({
type: "power-flow-card",
name: "Power Flow Card",
type: "system-flow-card",
name: "System Flow Card",
description:
"A power distribution card inspired by the official Energy Distribution card for Home Assistant",
"A system distribution card inspired by the official Energy Distribution card for Home Assistant",
});

declare global {
interface HTMLElementTagNameMap {
"power-flow-card": PowerFlowCard;
"system-flow-card": SystemFlowCard;
}
}

0 comments on commit 879d538

Please sign in to comment.