Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initial release #2

Merged
merged 29 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6f2b228
got most of the things I want working to work
ulic75 Apr 25, 2022
5b59ef2
set line paths back to original settings
ulic75 Apr 25, 2022
4698665
remove carbon stuffs
ulic75 Apr 25, 2022
942fcce
create some reusable code and add battery to home
ulic75 Apr 25, 2022
a9f7bc5
simplify naming and create reusable function for getting a number to …
ulic75 Apr 25, 2022
7eef86e
set animation duration to 3s until I can find a nice calculation
ulic75 Apr 26, 2022
ed09704
add grid to home circle
ulic75 Apr 26, 2022
3b787cd
do actual rounding instead of just formating
ulic75 Apr 26, 2022
ce4058a
ensure hass exists
ulic75 Apr 26, 2022
7cf57b8
huge refactor to go to from 7 entities to 4
ulic75 Apr 26, 2022
ff816a0
a decent duration calc
ulic75 Apr 26, 2022
d22d7d5
always show in/out values on battery and grid
ulic75 Apr 26, 2022
e03d18c
implement home circumference border
ulic75 Apr 26, 2022
79611d2
remove battery to grid line
ulic75 Apr 26, 2022
b64b2a1
circle rate tweaks
ulic75 Apr 27, 2022
227d366
move each line/circle flow into it's own svg
ulic75 Apr 27, 2022
6676365
centralize duration calculations
ulic75 Apr 27, 2022
007462d
fix type in flow id
ulic75 Apr 27, 2022
718db67
smooth out duration changes
ulic75 Apr 27, 2022
2d2daa1
add some workflows and hacs stuff
ulic75 Apr 27, 2022
6c3a691
remove hacs integration validation
ulic75 Apr 27, 2022
06b6c98
fix yaml typo
ulic75 Apr 27, 2022
40e56d0
Add build script
ulic75 Apr 27, 2022
067c798
add readme
ulic75 Apr 27, 2022
fae4939
add description and keywords
ulic75 Apr 27, 2022
785db02
update hacs file
ulic75 Apr 27, 2022
84a70d9
add more scripts
ulic75 Apr 27, 2022
2d2cb77
add semantic-release
ulic75 Apr 27, 2022
9aa6633
Update README.md
ulic75 Apr 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ module.exports = {
"@typescript-eslint/no-unused-vars": ["warn"],
"class-methods-use-this": "off",
"import/no-unresolved": "off",
"import/extensions": [
"error",
"always",
{
ignorePackages: true,
},
],
"no-use-before-define": ["error", { functions: false }],
"lines-between-class-members": "off",
},
};
33 changes: 33 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI
on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache pnpm modules
id: cache-modules
uses: actions/cache@v2
with:
path: |
~/.pnpm-store
**/node_modules
key: ${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'rollup.config.js') }}
restore-keys: |
${{ runner.os }}-

- name: Setup pnpm
uses: pnpm/action-setup@v2.2.1
with:
version: latest
run_install: false

- name: Install Packages
if: steps.cache-modules.outputs.cache-hit != 'true'
run: pnpm install

- name: Build
run: pnpm build
44 changes: 44 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Release

on: workflow_dispatch

jobs:
release-bundle:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev'

outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }}

steps:
- uses: actions/checkout@v3

- name: Cache pnpm modules
id: cache-modules
uses: actions/cache@v2
with:
path: |
~/.pnpm-store
**/node_modules
key: ${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'rollup.config.js') }}
restore-keys: |
${{ runner.os }}-

- name: Setup pnpm
uses: pnpm/action-setup@v2.2.1
with:
version: latest
run_install: false

- name: Install Packages
if: steps.cache-modules.outputs.cache-hit != 'true'
run: pnpm install

- name: Build
run: pnpm build

- name: Release
run: pnpx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 18 additions & 0 deletions .github/workflows/semantic-pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Semantic PR"
description: Ensure your PR title matches the Conventional Commits spec (https://www.conventionalcommits.org/).

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: HACS Validation

on:
pull_request:
jobs:
hacs:
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: "actions/checkout@v2"
- name: Validate HACS
uses: "hacs/action@main"
with:
category: "plugin"
19 changes: 19 additions & 0 deletions .releaserc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
branches: ["main", { name: "dev", prerelease: true }],
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/git",
{
assets: ["CHANGELOG.md", "README.md", "package.json", "pnpm-lock.yaml"],
},
],
[
"@semantic-release/github",
{
assets: "dist/*.js",
},
],
],
};
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Realtime Energy Distribution Card

This card for [Home Assistant](https://github.com/home-assistant/home-assistant) Dashboard card is designed to mimic the historic distribution card included by Home Assistant.

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

![realtime-distribution-preview](https://user-images.githubusercontent.com/5641964/165636264-dc2e02ed-e550-4167-9ce4-3dcbd7a84272.png)

## Install

### HACS (recommended)

This card is available in [HACS](https://hacs.xyz/) (Home Assistant Community Store).
<small>_HACS is a third party community store and is not included in Home Assistant out of the box._</small>

### Manual install

1. Download and copy `realtime-energy-distribution-card.js` from the [latest release](https://github.com/ulic75/realtime-energy-distribution-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 `realtime-energy-distribution-card.js` inside your `configuration.yaml`:

```yaml
resources:
- url: /local/realtime-energy-distribution-card.js
type: module
```

Else, if you prefer the graphical editor, use the menu to add the resource:

1. Make sure, advanced mode is enabled in your user profile (click on your user name to get there)
2. Navigate to Configuration -> Dashboards -> Resources Tab. Hit (+ ADD RESOURCE) icon
3. Enter URL `/local/realtime-energy-distribution-card.js` and select type "JavaScript Module".
(Use `/hacsfiles/realtime-energy-distribution-card/realtime-energy-distribution-card.js` and select "JavaScript Module" for HACS install)
4. Restart Home Assistant.

## Using the card

We recommend looking at the [Example usage section](#example-usage) to understand the basics to configure this card.
(also) pay attention to the **required** options mentioned below.

### Options

#### Card options

| Name | Type | Default | Description |
| ------------------------- | ------ | ------- | ------------------------------------------------------------------------------------------------------- |
| type **_(required)_** | string | | `custom:realtime-energy-distribution-card`. |
| entities **_(required)_** | map | | One or more sensor entities in a list, see [entities map](#entities-map) for additional entity options. |
| |

#### Entities map

| Name | Unit | Description |
| ------------------------ | :--: | -------------------------------------------------------------------------------------- |
| battery **_(required)_** | kW | Entity providing a positive value when charging and a negative value when discharging. |
| battery_charge | % | Entity providing the current percentage of charge on the battery. |
| grid **_(required)_** | kW | Entity providing a positive value when consuming and a negative value when producting. |
| solar **_(required)_** | kW | Entity providing a value of generation. |

### Example usage

```yaml
type: custom:realtime-energy-distribution-card
title: Realtime Distribution
entities:
battery: sensor.powerwall_battery_now
battery_charge: sensor.powerwall_charge
grid: sensor.powerwall_site_now
solar: sensor.powerwall_solar_now
```
4 changes: 4 additions & 0 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "realtime-energy-distribution-card",
"render_readme": true
}
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"name": "realtime-energy-distribution-card",
"version": "1.0.0",
"description": "",
"description": "A realtime energy distribution card for Home Assistant",
"keywords": [
"home-assistant",
"homeassistant",
"hass",
"dashboard",
"custom-cards"
],
"main": "index.js",
"repository": {
"type": "git",
Expand All @@ -13,6 +20,11 @@
"url": "https://github.com/ulic75/realtime-energy-distribution-card/issues"
},
"homepage": "https://github.com/ulic75/realtime-energy-distribution-card#readme",
"scripts": {
"build": "rollup -c",
"lint": "eslint src/*",
"watch": "rollup -wc"
},
"dependencies": {
"@mdi/js": "^6.6.96",
"custom-card-helpers": "^1.9.0",
Expand All @@ -29,6 +41,7 @@
"@rollup/plugin-commonjs": "^21.1.0",
"@rollup/plugin-node-resolve": "^13.2.1",
"@rollup/plugin-typescript": "^8.3.2",
"@semantic-release/git": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"eslint": "^8.14.0",
Expand All @@ -37,6 +50,7 @@
"rollup": "^2.70.2",
"rollup-plugin-serve": "^1.1.0",
"rollup-plugin-terser": "^7.0.2",
"semantic-release": "^19.0.2",
"typescript": "^4.6.3"
}
}
Loading