mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-15 04:09:25 +00:00
Compare commits
258 Commits
restructur
...
20230302.0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a57609380a | ||
![]() |
84affcce33 | ||
![]() |
d113d44d5a | ||
![]() |
afe1b7ef59 | ||
![]() |
000e2ef7fc | ||
![]() |
15394516af | ||
![]() |
a0033d9112 | ||
![]() |
895ebcdb2d | ||
![]() |
e7044ce40c | ||
![]() |
a0e71b9478 | ||
![]() |
db1f81e0ef | ||
![]() |
657a74e8ad | ||
![]() |
f803bbadc9 | ||
![]() |
2ab8bba4b0 | ||
![]() |
1a1c00ba62 | ||
![]() |
7b4850b5d6 | ||
![]() |
42688e100c | ||
![]() |
d32cde3cf8 | ||
![]() |
34c15d96c1 | ||
![]() |
0d869d53e3 | ||
![]() |
ccf670465b | ||
![]() |
4a9ec7233d | ||
![]() |
c747ab7605 | ||
![]() |
9c703ab469 | ||
![]() |
e3b797e85c | ||
![]() |
a5541996d7 | ||
![]() |
ea95fb98aa | ||
![]() |
4b428a60cd | ||
![]() |
9ce4563dd4 | ||
![]() |
4031d9cc78 | ||
![]() |
20f2f5b317 | ||
![]() |
6af57fa2cd | ||
![]() |
17e6e132d1 | ||
![]() |
67d064db28 | ||
![]() |
e0df5e4631 | ||
![]() |
a8a85a2af6 | ||
![]() |
702c24d908 | ||
![]() |
5eafecf95d | ||
![]() |
7f644530e4 | ||
![]() |
3aea416175 | ||
![]() |
868c414759 | ||
![]() |
f4848964c3 | ||
![]() |
b10c95e803 | ||
![]() |
25cf879793 | ||
![]() |
ba3b265b9a | ||
![]() |
7568ae5964 | ||
![]() |
d4ace99de3 | ||
![]() |
087bda22d4 | ||
![]() |
83ffc754c9 | ||
![]() |
7a8ea4a9f9 | ||
![]() |
df8f46388f | ||
![]() |
650f32ba6d | ||
![]() |
01ec9aaf96 | ||
![]() |
682f383c9e | ||
![]() |
7724fa02d7 | ||
![]() |
0a49bf2d4c | ||
![]() |
dd6437376d | ||
![]() |
12478a2177 | ||
![]() |
96a261d831 | ||
![]() |
1095088d42 | ||
![]() |
43541f9754 | ||
![]() |
f69ae84cc6 | ||
![]() |
7173b30716 | ||
![]() |
f92deb3225 | ||
![]() |
2e86d739fc | ||
![]() |
7e0c80ae24 | ||
![]() |
3b5fe7fd9f | ||
![]() |
03e3f161f7 | ||
![]() |
ab231eec4f | ||
![]() |
7041d322d6 | ||
![]() |
f786539f15 | ||
![]() |
971d2ff1c2 | ||
![]() |
19d721f193 | ||
![]() |
5629346fc3 | ||
![]() |
ca6ade4858 | ||
![]() |
6b9e0405d0 | ||
![]() |
e46803cb4e | ||
![]() |
e697a09e53 | ||
![]() |
3158e6043d | ||
![]() |
2c61c960bc | ||
![]() |
91493e109e | ||
![]() |
2bd6d9d202 | ||
![]() |
dfb74fd576 | ||
![]() |
fef74b0b8a | ||
![]() |
0fc36823da | ||
![]() |
25d8550dd7 | ||
![]() |
e44ccb0574 | ||
![]() |
d00467a39c | ||
![]() |
4e841c4a06 | ||
![]() |
cf304d91c7 | ||
![]() |
3066a9d10d | ||
![]() |
3e72b1cb5d | ||
![]() |
a03c335331 | ||
![]() |
6e153cb307 | ||
![]() |
8ed4914232 | ||
![]() |
88205a94d6 | ||
![]() |
0b54e60b91 | ||
![]() |
a469a92601 | ||
![]() |
77f7a5647d | ||
![]() |
850609b1d0 | ||
![]() |
c95a600fbb | ||
![]() |
1cffe4f9bf | ||
![]() |
2cae0cd54f | ||
![]() |
d56f35e6fd | ||
![]() |
be8cb8fb3f | ||
![]() |
74bc6eeda8 | ||
![]() |
fbf084bf00 | ||
![]() |
76f90e1449 | ||
![]() |
404199bb19 | ||
![]() |
dfbe32018a | ||
![]() |
48dcd98634 | ||
![]() |
658ce80801 | ||
![]() |
7adb49c772 | ||
![]() |
05f2fb896c | ||
![]() |
e21816be52 | ||
![]() |
bef586efb3 | ||
![]() |
5f9f51f92d | ||
![]() |
cabbbcf9f3 | ||
![]() |
d5fb924cb4 | ||
![]() |
8754947133 | ||
![]() |
9c42eb5130 | ||
![]() |
1ab1cf0fab | ||
![]() |
e91a477b8b | ||
![]() |
c4160e8368 | ||
![]() |
cf377558ae | ||
![]() |
6986c1c8b7 | ||
![]() |
6c9d6755f1 | ||
![]() |
747b9e2ae1 | ||
![]() |
8f22b3c1fa | ||
![]() |
054e4165f8 | ||
![]() |
82b2c6aa06 | ||
![]() |
07d84a32fd | ||
![]() |
d37e53b4a5 | ||
![]() |
252e58d63b | ||
![]() |
d98a26146b | ||
![]() |
8631139133 | ||
![]() |
d5578c236f | ||
![]() |
de5199e34c | ||
![]() |
980758528a | ||
![]() |
0fdb012e24 | ||
![]() |
3b1bc37f53 | ||
![]() |
cb85bc054a | ||
![]() |
94dd3c95ff | ||
![]() |
6e55077cd3 | ||
![]() |
ff47d7d408 | ||
![]() |
a9180e062c | ||
![]() |
9d918b727c | ||
![]() |
7c65bb9791 | ||
![]() |
1e2c21d49e | ||
![]() |
e81f596d76 | ||
![]() |
ec66e8331e | ||
![]() |
a13e2af17a | ||
![]() |
1e7fe59519 | ||
![]() |
d8fe7d9a01 | ||
![]() |
1a335a18a4 | ||
![]() |
00a40a5c51 | ||
![]() |
74512298d2 | ||
![]() |
bf5eeba0a5 | ||
![]() |
859e69d373 | ||
![]() |
1c5b476bda | ||
![]() |
714c6aab98 | ||
![]() |
b409d0ff88 | ||
![]() |
f74aa7c7e6 | ||
![]() |
a325d32d09 | ||
![]() |
4a10c722ab | ||
![]() |
d1b95ba36b | ||
![]() |
e2bfaf2448 | ||
![]() |
4e74a652b3 | ||
![]() |
24f6bb5c93 | ||
![]() |
eec4760593 | ||
![]() |
bc572a5749 | ||
![]() |
15cf003b46 | ||
![]() |
050ed145bf | ||
![]() |
1550895d86 | ||
![]() |
7e92d62936 | ||
![]() |
6c2a767896 | ||
![]() |
f19c50a002 | ||
![]() |
222a01d86f | ||
![]() |
5f6d0bc846 | ||
![]() |
74b12b8092 | ||
![]() |
1beeb0e5e8 | ||
![]() |
b2bfb1fdcb | ||
![]() |
c19cba85ec | ||
![]() |
09f0899fe4 | ||
![]() |
d1294edf34 | ||
![]() |
47fcd253b1 | ||
![]() |
a74c05a004 | ||
![]() |
251b2540c7 | ||
![]() |
3298bdd5a3 | ||
![]() |
d570d063c7 | ||
![]() |
c6eee9bf74 | ||
![]() |
84902bd01f | ||
![]() |
5548436678 | ||
![]() |
e6dc475310 | ||
![]() |
9f6d9d8b0b | ||
![]() |
68d1ef56db | ||
![]() |
57f7dfb648 | ||
![]() |
5b504bf9ce | ||
![]() |
e47b59f826 | ||
![]() |
cfbab03f76 | ||
![]() |
791fd102c6 | ||
![]() |
dded380076 | ||
![]() |
2c064c53cd | ||
![]() |
2511bad902 | ||
![]() |
095040af45 | ||
![]() |
b277e946c3 | ||
![]() |
1cf140c16c | ||
![]() |
adb65176f0 | ||
![]() |
52d869f5b8 | ||
![]() |
c7e7e14f32 | ||
![]() |
e6de8ec94d | ||
![]() |
51de22daa1 | ||
![]() |
f0d53aab7b | ||
![]() |
47b5ff7839 | ||
![]() |
6af3361c55 | ||
![]() |
3427595747 | ||
![]() |
9f3e2920f3 | ||
![]() |
46e152dc53 | ||
![]() |
0e06267055 | ||
![]() |
ec3a779a82 | ||
![]() |
7e7c6aa053 | ||
![]() |
4bce4152d3 | ||
![]() |
57289b0bbe | ||
![]() |
5aeaa65a89 | ||
![]() |
596d371781 | ||
![]() |
7348bbbbe5 | ||
![]() |
383b18b2af | ||
![]() |
b38ae0f754 | ||
![]() |
7ff681d43e | ||
![]() |
2663be188e | ||
![]() |
6f68134da3 | ||
![]() |
3d1151df4d | ||
![]() |
63a35c9d68 | ||
![]() |
1838f6184b | ||
![]() |
ca20a251b5 | ||
![]() |
8212a5a48c | ||
![]() |
cb00535683 | ||
![]() |
549d893407 | ||
![]() |
c1ed00a3f1 | ||
![]() |
41420c3af3 | ||
![]() |
9220d65f78 | ||
![]() |
acf9bca038 | ||
![]() |
a57c15c6f0 | ||
![]() |
8642478e8a | ||
![]() |
3af808ffa9 | ||
![]() |
ac17d0293e | ||
![]() |
7e441b5ade | ||
![]() |
82ed14e705 | ||
![]() |
169d8ac75c | ||
![]() |
6226a7f28d | ||
![]() |
30e6a1a57e | ||
![]() |
f332edc87d | ||
![]() |
eb49785557 | ||
![]() |
0af92b9bd1 | ||
![]() |
6945f99a34 | ||
![]() |
bbb9cfb2c2 | ||
![]() |
819366243f | ||
![]() |
51a45dd3cf |
13
.devcontainer/Dockerfile
Normal file
13
.devcontainer/Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.148.1/containers/python-3/.devcontainer/base.Dockerfile
|
||||||
|
FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.10
|
||||||
|
|
||||||
|
ENV \
|
||||||
|
DEBIAN_FRONTEND=noninteractive \
|
||||||
|
DEVCONTAINER=true \
|
||||||
|
PATH=$PATH:./node_modules/.bin
|
||||||
|
|
||||||
|
# Install nvm
|
||||||
|
COPY .nvmrc /tmp/.nvmrc
|
||||||
|
RUN \
|
||||||
|
su vscode -c \
|
||||||
|
"source /usr/local/share/nvm/nvm.sh && nvm install $(cat /tmp/.nvmrc) 2>&1"
|
@@ -1,20 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "Home Assistant Frontend",
|
"name": "Home Assistant Frontend",
|
||||||
"image": "mcr.microsoft.com/devcontainers/python:0-3.10",
|
"build": {
|
||||||
|
"dockerfile": "Dockerfile",
|
||||||
|
"context": ".."
|
||||||
|
},
|
||||||
"appPort": "8124:8123",
|
"appPort": "8124:8123",
|
||||||
"postCreateCommand": "script/bootstrap",
|
"postCreateCommand": "script/bootstrap",
|
||||||
"containerEnv": {
|
"containerEnv": {
|
||||||
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}",
|
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
|
||||||
"DEVCONTAINER": "true"
|
|
||||||
},
|
|
||||||
"remoteUser": "vscode",
|
|
||||||
"remoteEnv": {
|
|
||||||
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/node_modules/.bin:/home/vscode/.local/bin"
|
|
||||||
},
|
|
||||||
"features": {
|
|
||||||
"ghcr.io/devcontainers/features/node:1": {
|
|
||||||
"version": "16"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"customizations": {
|
"customizations": {
|
||||||
"vscode": {
|
"vscode": {
|
@@ -5,6 +5,7 @@
|
|||||||
"plugin:@typescript-eslint/recommended",
|
"plugin:@typescript-eslint/recommended",
|
||||||
"plugin:wc/recommended",
|
"plugin:wc/recommended",
|
||||||
"plugin:lit/all",
|
"plugin:lit/all",
|
||||||
|
"plugin:lit-a11y/recommended",
|
||||||
"prettier"
|
"prettier"
|
||||||
],
|
],
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
@@ -65,7 +66,10 @@
|
|||||||
"import/extensions": [
|
"import/extensions": [
|
||||||
"error",
|
"error",
|
||||||
"ignorePackages",
|
"ignorePackages",
|
||||||
{ "ts": "never", "js": "never" }
|
{
|
||||||
|
"ts": "never",
|
||||||
|
"js": "never"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"no-restricted-syntax": ["error", "LabeledStatement", "WithStatement"],
|
"no-restricted-syntax": ["error", "LabeledStatement", "WithStatement"],
|
||||||
"object-curly-newline": "off",
|
"object-curly-newline": "off",
|
||||||
@@ -112,7 +116,14 @@
|
|||||||
],
|
],
|
||||||
"unused-imports/no-unused-imports": "error",
|
"unused-imports/no-unused-imports": "error",
|
||||||
"lit/attribute-value-entities": "off",
|
"lit/attribute-value-entities": "off",
|
||||||
"lit/no-template-map": "off"
|
"lit/no-template-map": "off",
|
||||||
|
"lit/no-native-attributes": "warn",
|
||||||
|
"lit/no-this-assign-in-render": "warn",
|
||||||
|
"lit-a11y/click-events-have-key-events": ["off"],
|
||||||
|
"lit-a11y/no-autofocus": "off",
|
||||||
|
"lit-a11y/alt-text": "warn",
|
||||||
|
"lit-a11y/anchor-is-valid": "warn",
|
||||||
|
"lit-a11y/role-has-required-aria-attrs": "warn"
|
||||||
},
|
},
|
||||||
"plugins": ["disable", "unused-imports"],
|
"plugins": ["disable", "unused-imports"],
|
||||||
"processor": "disable/disable"
|
"processor": "disable/disable"
|
||||||
|
6
.github/dependabot.yml
vendored
6
.github/dependabot.yml
vendored
@@ -10,8 +10,10 @@ updates:
|
|||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
time: "06:00"
|
time: "03:00"
|
||||||
open-pull-requests-limit: 5
|
open-pull-requests-limit: 10
|
||||||
|
labels:
|
||||||
|
- "dependencies"
|
||||||
ignore:
|
ignore:
|
||||||
# Ignore rollup and plugins until everything else is updated
|
# Ignore rollup and plugins until everything else is updated
|
||||||
- dependency-name: "*rollup*"
|
- dependency-name: "*rollup*"
|
||||||
|
10
.github/workflows/cast_deployment.yaml
vendored
10
.github/workflows/cast_deployment.yaml
vendored
@@ -33,9 +33,7 @@ jobs:
|
|||||||
cache: yarn
|
cache: yarn
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install
|
run: yarn install --immutable
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
|
|
||||||
- name: Build Cast
|
- name: Build Cast
|
||||||
run: ./node_modules/.bin/gulp build-cast
|
run: ./node_modules/.bin/gulp build-cast
|
||||||
@@ -71,9 +69,7 @@ jobs:
|
|||||||
cache: yarn
|
cache: yarn
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install
|
run: yarn install --immutable
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
|
|
||||||
- name: Build Cast
|
- name: Build Cast
|
||||||
run: ./node_modules/.bin/gulp build-cast
|
run: ./node_modules/.bin/gulp build-cast
|
||||||
@@ -87,4 +83,4 @@ jobs:
|
|||||||
args: deploy --dir=cast/dist --prod
|
args: deploy --dir=cast/dist --prod
|
||||||
env:
|
env:
|
||||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_CAST_SITE_ID }}
|
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_CAST_SITE_ID }}
|
||||||
|
34
.github/workflows/ci.yaml
vendored
34
.github/workflows/ci.yaml
vendored
@@ -15,8 +15,13 @@ env:
|
|||||||
NODE_OPTIONS: --max_old_space_size=6144
|
NODE_OPTIONS: --max_old_space_size=6144
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
|
name: Lint and check format
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
@@ -27,20 +32,19 @@ jobs:
|
|||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install
|
run: yarn install --immutable
|
||||||
env:
|
- name: Check for duplicate dependencies
|
||||||
CI: true
|
run: yarn dedupe --check
|
||||||
- name: Build resources
|
- name: Build resources
|
||||||
run: ./node_modules/.bin/gulp gen-icons-json build-translations build-locale-data gather-gallery-pages
|
run: ./node_modules/.bin/gulp gen-icons-json build-translations build-locale-data gather-gallery-pages
|
||||||
- name: Run eslint
|
- name: Run eslint
|
||||||
run: yarn run lint:eslint
|
run: yarn run lint:eslint --quiet
|
||||||
- name: Run tsc
|
- name: Run tsc
|
||||||
run: yarn run lint:types
|
run: yarn run lint:types
|
||||||
- name: Run prettier
|
- name: Run prettier
|
||||||
run: yarn run lint:prettier
|
run: yarn run lint:prettier
|
||||||
- name: Check for duplicate dependencies
|
|
||||||
run: yarn dedupe --check
|
|
||||||
test:
|
test:
|
||||||
|
name: Run tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
@@ -51,16 +55,15 @@ jobs:
|
|||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install
|
run: yarn install --immutable
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
- name: Build resources
|
- name: Build resources
|
||||||
run: ./node_modules/.bin/gulp build-translations build-locale-data
|
run: ./node_modules/.bin/gulp build-translations build-locale-data
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: yarn run test
|
run: yarn run test
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
name: Build frontend
|
||||||
needs: [lint, test]
|
needs: [lint, test]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
uses: actions/checkout@v3.3.0
|
uses: actions/checkout@v3.3.0
|
||||||
@@ -70,16 +73,15 @@ jobs:
|
|||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install
|
run: yarn install --immutable
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
- name: Build Application
|
- name: Build Application
|
||||||
run: ./node_modules/.bin/gulp build-app
|
run: ./node_modules/.bin/gulp build-app
|
||||||
env:
|
env:
|
||||||
IS_TEST: "true"
|
IS_TEST: "true"
|
||||||
supervisor:
|
supervisor:
|
||||||
runs-on: ubuntu-latest
|
name: Build supervisor
|
||||||
needs: [lint, test]
|
needs: [lint, test]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
uses: actions/checkout@v3.3.0
|
uses: actions/checkout@v3.3.0
|
||||||
@@ -89,9 +91,7 @@ jobs:
|
|||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install
|
run: yarn install --immutable
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
- name: Build Application
|
- name: Build Application
|
||||||
run: ./node_modules/.bin/gulp build-hassio
|
run: ./node_modules/.bin/gulp build-hassio
|
||||||
env:
|
env:
|
||||||
|
10
.github/workflows/demo_deployment.yaml
vendored
10
.github/workflows/demo_deployment.yaml
vendored
@@ -34,9 +34,7 @@ jobs:
|
|||||||
cache: yarn
|
cache: yarn
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install
|
run: yarn install --immutable
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
|
|
||||||
- name: Build Demo
|
- name: Build Demo
|
||||||
run: ./node_modules/.bin/gulp build-demo
|
run: ./node_modules/.bin/gulp build-demo
|
||||||
@@ -72,9 +70,7 @@ jobs:
|
|||||||
cache: yarn
|
cache: yarn
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install
|
run: yarn install --immutable
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
|
|
||||||
- name: Build Demo
|
- name: Build Demo
|
||||||
run: ./node_modules/.bin/gulp build-demo
|
run: ./node_modules/.bin/gulp build-demo
|
||||||
@@ -88,4 +84,4 @@ jobs:
|
|||||||
args: deploy --dir=demo/dist --prod
|
args: deploy --dir=demo/dist --prod
|
||||||
env:
|
env:
|
||||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEMO_SITE_ID }}
|
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEMO_SITE_ID }}
|
||||||
|
4
.github/workflows/design_deployment.yaml
vendored
4
.github/workflows/design_deployment.yaml
vendored
@@ -26,9 +26,7 @@ jobs:
|
|||||||
cache: yarn
|
cache: yarn
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install
|
run: yarn install --immutable
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
|
|
||||||
- name: Build Gallery
|
- name: Build Gallery
|
||||||
run: ./node_modules/.bin/gulp build-gallery
|
run: ./node_modules/.bin/gulp build-gallery
|
||||||
|
4
.github/workflows/design_preview.yaml
vendored
4
.github/workflows/design_preview.yaml
vendored
@@ -31,9 +31,7 @@ jobs:
|
|||||||
cache: yarn
|
cache: yarn
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install
|
run: yarn install --immutable
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
|
|
||||||
- name: Build Gallery
|
- name: Build Gallery
|
||||||
run: ./node_modules/.bin/gulp build-gallery
|
run: ./node_modules/.bin/gulp build-gallery
|
||||||
|
@@ -53,13 +53,25 @@ module.exports.definedVars = ({ isProdBuild, latestBuild, defineOverlay }) => ({
|
|||||||
...defineOverlay,
|
...defineOverlay,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const htmlMinifierOptions = {
|
||||||
|
caseSensitive: true,
|
||||||
|
collapseWhitespace: true,
|
||||||
|
conservativeCollapse: true,
|
||||||
|
decodeEntities: true,
|
||||||
|
removeComments: true,
|
||||||
|
removeRedundantAttributes: true,
|
||||||
|
minifyCSS: {
|
||||||
|
level: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
module.exports.terserOptions = (latestBuild) => ({
|
module.exports.terserOptions = (latestBuild) => ({
|
||||||
safari10: !latestBuild,
|
safari10: !latestBuild,
|
||||||
ecma: latestBuild ? undefined : 5,
|
ecma: latestBuild ? undefined : 5,
|
||||||
output: { comments: false },
|
output: { comments: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports.babelOptions = ({ latestBuild }) => ({
|
module.exports.babelOptions = ({ latestBuild, isProdBuild }) => ({
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
compact: false,
|
compact: false,
|
||||||
presets: [
|
presets: [
|
||||||
@@ -67,7 +79,7 @@ module.exports.babelOptions = ({ latestBuild }) => ({
|
|||||||
"@babel/preset-env",
|
"@babel/preset-env",
|
||||||
{
|
{
|
||||||
useBuiltIns: "entry",
|
useBuiltIns: "entry",
|
||||||
corejs: "3.15",
|
corejs: { version: "3.29", proposals: true },
|
||||||
bugfixes: true,
|
bugfixes: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -93,12 +105,30 @@ module.exports.babelOptions = ({ latestBuild }) => ({
|
|||||||
"@babel/plugin-syntax-import-meta",
|
"@babel/plugin-syntax-import-meta",
|
||||||
"@babel/plugin-syntax-dynamic-import",
|
"@babel/plugin-syntax-dynamic-import",
|
||||||
"@babel/plugin-syntax-top-level-await",
|
"@babel/plugin-syntax-top-level-await",
|
||||||
|
// Support various proposals
|
||||||
"@babel/plugin-proposal-optional-chaining",
|
"@babel/plugin-proposal-optional-chaining",
|
||||||
"@babel/plugin-proposal-nullish-coalescing-operator",
|
"@babel/plugin-proposal-nullish-coalescing-operator",
|
||||||
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: true }],
|
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: true }],
|
||||||
["@babel/plugin-proposal-private-methods", { loose: true }],
|
["@babel/plugin-proposal-private-methods", { loose: true }],
|
||||||
["@babel/plugin-proposal-private-property-in-object", { loose: true }],
|
["@babel/plugin-proposal-private-property-in-object", { loose: true }],
|
||||||
["@babel/plugin-proposal-class-properties", { loose: true }],
|
["@babel/plugin-proposal-class-properties", { loose: true }],
|
||||||
|
// Minify template literals for production
|
||||||
|
isProdBuild && [
|
||||||
|
"template-html-minifier",
|
||||||
|
{
|
||||||
|
modules: {
|
||||||
|
lit: [
|
||||||
|
"html",
|
||||||
|
{ name: "svg", encapsulation: "svg" },
|
||||||
|
{ name: "css", encapsulation: "style" },
|
||||||
|
],
|
||||||
|
"@polymer/polymer/lib/utils/html-tag": ["html"],
|
||||||
|
},
|
||||||
|
strictCSS: true,
|
||||||
|
htmlMinifier: htmlMinifierOptions,
|
||||||
|
failOnError: true, // we can turn this off in case of false positives
|
||||||
|
},
|
||||||
|
],
|
||||||
].filter(Boolean),
|
].filter(Boolean),
|
||||||
exclude: [
|
exclude: [
|
||||||
// \\ for Windows, / for Mac OS and Linux
|
// \\ for Windows, / for Mac OS and Linux
|
||||||
|
@@ -43,7 +43,14 @@ const createRollupConfig = ({
|
|||||||
preserveEntrySignatures: false,
|
preserveEntrySignatures: false,
|
||||||
plugins: [
|
plugins: [
|
||||||
ignore({
|
ignore({
|
||||||
files: bundle.emptyPackages({ latestBuild }),
|
files: bundle
|
||||||
|
.emptyPackages({ latestBuild })
|
||||||
|
// TEMP HACK: Makes Rollup build work again
|
||||||
|
.concat(
|
||||||
|
require.resolve(
|
||||||
|
"@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min"
|
||||||
|
)
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
resolve({
|
resolve({
|
||||||
extensions,
|
extensions,
|
||||||
@@ -54,7 +61,7 @@ const createRollupConfig = ({
|
|||||||
commonjs(),
|
commonjs(),
|
||||||
json(),
|
json(),
|
||||||
babel({
|
babel({
|
||||||
...bundle.babelOptions({ latestBuild }),
|
...bundle.babelOptions({ latestBuild, isProdBuild }),
|
||||||
extensions,
|
extensions,
|
||||||
babelHelpers: isWDS ? "inline" : "bundled",
|
babelHelpers: isWDS ? "inline" : "bundled",
|
||||||
}),
|
}),
|
||||||
|
@@ -51,7 +51,7 @@ const createWebpackConfig = ({
|
|||||||
use: {
|
use: {
|
||||||
loader: "babel-loader",
|
loader: "babel-loader",
|
||||||
options: {
|
options: {
|
||||||
...bundle.babelOptions({ latestBuild }),
|
...bundle.babelOptions({ latestBuild, isProdBuild }),
|
||||||
cacheDirectory: !isProdBuild,
|
cacheDirectory: !isProdBuild,
|
||||||
cacheCompression: false,
|
cacheCompression: false,
|
||||||
},
|
},
|
||||||
|
@@ -181,7 +181,7 @@ class HcCast extends LitElement {
|
|||||||
private async _handlePickView(ev: Event) {
|
private async _handlePickView(ev: Event) {
|
||||||
const path = (ev.currentTarget as any).getAttribute("data-path");
|
const path = (ev.currentTarget as any).getAttribute("data-path");
|
||||||
await ensureConnectedCastSession(this.castManager!, this.auth!);
|
await ensureConnectedCastSession(this.castManager!, this.auth!);
|
||||||
castSendShowLovelaceView(this.castManager, path, this.auth.data.hassUrl);
|
castSendShowLovelaceView(this.castManager, this.auth.data.hassUrl, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _handleLogout() {
|
private async _handleLogout() {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { html, TemplateResult } from "lit";
|
import { html, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { mockHistory } from "../../../../demo/src/stubs/history";
|
import { mockHistory } from "../../../../demo/src/stubs/history";
|
||||||
import { LovelaceConfig } from "../../../../src/data/lovelace";
|
import { LovelaceConfig } from "../../../../src/data/lovelace";
|
||||||
@@ -18,9 +18,9 @@ class HcDemo extends HassElement {
|
|||||||
|
|
||||||
@state() private _lovelaceConfig?: LovelaceConfig;
|
@state() private _lovelaceConfig?: LovelaceConfig;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this._lovelaceConfig) {
|
if (!this._lovelaceConfig) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<hc-lovelace
|
<hc-lovelace
|
||||||
|
@@ -252,6 +252,22 @@ export class HcMain extends HassElement {
|
|||||||
msg.urlPath = null;
|
msg.urlPath = null;
|
||||||
}
|
}
|
||||||
this._lovelacePath = msg.viewPath;
|
this._lovelacePath = msg.viewPath;
|
||||||
|
if (msg.urlPath === "energy") {
|
||||||
|
this._lovelaceConfig = {
|
||||||
|
views: [
|
||||||
|
{
|
||||||
|
strategy: {
|
||||||
|
type: "energy",
|
||||||
|
options: { show_date_selection: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
this._urlPath = "energy";
|
||||||
|
this._lovelacePath = 0;
|
||||||
|
this._sendStatus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!this._unsubLovelace || this._urlPath !== msg.urlPath) {
|
if (!this._unsubLovelace || this._urlPath !== msg.urlPath) {
|
||||||
this._urlPath = msg.urlPath;
|
this._urlPath = msg.urlPath;
|
||||||
this._lovelaceConfig = undefined;
|
this._lovelaceConfig = undefined;
|
||||||
|
@@ -6,6 +6,9 @@ set -e
|
|||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
STATS=1 NODE_ENV=production ../node_modules/.bin/webpack --profile --json > compilation-stats.json
|
export STATS=1
|
||||||
npx webpack-bundle-analyzer compilation-stats.json dist/frontend_latest
|
statsfile="compilation-stats-demo.json"
|
||||||
rm compilation-stats.json
|
|
||||||
|
./node_modules/.bin/webpack-cli --profile --node-env=production --json=$statsfile
|
||||||
|
npx webpack-bundle-analyzer $statsfile dist/frontend_latest
|
||||||
|
rm -f $statsfile
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { mdiTelevision } from "@mdi/js";
|
import { mdiTelevision } from "@mdi/js";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, state } from "lit/decorators";
|
import { customElement, state } from "lit/decorators";
|
||||||
import { CastManager } from "../../../src/cast/cast_manager";
|
import { CastManager } from "../../../src/cast/cast_manager";
|
||||||
import { castSendShowDemo } from "../../../src/cast/receiver_messages";
|
import { castSendShowDemo } from "../../../src/cast/receiver_messages";
|
||||||
@@ -20,12 +20,12 @@ class CastDemoRow extends LitElement implements LovelaceRow {
|
|||||||
// No config possible.
|
// No config possible.
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (
|
if (
|
||||||
!this._castManager ||
|
!this._castManager ||
|
||||||
this._castManager.castState === "NO_DEVICES_AVAILABLE"
|
this._castManager.castState === "NO_DEVICES_AVAILABLE"
|
||||||
) {
|
) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<ha-svg-icon .path=${mdiTelevision}></ha-svg-icon>
|
<ha-svg-icon .path=${mdiTelevision}></ha-svg-icon>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { until } from "lit/directives/until";
|
import { until } from "lit/directives/until";
|
||||||
import "../../../src/components/ha-card";
|
import "../../../src/components/ha-card";
|
||||||
import "../../../src/components/ha-circular-progress";
|
import "../../../src/components/ha-circular-progress";
|
||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
setDemoConfig,
|
setDemoConfig,
|
||||||
} from "../configs/demo-configs";
|
} from "../configs/demo-configs";
|
||||||
|
|
||||||
|
@customElement("ha-demo-card")
|
||||||
export class HADemoCard extends LitElement implements LovelaceCard {
|
export class HADemoCard extends LitElement implements LovelaceCard {
|
||||||
@property({ attribute: false }) public lovelace?: Lovelace;
|
@property({ attribute: false }) public lovelace?: Lovelace;
|
||||||
|
|
||||||
@@ -29,9 +30,9 @@ export class HADemoCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
public setConfig(_config: LovelaceCardConfig) {}
|
public setConfig(_config: LovelaceCardConfig) {}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (this._hidden) {
|
if (this._hidden) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<ha-card>
|
<ha-card>
|
||||||
@@ -154,5 +155,3 @@ declare global {
|
|||||||
"ha-demo-card": HADemoCard;
|
"ha-demo-card": HADemoCard;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define("ha-demo-card", HADemoCard);
|
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
// Compat needs to be first import
|
// Compat needs to be first import
|
||||||
|
import "../../src/resources/compatibility";
|
||||||
|
import { customElement } from "lit/decorators";
|
||||||
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
|
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
|
||||||
import { navigate } from "../../src/common/navigate";
|
import { navigate } from "../../src/common/navigate";
|
||||||
import {
|
import {
|
||||||
@@ -6,7 +8,6 @@ import {
|
|||||||
provideHass,
|
provideHass,
|
||||||
} from "../../src/fake_data/provide_hass";
|
} from "../../src/fake_data/provide_hass";
|
||||||
import { HomeAssistantAppEl } from "../../src/layouts/home-assistant";
|
import { HomeAssistantAppEl } from "../../src/layouts/home-assistant";
|
||||||
import "../../src/resources/compatibility";
|
|
||||||
import { HomeAssistant } from "../../src/types";
|
import { HomeAssistant } from "../../src/types";
|
||||||
import { selectedDemoConfig } from "./configs/demo-configs";
|
import { selectedDemoConfig } from "./configs/demo-configs";
|
||||||
import { mockAuth } from "./stubs/auth";
|
import { mockAuth } from "./stubs/auth";
|
||||||
@@ -26,7 +27,8 @@ import { mockSystemLog } from "./stubs/system_log";
|
|||||||
import { mockTemplate } from "./stubs/template";
|
import { mockTemplate } from "./stubs/template";
|
||||||
import { mockTranslations } from "./stubs/translations";
|
import { mockTranslations } from "./stubs/translations";
|
||||||
|
|
||||||
class HaDemo extends HomeAssistantAppEl {
|
@customElement("ha-demo")
|
||||||
|
export class HaDemo extends HomeAssistantAppEl {
|
||||||
protected async _initializeHass() {
|
protected async _initializeHass() {
|
||||||
const initial: Partial<MockHomeAssistant> = {
|
const initial: Partial<MockHomeAssistant> = {
|
||||||
panelUrl: (this as any)._panelUrl,
|
panelUrl: (this as any)._panelUrl,
|
||||||
@@ -71,6 +73,7 @@ class HaDemo extends HomeAssistantAppEl {
|
|||||||
entity_category: null,
|
entity_category: null,
|
||||||
has_entity_name: false,
|
has_entity_name: false,
|
||||||
unique_id: "co2_intensity",
|
unique_id: "co2_intensity",
|
||||||
|
options: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
config_entry_id: "co2signal",
|
config_entry_id: "co2signal",
|
||||||
@@ -86,6 +89,7 @@ class HaDemo extends HomeAssistantAppEl {
|
|||||||
entity_category: null,
|
entity_category: null,
|
||||||
has_entity_name: false,
|
has_entity_name: false,
|
||||||
unique_id: "grid_fossil_fuel_percentage",
|
unique_id: "grid_fossil_fuel_percentage",
|
||||||
|
options: null,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -121,8 +125,6 @@ class HaDemo extends HomeAssistantAppEl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define("ha-demo", HaDemo);
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"ha-demo": HaDemo;
|
"ha-demo": HaDemo;
|
||||||
|
@@ -66,7 +66,7 @@ const incrementalUnits = ["clients", "queries", "ads"];
|
|||||||
|
|
||||||
export const mockHistory = (mockHass: MockHomeAssistant) => {
|
export const mockHistory = (mockHass: MockHomeAssistant) => {
|
||||||
mockHass.mockAPI(
|
mockHass.mockAPI(
|
||||||
new RegExp("history/period/.+"),
|
/history\/period\/.+/,
|
||||||
(hass, _method, path, _parameters) => {
|
(hass, _method, path, _parameters) => {
|
||||||
const params = parseQuery<HistoryQueryParams>(path.split("?")[1]);
|
const params = parseQuery<HistoryQueryParams>(path.split("?")[1]);
|
||||||
const entities = params.filter_entity_id.split(",");
|
const entities = params.filter_entity_id.split(",");
|
||||||
|
@@ -15,6 +15,7 @@ import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
|||||||
const generateMeanStatistics = (
|
const generateMeanStatistics = (
|
||||||
start: Date,
|
start: Date,
|
||||||
end: Date,
|
end: Date,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/default-param-last
|
||||||
period: "5minute" | "hour" | "day" | "month" = "hour",
|
period: "5minute" | "hour" | "day" | "month" = "hour",
|
||||||
initValue: number,
|
initValue: number,
|
||||||
maxDiff: number
|
maxDiff: number
|
||||||
@@ -51,6 +52,7 @@ const generateMeanStatistics = (
|
|||||||
const generateSumStatistics = (
|
const generateSumStatistics = (
|
||||||
start: Date,
|
start: Date,
|
||||||
end: Date,
|
end: Date,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/default-param-last
|
||||||
period: "5minute" | "hour" | "day" | "month" = "hour",
|
period: "5minute" | "hour" | "day" | "month" = "hour",
|
||||||
initValue: number,
|
initValue: number,
|
||||||
maxDiff: number
|
maxDiff: number
|
||||||
@@ -86,6 +88,7 @@ const generateSumStatistics = (
|
|||||||
const generateCurvedStatistics = (
|
const generateCurvedStatistics = (
|
||||||
start: Date,
|
start: Date,
|
||||||
end: Date,
|
end: Date,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/default-param-last
|
||||||
_period: "5minute" | "hour" | "day" | "month" = "hour",
|
_period: "5minute" | "hour" | "day" | "month" = "hour",
|
||||||
initValue: number,
|
initValue: number,
|
||||||
maxDiff: number,
|
maxDiff: number,
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { html, css } from "lit";
|
import { css, html, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { until } from "lit/directives/until";
|
import { until } from "lit/directives/until";
|
||||||
import { HaMarkdown } from "../../../src/components/ha-markdown";
|
import { HaMarkdown } from "../../../src/components/ha-markdown";
|
||||||
@@ -10,7 +10,7 @@ class PageDescription extends HaMarkdown {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (!PAGES[this.page].description) {
|
if (!PAGES[this.page].description) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { dump } from "js-yaml";
|
import { dump } from "js-yaml";
|
||||||
import { html, css, LitElement, TemplateResult } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import "../../../../src/components/ha-card";
|
import "../../../../src/components/ha-card";
|
||||||
import "../../../../src/components/ha-yaml-editor";
|
import "../../../../src/components/ha-yaml-editor";
|
||||||
@@ -127,16 +127,16 @@ export class DemoAutomationDescribeAction extends LitElement {
|
|||||||
|
|
||||||
@state() _action = initialAction;
|
@state() _action = initialAction;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<ha-card header="Actions">
|
<ha-card header="Actions">
|
||||||
<div class="action">
|
<div class="action">
|
||||||
<span>
|
<span>
|
||||||
${this._action
|
${this._action
|
||||||
? describeAction(this.hass, this._action)
|
? describeAction(this.hass, [], this._action)
|
||||||
: "<invalid YAML>"}
|
: "<invalid YAML>"}
|
||||||
</span>
|
</span>
|
||||||
<ha-yaml-editor
|
<ha-yaml-editor
|
||||||
@@ -149,7 +149,7 @@ export class DemoAutomationDescribeAction extends LitElement {
|
|||||||
${ACTIONS.map(
|
${ACTIONS.map(
|
||||||
(conf) => html`
|
(conf) => html`
|
||||||
<div class="action">
|
<div class="action">
|
||||||
<span>${describeAction(this.hass, conf as any)}</span>
|
<span>${describeAction(this.hass, [], conf as any)}</span>
|
||||||
<pre>${dump(conf)}</pre>
|
<pre>${dump(conf)}</pre>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { dump } from "js-yaml";
|
import { dump } from "js-yaml";
|
||||||
import { css, html, LitElement, TemplateResult } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import "../../../../src/components/ha-card";
|
import "../../../../src/components/ha-card";
|
||||||
import "../../../../src/components/ha-yaml-editor";
|
import "../../../../src/components/ha-yaml-editor";
|
||||||
@@ -53,9 +53,9 @@ export class DemoAutomationDescribeCondition extends LitElement {
|
|||||||
|
|
||||||
@state() _condition = initialCondition;
|
@state() _condition = initialCondition;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { dump } from "js-yaml";
|
import { dump } from "js-yaml";
|
||||||
import { css, html, LitElement, TemplateResult } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import "../../../../src/components/ha-card";
|
import "../../../../src/components/ha-card";
|
||||||
import "../../../../src/components/ha-yaml-editor";
|
import "../../../../src/components/ha-yaml-editor";
|
||||||
@@ -64,9 +64,9 @@ export class DemoAutomationDescribeTrigger extends LitElement {
|
|||||||
|
|
||||||
@state() _trigger = initialTrigger;
|
@state() _trigger = initialTrigger;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
/* eslint-disable lit/no-template-arrow */
|
/* eslint-disable lit/no-template-arrow */
|
||||||
import { html, css, LitElement, TemplateResult } from "lit";
|
|
||||||
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import "../../../../src/components/ha-card";
|
import "../../../../src/components/ha-card";
|
||||||
import "../../../../src/components/trace/hat-script-graph";
|
import "../../../../src/components/trace/hat-script-graph";
|
||||||
@@ -29,9 +30,9 @@ const traces: DemoTrace[] = [
|
|||||||
export class DemoAutomationTraceTimeline extends LitElement {
|
export class DemoAutomationTraceTimeline extends LitElement {
|
||||||
@property({ attribute: false }) hass?: HomeAssistant;
|
@property({ attribute: false }) hass?: HomeAssistant;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
${traces.map(
|
${traces.map(
|
||||||
|
@@ -1,14 +1,15 @@
|
|||||||
/* eslint-disable lit/no-template-arrow */
|
/* eslint-disable lit/no-template-arrow */
|
||||||
import { html, css, LitElement, TemplateResult } from "lit";
|
|
||||||
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import "../../../../src/components/ha-card";
|
import "../../../../src/components/ha-card";
|
||||||
import "../../../../src/components/trace/hat-script-graph";
|
import "../../../../src/components/trace/hat-script-graph";
|
||||||
import "../../../../src/components/trace/hat-trace-timeline";
|
import "../../../../src/components/trace/hat-trace-timeline";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
|
||||||
import { provideHass } from "../../../../src/fake_data/provide_hass";
|
import { provideHass } from "../../../../src/fake_data/provide_hass";
|
||||||
import { HomeAssistant } from "../../../../src/types";
|
import { HomeAssistant } from "../../../../src/types";
|
||||||
import { DemoTrace } from "../../data/traces/types";
|
|
||||||
import { basicTrace } from "../../data/traces/basic_trace";
|
import { basicTrace } from "../../data/traces/basic_trace";
|
||||||
import { motionLightTrace } from "../../data/traces/motion-light-trace";
|
import { motionLightTrace } from "../../data/traces/motion-light-trace";
|
||||||
|
import { DemoTrace } from "../../data/traces/types";
|
||||||
|
|
||||||
const traces: DemoTrace[] = [basicTrace, motionLightTrace];
|
const traces: DemoTrace[] = [basicTrace, motionLightTrace];
|
||||||
|
|
||||||
@@ -18,9 +19,9 @@ export class DemoAutomationTrace extends LitElement {
|
|||||||
|
|
||||||
@state() private _selected = {};
|
@state() private _selected = {};
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
${traces.map(
|
${traces.map(
|
||||||
|
@@ -156,18 +156,6 @@ The `title ` option should not be used without a description.
|
|||||||
|
|
||||||
*Documentation coming soon*
|
*Documentation coming soon*
|
||||||
|
|
||||||
**Right to left**
|
|
||||||
|
|
||||||
<ha-alert alert-type="success" rtl>
|
|
||||||
This is an info alert — check it out!
|
|
||||||
</ha-alert>
|
|
||||||
|
|
||||||
```html
|
|
||||||
<ha-alert alert-type="success" rtl>
|
|
||||||
This is an info alert — check it out!
|
|
||||||
</ha-alert>
|
|
||||||
```
|
|
||||||
|
|
||||||
### API
|
### API
|
||||||
**Properties/Attributes**
|
**Properties/Attributes**
|
||||||
|
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
title: Bar Slider
|
|
||||||
---
|
|
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
title: Bar Switch
|
|
||||||
---
|
|
3
gallery/src/pages/components/ha-control-button.markdown
Normal file
3
gallery/src/pages/components/ha-control-button.markdown
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
title: Control Button
|
||||||
|
---
|
192
gallery/src/pages/components/ha-control-button.ts
Normal file
192
gallery/src/pages/components/ha-control-button.ts
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
import {
|
||||||
|
mdiFanSpeed1,
|
||||||
|
mdiFanSpeed2,
|
||||||
|
mdiFanSpeed3,
|
||||||
|
mdiLightbulb,
|
||||||
|
} from "@mdi/js";
|
||||||
|
import { css, html, LitElement, TemplateResult } from "lit";
|
||||||
|
import { customElement } from "lit/decorators";
|
||||||
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
|
import { repeat } from "lit/directives/repeat";
|
||||||
|
import "../../../../src/components/ha-control-button";
|
||||||
|
import "../../../../src/components/ha-card";
|
||||||
|
import "../../../../src/components/ha-svg-icon";
|
||||||
|
import "../../../../src/components/ha-control-button-group";
|
||||||
|
|
||||||
|
type Button = {
|
||||||
|
label: string;
|
||||||
|
icon?: string;
|
||||||
|
class?: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttons: Button[] = [
|
||||||
|
{
|
||||||
|
label: "Button",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Button and custom style",
|
||||||
|
class: "custom",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Disabled Button",
|
||||||
|
disabled: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
type ButtonGroup = {
|
||||||
|
vertical?: boolean;
|
||||||
|
class?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttonGroups: ButtonGroup[] = [
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
class: "custom-group",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
@customElement("demo-components-ha-control-button")
|
||||||
|
export class DemoHaBarButton extends LitElement {
|
||||||
|
protected render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<ha-card>
|
||||||
|
${repeat(
|
||||||
|
buttons,
|
||||||
|
(btn) => html`
|
||||||
|
<div class="card-content">
|
||||||
|
<pre>Config: ${JSON.stringify(btn)}</pre>
|
||||||
|
<ha-control-button
|
||||||
|
class=${ifDefined(btn.class)}
|
||||||
|
label=${ifDefined(btn.label)}
|
||||||
|
disabled=${ifDefined(btn.disabled)}
|
||||||
|
>
|
||||||
|
<ha-svg-icon .path=${btn.icon || mdiLightbulb}></ha-svg-icon>
|
||||||
|
</ha-control-button>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</ha-card>
|
||||||
|
|
||||||
|
<ha-card>
|
||||||
|
${repeat(
|
||||||
|
buttonGroups,
|
||||||
|
(group) => html`
|
||||||
|
<div class="card-content">
|
||||||
|
<pre>Config: ${JSON.stringify(group)}</pre>
|
||||||
|
<ha-control-button-group class=${ifDefined(group.class)}>
|
||||||
|
<ha-control-button>
|
||||||
|
<ha-svg-icon
|
||||||
|
.path=${mdiFanSpeed1}
|
||||||
|
label="Speed 1"
|
||||||
|
></ha-svg-icon>
|
||||||
|
</ha-control-button>
|
||||||
|
<ha-control-button>
|
||||||
|
<ha-svg-icon
|
||||||
|
.path=${mdiFanSpeed2}
|
||||||
|
label="Speed 2"
|
||||||
|
></ha-svg-icon>
|
||||||
|
</ha-control-button>
|
||||||
|
<ha-control-button>
|
||||||
|
<ha-svg-icon
|
||||||
|
.path=${mdiFanSpeed3}
|
||||||
|
label="Speed 3"
|
||||||
|
></ha-svg-icon>
|
||||||
|
</ha-control-button>
|
||||||
|
</ha-control-button-group>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</ha-card>
|
||||||
|
<ha-card>
|
||||||
|
<div class="card-content">
|
||||||
|
<p class="title"><b>Vertical</b></p>
|
||||||
|
<div class="vertical-buttons">
|
||||||
|
${repeat(
|
||||||
|
buttonGroups,
|
||||||
|
(group) => html`
|
||||||
|
<ha-control-button-group
|
||||||
|
vertical
|
||||||
|
class=${ifDefined(group.class)}
|
||||||
|
>
|
||||||
|
<ha-control-button>
|
||||||
|
<ha-svg-icon
|
||||||
|
.path=${mdiFanSpeed1}
|
||||||
|
label="Speed 1"
|
||||||
|
></ha-svg-icon>
|
||||||
|
</ha-control-button>
|
||||||
|
<ha-control-button>
|
||||||
|
<ha-svg-icon
|
||||||
|
.path=${mdiFanSpeed2}
|
||||||
|
label="Speed 2"
|
||||||
|
></ha-svg-icon>
|
||||||
|
</ha-control-button>
|
||||||
|
<ha-control-button>
|
||||||
|
<ha-svg-icon
|
||||||
|
.path=${mdiFanSpeed3}
|
||||||
|
label="Speed 3"
|
||||||
|
></ha-svg-icon>
|
||||||
|
</ha-control-button>
|
||||||
|
</ha-control-button-group>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ha-card>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get styles() {
|
||||||
|
return css`
|
||||||
|
ha-card {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 24px auto;
|
||||||
|
}
|
||||||
|
pre {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.custom {
|
||||||
|
--control-button-icon-color: var(--primary-color);
|
||||||
|
--control-button-background-color: var(--primary-color);
|
||||||
|
--control-button-background-opacity: 0.2;
|
||||||
|
--control-button-border-radius: 18px;
|
||||||
|
height: 100px;
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
.custom-group {
|
||||||
|
--control-button-group-thickness: 100px;
|
||||||
|
--control-button-group-border-radius: 18px;
|
||||||
|
--control-button-group-spacing: 20px;
|
||||||
|
}
|
||||||
|
.custom-group ha-control-button {
|
||||||
|
--control-button-border-radius: 18px;
|
||||||
|
--mdc-icon-size: 32px;
|
||||||
|
}
|
||||||
|
.vertical-buttons {
|
||||||
|
height: 300px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
p.title {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
.vertical-switches > *:not(:last-child) {
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"demo-components-ha-control-button": DemoHaBarButton;
|
||||||
|
}
|
||||||
|
}
|
3
gallery/src/pages/components/ha-control-slider.markdown
Normal file
3
gallery/src/pages/components/ha-control-slider.markdown
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
title: Control Slider
|
||||||
|
---
|
@@ -2,7 +2,7 @@ import { css, html, LitElement, TemplateResult } from "lit";
|
|||||||
import { customElement, state } from "lit/decorators";
|
import { customElement, state } from "lit/decorators";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import { repeat } from "lit/directives/repeat";
|
import { repeat } from "lit/directives/repeat";
|
||||||
import "../../../../src/components/ha-bar-slider";
|
import "../../../../src/components/ha-control-slider";
|
||||||
import "../../../../src/components/ha-card";
|
import "../../../../src/components/ha-card";
|
||||||
|
|
||||||
const sliders: {
|
const sliders: {
|
||||||
@@ -46,7 +46,7 @@ const sliders: {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@customElement("demo-components-ha-bar-slider")
|
@customElement("demo-components-ha-control-slider")
|
||||||
export class DemoHaBarSlider extends LitElement {
|
export class DemoHaBarSlider extends LitElement {
|
||||||
@state() private value = 50;
|
@state() private value = 50;
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ export class DemoHaBarSlider extends LitElement {
|
|||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<label id=${id}>${label}</label>
|
<label id=${id}>${label}</label>
|
||||||
<pre>Config: ${JSON.stringify(config)}</pre>
|
<pre>Config: ${JSON.stringify(config)}</pre>
|
||||||
<ha-bar-slider
|
<ha-control-slider
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
.mode=${config.mode}
|
.mode=${config.mode}
|
||||||
class=${ifDefined(config.class)}
|
class=${ifDefined(config.class)}
|
||||||
@@ -94,7 +94,7 @@ export class DemoHaBarSlider extends LitElement {
|
|||||||
@slider-moved=${this.handleSliderMoved}
|
@slider-moved=${this.handleSliderMoved}
|
||||||
aria-labelledby=${id}
|
aria-labelledby=${id}
|
||||||
>
|
>
|
||||||
</ha-bar-slider>
|
</ha-control-slider>
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
@@ -106,7 +106,7 @@ export class DemoHaBarSlider extends LitElement {
|
|||||||
${repeat(sliders, (slider) => {
|
${repeat(sliders, (slider) => {
|
||||||
const { id, label, ...config } = slider;
|
const { id, label, ...config } = slider;
|
||||||
return html`
|
return html`
|
||||||
<ha-bar-slider
|
<ha-control-slider
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
.mode=${config.mode}
|
.mode=${config.mode}
|
||||||
vertical
|
vertical
|
||||||
@@ -115,7 +115,7 @@ export class DemoHaBarSlider extends LitElement {
|
|||||||
@slider-moved=${this.handleSliderMoved}
|
@slider-moved=${this.handleSliderMoved}
|
||||||
aria-label=${label}
|
aria-label=${label}
|
||||||
>
|
>
|
||||||
</ha-bar-slider>
|
</ha-control-slider>
|
||||||
`;
|
`;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
@@ -141,11 +141,11 @@ export class DemoHaBarSlider extends LitElement {
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.custom {
|
.custom {
|
||||||
--slider-bar-color: #ffcf4c;
|
--control-slider-color: #ffcf4c;
|
||||||
--slider-bar-background: #ffcf4c;
|
--control-slider-background: #ffcf4c;
|
||||||
--slider-bar-background-opacity: 0.2;
|
--control-slider-background-opacity: 0.2;
|
||||||
--slider-bar-thickness: 100px;
|
--control-slider-thickness: 100px;
|
||||||
--slider-bar-border-radius: 24px;
|
--control-slider-border-radius: 24px;
|
||||||
}
|
}
|
||||||
.vertical-sliders {
|
.vertical-sliders {
|
||||||
height: 300px;
|
height: 300px;
|
||||||
@@ -165,6 +165,6 @@ export class DemoHaBarSlider extends LitElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"demo-components-ha-bar-slider": DemoHaBarSlider;
|
"demo-components-ha-control-slider": DemoHaBarSlider;
|
||||||
}
|
}
|
||||||
}
|
}
|
3
gallery/src/pages/components/ha-control-switch.markdown
Normal file
3
gallery/src/pages/components/ha-control-switch.markdown
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
title: Control Switch
|
||||||
|
---
|
@@ -8,7 +8,7 @@ import { css, html, LitElement, TemplateResult } from "lit";
|
|||||||
import { customElement, state } from "lit/decorators";
|
import { customElement, state } from "lit/decorators";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
import { repeat } from "lit/directives/repeat";
|
import { repeat } from "lit/directives/repeat";
|
||||||
import "../../../../src/components/ha-bar-switch";
|
import "../../../../src/components/ha-control-switch";
|
||||||
import "../../../../src/components/ha-card";
|
import "../../../../src/components/ha-card";
|
||||||
|
|
||||||
const switches: {
|
const switches: {
|
||||||
@@ -39,8 +39,8 @@ const switches: {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@customElement("demo-components-ha-bar-switch")
|
@customElement("demo-components-ha-control-switch")
|
||||||
export class DemoHaBarSwitch extends LitElement {
|
export class DemoHaControlSwitch extends LitElement {
|
||||||
@state() private checked = false;
|
@state() private checked = false;
|
||||||
|
|
||||||
handleValueChanged(e: any) {
|
handleValueChanged(e: any) {
|
||||||
@@ -56,7 +56,7 @@ export class DemoHaBarSwitch extends LitElement {
|
|||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<label id=${id}>${label}</label>
|
<label id=${id}>${label}</label>
|
||||||
<pre>Config: ${JSON.stringify(config)}</pre>
|
<pre>Config: ${JSON.stringify(config)}</pre>
|
||||||
<ha-bar-switch
|
<ha-control-switch
|
||||||
.checked=${this.checked}
|
.checked=${this.checked}
|
||||||
class=${ifDefined(config.class)}
|
class=${ifDefined(config.class)}
|
||||||
@change=${this.handleValueChanged}
|
@change=${this.handleValueChanged}
|
||||||
@@ -66,7 +66,7 @@ export class DemoHaBarSwitch extends LitElement {
|
|||||||
disabled=${ifDefined(config.disabled)}
|
disabled=${ifDefined(config.disabled)}
|
||||||
reversed=${ifDefined(config.reversed)}
|
reversed=${ifDefined(config.reversed)}
|
||||||
>
|
>
|
||||||
</ha-bar-switch>
|
</ha-control-switch>
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
@@ -78,7 +78,7 @@ export class DemoHaBarSwitch extends LitElement {
|
|||||||
${repeat(switches, (sw) => {
|
${repeat(switches, (sw) => {
|
||||||
const { id, label, ...config } = sw;
|
const { id, label, ...config } = sw;
|
||||||
return html`
|
return html`
|
||||||
<ha-bar-switch
|
<ha-control-switch
|
||||||
.checked=${this.checked}
|
.checked=${this.checked}
|
||||||
vertical
|
vertical
|
||||||
class=${ifDefined(config.class)}
|
class=${ifDefined(config.class)}
|
||||||
@@ -89,7 +89,7 @@ export class DemoHaBarSwitch extends LitElement {
|
|||||||
disabled=${ifDefined(config.disabled)}
|
disabled=${ifDefined(config.disabled)}
|
||||||
reversed=${ifDefined(config.reversed)}
|
reversed=${ifDefined(config.reversed)}
|
||||||
>
|
>
|
||||||
</ha-bar-switch>
|
</ha-control-switch>
|
||||||
`;
|
`;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
@@ -115,11 +115,11 @@ export class DemoHaBarSwitch extends LitElement {
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.custom {
|
.custom {
|
||||||
--switch-bar-on-color: var(--green-color);
|
--control-switch-on-color: var(--green-color);
|
||||||
--switch-bar-off-color: var(--red-color);
|
--control-switch-off-color: var(--red-color);
|
||||||
--switch-bar-thickness: 100px;
|
--control-switch-thickness: 100px;
|
||||||
--switch-bar-border-radius: 24px;
|
--control-switch-border-radius: 24px;
|
||||||
--switch-bar-padding: 6px;
|
--control-switch-padding: 6px;
|
||||||
--mdc-icon-size: 24px;
|
--mdc-icon-size: 24px;
|
||||||
}
|
}
|
||||||
.vertical-switches {
|
.vertical-switches {
|
||||||
@@ -140,6 +140,6 @@ export class DemoHaBarSwitch extends LitElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"demo-components-ha-bar-switch": DemoHaBarSwitch;
|
"demo-components-ha-control-switch": DemoHaControlSwitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,6 +3,7 @@ import { customElement } from "lit/decorators";
|
|||||||
import "../../../../src/components/ha-tip";
|
import "../../../../src/components/ha-tip";
|
||||||
import "../../../../src/components/ha-card";
|
import "../../../../src/components/ha-card";
|
||||||
import { applyThemesOnElement } from "../../../../src/common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../../../../src/common/dom/apply_themes_on_element";
|
||||||
|
import { provideHass } from "../../../../src/fake_data/provide_hass";
|
||||||
|
|
||||||
const tips: (string | TemplateResult)[] = [
|
const tips: (string | TemplateResult)[] = [
|
||||||
"Test tip",
|
"Test tip",
|
||||||
@@ -18,7 +19,11 @@ export class DemoHaTip extends LitElement {
|
|||||||
<div class=${mode}>
|
<div class=${mode}>
|
||||||
<ha-card header="ha-tip ${mode} demo">
|
<ha-card header="ha-tip ${mode} demo">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${tips.map((tip) => html`<ha-tip>${tip}</ha-tip>`)}
|
${tips.map(
|
||||||
|
(tip) => html`<ha-tip .hass=${provideHass(this)}
|
||||||
|
>${tip}</ha-tip
|
||||||
|
>`
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
</div>
|
</div>
|
||||||
|
3
gallery/src/pages/lovelace/tile-card.markdown
Normal file
3
gallery/src/pages/lovelace/tile-card.markdown
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
title: Tile Card
|
||||||
|
---
|
173
gallery/src/pages/lovelace/tile-card.ts
Normal file
173
gallery/src/pages/lovelace/tile-card.ts
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||||
|
import { customElement, query } from "lit/decorators";
|
||||||
|
import { CoverEntityFeature } from "../../../../src/data/cover";
|
||||||
|
import { LightColorMode } from "../../../../src/data/light";
|
||||||
|
import { VacuumEntityFeature } from "../../../../src/data/vacuum";
|
||||||
|
import { getEntity } from "../../../../src/fake_data/entity";
|
||||||
|
import { provideHass } from "../../../../src/fake_data/provide_hass";
|
||||||
|
import "../../components/demo-cards";
|
||||||
|
|
||||||
|
const ENTITIES = [
|
||||||
|
getEntity("switch", "tv_outlet", "on", {
|
||||||
|
friendly_name: "TV outlet",
|
||||||
|
device_class: "outlet",
|
||||||
|
}),
|
||||||
|
getEntity("light", "bed_light", "on", {
|
||||||
|
friendly_name: "Bed Light",
|
||||||
|
supported_color_modes: [LightColorMode.HS],
|
||||||
|
}),
|
||||||
|
getEntity("light", "unavailable", "unavailable", {
|
||||||
|
friendly_name: "Unavailable entity",
|
||||||
|
}),
|
||||||
|
getEntity("climate", "thermostat", "heat", {
|
||||||
|
current_temperature: 73,
|
||||||
|
min_temp: 45,
|
||||||
|
max_temp: 95,
|
||||||
|
temperature: 80,
|
||||||
|
hvac_modes: ["heat", "cool", "auto", "off"],
|
||||||
|
friendly_name: "Thermostat",
|
||||||
|
hvac_action: "heating",
|
||||||
|
}),
|
||||||
|
getEntity("person", "paulus", "home", {
|
||||||
|
friendly_name: "Paulus",
|
||||||
|
}),
|
||||||
|
getEntity("vacuum", "first_floor_vacuum", "docked", {
|
||||||
|
friendly_name: "First floor vacuum",
|
||||||
|
supported_features:
|
||||||
|
VacuumEntityFeature.START +
|
||||||
|
VacuumEntityFeature.STOP +
|
||||||
|
VacuumEntityFeature.RETURN_HOME,
|
||||||
|
}),
|
||||||
|
getEntity("cover", "kitchen_shutter", "open", {
|
||||||
|
friendly_name: "Kitchen shutter",
|
||||||
|
device_class: "shutter",
|
||||||
|
supported_features:
|
||||||
|
CoverEntityFeature.CLOSE +
|
||||||
|
CoverEntityFeature.OPEN +
|
||||||
|
CoverEntityFeature.STOP,
|
||||||
|
}),
|
||||||
|
getEntity("cover", "pergola_roof", "open", {
|
||||||
|
friendly_name: "Pergola Roof",
|
||||||
|
supported_features:
|
||||||
|
CoverEntityFeature.CLOSE_TILT +
|
||||||
|
CoverEntityFeature.OPEN_TILT +
|
||||||
|
CoverEntityFeature.STOP_TILT,
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
|
||||||
|
const CONFIGS = [
|
||||||
|
{
|
||||||
|
heading: "Basic example",
|
||||||
|
config: `
|
||||||
|
- type: tile
|
||||||
|
entity: switch.tv_outlet
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
heading: "Vertical example",
|
||||||
|
config: `
|
||||||
|
- type: tile
|
||||||
|
entity: switch.tv_outlet
|
||||||
|
vertical: true
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
heading: "Custom color",
|
||||||
|
config: `
|
||||||
|
- type: tile
|
||||||
|
entity: switch.tv_outlet
|
||||||
|
color: pink
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
heading: "Unknown entity",
|
||||||
|
config: `
|
||||||
|
- type: tile
|
||||||
|
entity: light.unknown
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
heading: "Unavailable entity",
|
||||||
|
config: `
|
||||||
|
- type: tile
|
||||||
|
entity: light.unavailable
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
heading: "Climate",
|
||||||
|
config: `
|
||||||
|
- type: tile
|
||||||
|
entity: climate.thermostat
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
heading: "Person",
|
||||||
|
config: `
|
||||||
|
- type: tile
|
||||||
|
entity: person.paulus
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
heading: "Light brightness feature",
|
||||||
|
config: `
|
||||||
|
- type: tile
|
||||||
|
entity: light.bed_light
|
||||||
|
features:
|
||||||
|
- type: "light-brightness"
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
heading: "Vacuum commands feature",
|
||||||
|
config: `
|
||||||
|
- type: tile
|
||||||
|
entity: vacuum.first_floor_vacuum
|
||||||
|
features:
|
||||||
|
- type: "vacuum-commands"
|
||||||
|
commands:
|
||||||
|
- start_pause
|
||||||
|
- stop
|
||||||
|
- return_home
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
heading: "Cover open close feature",
|
||||||
|
config: `
|
||||||
|
- type: tile
|
||||||
|
entity: cover.kitchen_shutter
|
||||||
|
features:
|
||||||
|
- type: "cover-open-close"
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
heading: "Cover tilt feature",
|
||||||
|
config: `
|
||||||
|
- type: tile
|
||||||
|
entity: cover.pergola_roof
|
||||||
|
features:
|
||||||
|
- type: "cover-tilt"
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
@customElement("demo-lovelace-tile-card")
|
||||||
|
class DemoTile extends LitElement {
|
||||||
|
@query("#demos") private _demoRoot!: HTMLElement;
|
||||||
|
|
||||||
|
protected render(): TemplateResult {
|
||||||
|
return html`<demo-cards id="demos" .configs=${CONFIGS}></demo-cards>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected firstUpdated(changedProperties: PropertyValues) {
|
||||||
|
super.firstUpdated(changedProperties);
|
||||||
|
const hass = provideHass(this._demoRoot);
|
||||||
|
hass.updateTranslations(null, "en");
|
||||||
|
hass.updateTranslations("lovelace", "en");
|
||||||
|
hass.addEntities(ENTITIES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"demo-lovelace-tile-card": DemoTile;
|
||||||
|
}
|
||||||
|
}
|
@@ -2,7 +2,7 @@ import {
|
|||||||
HassEntity,
|
HassEntity,
|
||||||
HassEntityAttributeBase,
|
HassEntityAttributeBase,
|
||||||
} from "home-assistant-js-websocket";
|
} from "home-assistant-js-websocket";
|
||||||
import { css, html, LitElement, TemplateResult } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { computeDomain } from "../../../../src/common/entity/compute_domain";
|
import { computeDomain } from "../../../../src/common/entity/compute_domain";
|
||||||
@@ -387,9 +387,9 @@ export class DemoEntityState extends LitElement {
|
|||||||
hass.updateTranslations("config", "en");
|
hass.updateTranslations("config", "en");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
import { html, css, LitElement, TemplateResult } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import "../../../../src/components/ha-formfield";
|
import "../../../../src/components/ha-formfield";
|
||||||
import "../../../../src/components/ha-switch";
|
import "../../../../src/components/ha-switch";
|
||||||
|
|
||||||
import { classMap } from "lit/directives/class-map";
|
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { IntegrationManifest } from "../../../../src/data/integration";
|
import { IntegrationManifest } from "../../../../src/data/integration";
|
||||||
|
|
||||||
|
import { DeviceRegistryEntry } from "../../../../src/data/device_registry";
|
||||||
|
import { EntityRegistryEntry } from "../../../../src/data/entity_registry";
|
||||||
import { provideHass } from "../../../../src/fake_data/provide_hass";
|
import { provideHass } from "../../../../src/fake_data/provide_hass";
|
||||||
import { HomeAssistant } from "../../../../src/types";
|
|
||||||
import "../../../../src/panels/config/integrations/ha-integration-card";
|
|
||||||
import "../../../../src/panels/config/integrations/ha-ignored-config-entry-card";
|
|
||||||
import "../../../../src/panels/config/integrations/ha-config-flow-card";
|
import "../../../../src/panels/config/integrations/ha-config-flow-card";
|
||||||
import type {
|
import type {
|
||||||
ConfigEntryExtended,
|
ConfigEntryExtended,
|
||||||
DataEntryFlowProgressExtended,
|
DataEntryFlowProgressExtended,
|
||||||
} from "../../../../src/panels/config/integrations/ha-config-integrations";
|
} from "../../../../src/panels/config/integrations/ha-config-integrations";
|
||||||
import { DeviceRegistryEntry } from "../../../../src/data/device_registry";
|
import "../../../../src/panels/config/integrations/ha-ignored-config-entry-card";
|
||||||
import { EntityRegistryEntry } from "../../../../src/data/entity_registry";
|
import "../../../../src/panels/config/integrations/ha-integration-card";
|
||||||
|
import { HomeAssistant } from "../../../../src/types";
|
||||||
|
|
||||||
const createConfigEntry = (
|
const createConfigEntry = (
|
||||||
title: string,
|
title: string,
|
||||||
@@ -197,6 +197,7 @@ const createEntityRegistryEntries = (
|
|||||||
platform: "updater",
|
platform: "updater",
|
||||||
has_entity_name: false,
|
has_entity_name: false,
|
||||||
unique_id: "updater",
|
unique_id: "updater",
|
||||||
|
options: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -230,9 +231,9 @@ export class DemoIntegrationCard extends LitElement {
|
|||||||
|
|
||||||
@state() isCloud = false;
|
@state() isCloud = false;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { mdiArrowUpBoldCircle, mdiPuzzle } from "@mdi/js";
|
import { mdiArrowUpBoldCircle, mdiPuzzle } from "@mdi/js";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
import { property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { atLeastVersion } from "../../../src/common/config/version";
|
import { atLeastVersion } from "../../../src/common/config/version";
|
||||||
import { navigate } from "../../../src/common/navigate";
|
import { navigate } from "../../../src/common/navigate";
|
||||||
@@ -14,7 +14,8 @@ import "../components/hassio-card-content";
|
|||||||
import { filterAndSort } from "../components/hassio-filter-addons";
|
import { filterAndSort } from "../components/hassio-filter-addons";
|
||||||
import { hassioStyle } from "../resources/hassio-style";
|
import { hassioStyle } from "../resources/hassio-style";
|
||||||
|
|
||||||
class HassioAddonRepositoryEl extends LitElement {
|
@customElement("hassio-addon-repository")
|
||||||
|
export class HassioAddonRepositoryEl extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property({ attribute: false }) public supervisor!: Supervisor;
|
@property({ attribute: false }) public supervisor!: Supervisor;
|
||||||
@@ -140,5 +141,3 @@ class HassioAddonRepositoryEl extends LitElement {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define("hassio-addon-repository", HassioAddonRepositoryEl);
|
|
||||||
|
@@ -6,10 +6,11 @@ import {
|
|||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
|
nothing,
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { atLeastVersion } from "../../../src/common/config/version";
|
import { atLeastVersion } from "../../../src/common/config/version";
|
||||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||||
@@ -49,7 +50,8 @@ const sortRepos = (a: HassioAddonRepository, b: HassioAddonRepository) => {
|
|||||||
return a.name.toUpperCase() < b.name.toUpperCase() ? -1 : 1;
|
return a.name.toUpperCase() < b.name.toUpperCase() ? -1 : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HassioAddonStore extends LitElement {
|
@customElement("hassio-addon-store")
|
||||||
|
export class HassioAddonStore extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property({ attribute: false }) public supervisor!: Supervisor;
|
@property({ attribute: false }) public supervisor!: Supervisor;
|
||||||
@@ -72,8 +74,8 @@ class HassioAddonStore extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
let repos: TemplateResult[] = [];
|
let repos: (TemplateResult | typeof nothing)[] = [];
|
||||||
|
|
||||||
if (this.supervisor.store.repositories) {
|
if (this.supervisor.store.repositories) {
|
||||||
repos = this.addonRepositories(
|
repos = this.addonRepositories(
|
||||||
@@ -172,7 +174,7 @@ class HassioAddonStore extends LitElement {
|
|||||||
.supervisor=${this.supervisor}
|
.supervisor=${this.supervisor}
|
||||||
></hassio-addon-repository>
|
></hassio-addon-repository>
|
||||||
`
|
`
|
||||||
: html``;
|
: nothing;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -250,5 +252,3 @@ class HassioAddonStore extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define("hassio-addon-store", HassioAddonStore);
|
|
||||||
|
@@ -4,7 +4,7 @@ import {
|
|||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
TemplateResult,
|
nothing,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
@@ -47,9 +47,9 @@ class HassioAddonNetwork extends LitElement {
|
|||||||
this._setNetworkConfig();
|
this._setNetworkConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this._config) {
|
if (!this._config) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasHiddenOptions = Object.keys(this._config).find(
|
const hasHiddenOptions = Object.keys(this._config).find(
|
||||||
|
@@ -8,7 +8,7 @@ import {
|
|||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
TemplateResult,
|
nothing,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
@@ -160,9 +160,9 @@ export class HassioBackups extends LitElement {
|
|||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.supervisor) {
|
if (!this.supervisor) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<hass-tabs-subpage-data-table
|
<hass-tabs-subpage-data-table
|
||||||
|
@@ -1,6 +1,13 @@
|
|||||||
import { mdiFolder, mdiHomeAssistant, mdiPuzzle } from "@mdi/js";
|
import { mdiFolder, mdiHomeAssistant, mdiPuzzle } from "@mdi/js";
|
||||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import {
|
||||||
|
css,
|
||||||
|
CSSResultGroup,
|
||||||
|
html,
|
||||||
|
LitElement,
|
||||||
|
TemplateResult,
|
||||||
|
nothing,
|
||||||
|
} from "lit";
|
||||||
import { customElement, property, query } from "lit/decorators";
|
import { customElement, property, query } from "lit/decorators";
|
||||||
import { atLeastVersion } from "../../../src/common/config/version";
|
import { atLeastVersion } from "../../../src/common/config/version";
|
||||||
import { formatDate } from "../../../src/common/datetime/format_date";
|
import { formatDate } from "../../../src/common/datetime/format_date";
|
||||||
@@ -11,9 +18,9 @@ import "../../../src/components/ha-formfield";
|
|||||||
import "../../../src/components/ha-radio";
|
import "../../../src/components/ha-radio";
|
||||||
import type { HaRadio } from "../../../src/components/ha-radio";
|
import type { HaRadio } from "../../../src/components/ha-radio";
|
||||||
import {
|
import {
|
||||||
|
HassioBackupDetail,
|
||||||
HassioFullBackupCreateParams,
|
HassioFullBackupCreateParams,
|
||||||
HassioPartialBackupCreateParams,
|
HassioPartialBackupCreateParams,
|
||||||
HassioBackupDetail,
|
|
||||||
} from "../../../src/data/hassio/backup";
|
} from "../../../src/data/hassio/backup";
|
||||||
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
||||||
import { PolymerChangedEvent } from "../../../src/polymer-types";
|
import { PolymerChangedEvent } from "../../../src/polymer-types";
|
||||||
@@ -115,9 +122,9 @@ export class SupervisorBackupContent extends LitElement {
|
|||||||
this.supervisor?.localize(`backup.${key}`) ||
|
this.supervisor?.localize(`backup.${key}`) ||
|
||||||
this.localize!(`ui.panel.page-onboarding.restore.${key}`);
|
this.localize!(`ui.panel.page-onboarding.restore.${key}`);
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.onboarding && !this.supervisor) {
|
if (!this.onboarding && !this.supervisor) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
const foldersSection =
|
const foldersSection =
|
||||||
this.backupType === "partial" ? this._getSection("folders") : undefined;
|
this.backupType === "partial" ? this._getSection("folders") : undefined;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import { mdiHomeAssistant } from "@mdi/js";
|
import { mdiHomeAssistant } from "@mdi/js";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import "../../../src/components/buttons/ha-progress-button";
|
import "../../../src/components/buttons/ha-progress-button";
|
||||||
@@ -33,14 +33,14 @@ export class HassioUpdate extends LitElement {
|
|||||||
).length
|
).length
|
||||||
);
|
);
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.supervisor) {
|
if (!this.supervisor) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatesAvailable = this._pendingUpdates(this.supervisor);
|
const updatesAvailable = this._pendingUpdates(this.supervisor);
|
||||||
if (!updatesAvailable) {
|
if (!updatesAvailable) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
@@ -80,9 +80,9 @@ export class HassioUpdate extends LitElement {
|
|||||||
name: string,
|
name: string,
|
||||||
key: string,
|
key: string,
|
||||||
object: HassioHomeAssistantInfo | HassioSupervisorInfo | HassioHassOSInfo
|
object: HassioHomeAssistantInfo | HassioSupervisorInfo | HassioHassOSInfo
|
||||||
): TemplateResult {
|
) {
|
||||||
if (!object.update_available) {
|
if (!object.update_available) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<ha-card outlined>
|
<ha-card outlined>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { mdiClose } from "@mdi/js";
|
import { mdiClose } from "@mdi/js";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
import "../../../../src/components/ha-header-bar";
|
import "../../../../src/components/ha-header-bar";
|
||||||
@@ -36,9 +36,9 @@ export class DialogHassioBackupUpload
|
|||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this._dialogParams) {
|
if (!this._dialogParams) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
import { ActionDetail } from "@material/mwc-list";
|
import { ActionDetail } from "@material/mwc-list";
|
||||||
import "@material/mwc-list/mwc-list-item";
|
import "@material/mwc-list/mwc-list-item";
|
||||||
import { mdiClose, mdiDotsVertical } from "@mdi/js";
|
import { mdiClose, mdiDotsVertical } from "@mdi/js";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
|
import { atLeastVersion } from "../../../../src/common/config/version";
|
||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
|
import { stopPropagation } from "../../../../src/common/dom/stop_propagation";
|
||||||
import { slugify } from "../../../../src/common/string/slugify";
|
import { slugify } from "../../../../src/common/string/slugify";
|
||||||
import "../../../../src/components/buttons/ha-progress-button";
|
import "../../../../src/components/buttons/ha-progress-button";
|
||||||
import "../../../../src/components/ha-alert";
|
import "../../../../src/components/ha-alert";
|
||||||
@@ -11,11 +13,11 @@ import "../../../../src/components/ha-button-menu";
|
|||||||
import "../../../../src/components/ha-header-bar";
|
import "../../../../src/components/ha-header-bar";
|
||||||
import "../../../../src/components/ha-icon-button";
|
import "../../../../src/components/ha-icon-button";
|
||||||
import { getSignedPath } from "../../../../src/data/auth";
|
import { getSignedPath } from "../../../../src/data/auth";
|
||||||
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
|
||||||
import {
|
import {
|
||||||
fetchHassioBackupInfo,
|
fetchHassioBackupInfo,
|
||||||
HassioBackupDetail,
|
HassioBackupDetail,
|
||||||
} from "../../../../src/data/hassio/backup";
|
} from "../../../../src/data/hassio/backup";
|
||||||
|
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
||||||
import {
|
import {
|
||||||
showAlertDialog,
|
showAlertDialog,
|
||||||
showConfirmationDialog,
|
showConfirmationDialog,
|
||||||
@@ -27,8 +29,6 @@ import { fileDownload } from "../../../../src/util/file_download";
|
|||||||
import "../../components/supervisor-backup-content";
|
import "../../components/supervisor-backup-content";
|
||||||
import type { SupervisorBackupContent } from "../../components/supervisor-backup-content";
|
import type { SupervisorBackupContent } from "../../components/supervisor-backup-content";
|
||||||
import { HassioBackupDialogParams } from "./show-dialog-hassio-backup";
|
import { HassioBackupDialogParams } from "./show-dialog-hassio-backup";
|
||||||
import { atLeastVersion } from "../../../../src/common/config/version";
|
|
||||||
import { stopPropagation } from "../../../../src/common/dom/stop_propagation";
|
|
||||||
|
|
||||||
@customElement("dialog-hassio-backup")
|
@customElement("dialog-hassio-backup")
|
||||||
class HassioBackupDialog
|
class HassioBackupDialog
|
||||||
@@ -62,9 +62,9 @@ class HassioBackupDialog
|
|||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this._dialogParams || !this._backup) {
|
if (!this._dialogParams || !this._backup) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<ha-dialog
|
<ha-dialog
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
import "../../../../src/components/ha-alert";
|
|
||||||
import "../../../../src/components/buttons/ha-progress-button";
|
import "../../../../src/components/buttons/ha-progress-button";
|
||||||
|
import "../../../../src/components/ha-alert";
|
||||||
import { createCloseHeading } from "../../../../src/components/ha-dialog";
|
import { createCloseHeading } from "../../../../src/components/ha-dialog";
|
||||||
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
|
||||||
import {
|
import {
|
||||||
createHassioFullBackup,
|
createHassioFullBackup,
|
||||||
createHassioPartialBackup,
|
createHassioPartialBackup,
|
||||||
} from "../../../../src/data/hassio/backup";
|
} from "../../../../src/data/hassio/backup";
|
||||||
|
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
||||||
import { showAlertDialog } from "../../../../src/dialogs/generic/show-dialog-box";
|
import { showAlertDialog } from "../../../../src/dialogs/generic/show-dialog-box";
|
||||||
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
||||||
import { HomeAssistant } from "../../../../src/types";
|
import { HomeAssistant } from "../../../../src/types";
|
||||||
@@ -42,9 +42,9 @@ class HassioCreateBackupDialog extends LitElement {
|
|||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this._dialogParams) {
|
if (!this._dialogParams) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<ha-dialog
|
<ha-dialog
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import "@material/mwc-list/mwc-list-item";
|
import "@material/mwc-list/mwc-list-item";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
@@ -55,9 +55,9 @@ class HassioDatadiskDialog extends LitElement {
|
|||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.dialogParams) {
|
if (!this.dialogParams) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<ha-dialog
|
<ha-dialog
|
||||||
|
8
hassio/src/dialogs/hardware/dialog-hassio-hardware.ts
Executable file → Normal file
8
hassio/src/dialogs/hardware/dialog-hassio-hardware.ts
Executable file → Normal file
@@ -1,13 +1,13 @@
|
|||||||
import { mdiClose } from "@mdi/js";
|
import { mdiClose } from "@mdi/js";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
import "../../../../src/components/search-input";
|
|
||||||
import { stringCompare } from "../../../../src/common/string/compare";
|
import { stringCompare } from "../../../../src/common/string/compare";
|
||||||
import "../../../../src/components/ha-dialog";
|
import "../../../../src/components/ha-dialog";
|
||||||
import "../../../../src/components/ha-expansion-panel";
|
import "../../../../src/components/ha-expansion-panel";
|
||||||
import "../../../../src/components/ha-icon-button";
|
import "../../../../src/components/ha-icon-button";
|
||||||
|
import "../../../../src/components/search-input";
|
||||||
import { HassioHardwareInfo } from "../../../../src/data/hassio/hardware";
|
import { HassioHardwareInfo } from "../../../../src/data/hassio/hardware";
|
||||||
import { dump } from "../../../../src/resources/js-yaml-dump";
|
import { dump } from "../../../../src/resources/js-yaml-dump";
|
||||||
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
||||||
@@ -53,9 +53,9 @@ class HassioHardwareDialog extends LitElement {
|
|||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this._dialogParams) {
|
if (!this._dialogParams) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const devices = _filterDevices(
|
const devices = _filterDevices(
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { createCloseHeading } from "../../../../src/components/ha-dialog";
|
import { createCloseHeading } from "../../../../src/components/ha-dialog";
|
||||||
import "../../../../src/components/ha-markdown";
|
import "../../../../src/components/ha-markdown";
|
||||||
@@ -27,9 +27,9 @@ class HassioMarkdownDialog extends LitElement {
|
|||||||
this._opened = false;
|
this._opened = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this._opened) {
|
if (!this._opened) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<ha-dialog
|
<ha-dialog
|
||||||
|
@@ -5,7 +5,7 @@ import "@material/mwc-tab";
|
|||||||
import "@material/mwc-tab-bar";
|
import "@material/mwc-tab-bar";
|
||||||
import { mdiClose } from "@mdi/js";
|
import { mdiClose } from "@mdi/js";
|
||||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { cache } from "lit/directives/cache";
|
import { cache } from "lit/directives/cache";
|
||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
@@ -17,7 +17,6 @@ import "../../../../src/components/ha-formfield";
|
|||||||
import "../../../../src/components/ha-header-bar";
|
import "../../../../src/components/ha-header-bar";
|
||||||
import "../../../../src/components/ha-icon-button";
|
import "../../../../src/components/ha-icon-button";
|
||||||
import "../../../../src/components/ha-radio";
|
import "../../../../src/components/ha-radio";
|
||||||
import "../../../../src/components/ha-related-items";
|
|
||||||
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
||||||
import {
|
import {
|
||||||
AccessPoints,
|
AccessPoints,
|
||||||
@@ -84,9 +83,9 @@ export class DialogHassioNetwork
|
|||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this._params || !this._interface) {
|
if (!this._params || !this._interface) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
@@ -138,7 +137,10 @@ export class DialogHassioNetwork
|
|||||||
)}
|
)}
|
||||||
${this._interface?.type === "wireless"
|
${this._interface?.type === "wireless"
|
||||||
? html`
|
? html`
|
||||||
<ha-expansion-panel header="Wi-Fi" outlined>
|
<ha-expansion-panel
|
||||||
|
.header=${this.supervisor.localize("dialog.network.wifi")}
|
||||||
|
outlined
|
||||||
|
>
|
||||||
${this._interface?.wifi?.ssid
|
${this._interface?.wifi?.ssid
|
||||||
? html`<p>
|
? html`<p>
|
||||||
${this.supervisor.localize(
|
${this.supervisor.localize(
|
||||||
@@ -177,7 +179,11 @@ export class DialogHassioNetwork
|
|||||||
>
|
>
|
||||||
<span>${ap.ssid}</span>
|
<span>${ap.ssid}</span>
|
||||||
<span slot="secondary">
|
<span slot="secondary">
|
||||||
${ap.mac} - Strength: ${ap.signal}
|
${ap.mac} -
|
||||||
|
${this.supervisor.localize(
|
||||||
|
"dialog.network.signal_strength"
|
||||||
|
)}:
|
||||||
|
${ap.signal}
|
||||||
</span>
|
</span>
|
||||||
</mwc-list-item>
|
</mwc-list-item>
|
||||||
`
|
`
|
||||||
@@ -241,7 +247,9 @@ export class DialogHassioNetwork
|
|||||||
class="flex-auto"
|
class="flex-auto"
|
||||||
type="password"
|
type="password"
|
||||||
id="psk"
|
id="psk"
|
||||||
label="Password"
|
.label=${this.supervisor.localize(
|
||||||
|
"dialog.network.wifi_password"
|
||||||
|
)}
|
||||||
version="wifi"
|
version="wifi"
|
||||||
@value-changed=${this
|
@value-changed=${this
|
||||||
._handleInputValueChangedWifi}
|
._handleInputValueChangedWifi}
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import "@polymer/paper-tooltip/paper-tooltip";
|
|
||||||
import "@material/mwc-button/mwc-button";
|
import "@material/mwc-button/mwc-button";
|
||||||
import { mdiDelete, mdiDeleteOff } from "@mdi/js";
|
import { mdiDelete, mdiDeleteOff } from "@mdi/js";
|
||||||
import "@polymer/paper-input/paper-input";
|
import "@polymer/paper-input/paper-input";
|
||||||
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||||
import "@polymer/paper-item/paper-item";
|
import "@polymer/paper-item/paper-item";
|
||||||
import "@polymer/paper-item/paper-item-body";
|
import "@polymer/paper-item/paper-item-body";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import "@polymer/paper-tooltip/paper-tooltip";
|
||||||
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
@@ -19,14 +19,14 @@ import {
|
|||||||
HassioAddonRepository,
|
HassioAddonRepository,
|
||||||
} from "../../../../src/data/hassio/addon";
|
} from "../../../../src/data/hassio/addon";
|
||||||
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
||||||
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
|
||||||
import type { HomeAssistant } from "../../../../src/types";
|
|
||||||
import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
|
|
||||||
import {
|
import {
|
||||||
addStoreRepository,
|
addStoreRepository,
|
||||||
fetchStoreRepositories,
|
fetchStoreRepositories,
|
||||||
removeStoreRepository,
|
removeStoreRepository,
|
||||||
} from "../../../../src/data/supervisor/store";
|
} from "../../../../src/data/supervisor/store";
|
||||||
|
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
||||||
|
import type { HomeAssistant } from "../../../../src/types";
|
||||||
|
import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
|
||||||
|
|
||||||
@customElement("dialog-hassio-repositories")
|
@customElement("dialog-hassio-repositories")
|
||||||
class HassioRepositoriesDialog extends LitElement {
|
class HassioRepositoriesDialog extends LitElement {
|
||||||
@@ -82,9 +82,9 @@ class HassioRepositoriesDialog extends LitElement {
|
|||||||
.map((repo) => repo.slug)
|
.map((repo) => repo.slug)
|
||||||
);
|
);
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this._dialogParams?.supervisor || this._repositories === undefined) {
|
if (!this._dialogParams?.supervisor || this._repositories === undefined) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
const repositories = this._filteredRepositories(this._repositories);
|
const repositories = this._filteredRepositories(this._repositories);
|
||||||
const usedRepositories = this._filteredUsedRepositories(
|
const usedRepositories = this._filteredUsedRepositories(
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { sanitizeUrl } from "@braintree/sanitize-url";
|
import { sanitizeUrl } from "@braintree/sanitize-url";
|
||||||
import { html, LitElement, TemplateResult } from "lit";
|
import { html, LitElement, TemplateResult, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { navigate } from "../../src/common/navigate";
|
import { navigate } from "../../src/common/navigate";
|
||||||
import {
|
import {
|
||||||
@@ -101,13 +101,13 @@ class HassioMyRedirect extends LitElement {
|
|||||||
navigate(url, { replace: true });
|
navigate(url, { replace: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (this._error) {
|
if (this._error) {
|
||||||
return html`<hass-error-screen
|
return html`<hass-error-screen
|
||||||
.error=${this._error}
|
.error=${this._error}
|
||||||
></hass-error-screen>`;
|
></hass-error-screen>`;
|
||||||
}
|
}
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _createRedirectUrl(redirect: Redirect): string {
|
private _createRedirectUrl(redirect: Redirect): string {
|
||||||
|
@@ -5,7 +5,7 @@ import {
|
|||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
TemplateResult,
|
nothing,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
@@ -116,12 +116,12 @@ class UpdateAvailableCard extends LitElement {
|
|||||||
storeAddons.find((addon) => addon.slug === slug)
|
storeAddons.find((addon) => addon.slug === slug)
|
||||||
);
|
);
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (
|
if (
|
||||||
!this._updateType ||
|
!this._updateType ||
|
||||||
(this._updateType === "addon" && !this._addonInfo)
|
(this._updateType === "addon" && !this._addonInfo)
|
||||||
) {
|
) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const changelog = changelogUrl(this._updateType, this._version_latest);
|
const changelog = changelogUrl(this._updateType, this._version_latest);
|
||||||
|
@@ -5,5 +5,5 @@ module.exports = {
|
|||||||
'printf "%s\n" "Translation files should not be added or modified here. Instead, make the necessary modifications in src/translations/en.json. Other languages are managed externally. Please see https://developers.home-assistant.io/docs/translations/ for details." ' +
|
'printf "%s\n" "Translation files should not be added or modified here. Instead, make the necessary modifications in src/translations/en.json. Other languages are managed externally. Please see https://developers.home-assistant.io/docs/translations/ for details." ' +
|
||||||
files.join(" ") +
|
files.join(" ") +
|
||||||
" >&2 && exit 1",
|
" >&2 && exit 1",
|
||||||
"/yarn.lock": () => "yarn dedupe",
|
"yarn.lock": () => "yarn dedupe",
|
||||||
};
|
};
|
||||||
|
172
package.json
172
package.json
@@ -24,26 +24,26 @@
|
|||||||
"author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)",
|
"author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@braintree/sanitize-url": "^6.0.0",
|
"@braintree/sanitize-url": "^6.0.2",
|
||||||
"@codemirror/autocomplete": "^6.4.0",
|
"@codemirror/autocomplete": "^6.4.2",
|
||||||
"@codemirror/commands": "^6.1.3",
|
"@codemirror/commands": "^6.2.1",
|
||||||
"@codemirror/language": "^6.4.0",
|
"@codemirror/language": "^6.6.0",
|
||||||
"@codemirror/legacy-modes": "^6.3.1",
|
"@codemirror/legacy-modes": "^6.3.1",
|
||||||
"@codemirror/search": "^6.2.3",
|
"@codemirror/search": "^6.2.3",
|
||||||
"@codemirror/state": "^6.2.0",
|
"@codemirror/state": "^6.2.0",
|
||||||
"@codemirror/view": "^6.7.1",
|
"@codemirror/view": "^6.9.1",
|
||||||
"@formatjs/intl-datetimeformat": "^4.2.5",
|
"@egjs/hammerjs": "^2.0.17",
|
||||||
"@formatjs/intl-getcanonicallocales": "^2.0.5",
|
"@formatjs/intl-datetimeformat": "^6.5.1",
|
||||||
"@formatjs/intl-locale": "^3.0.11",
|
"@formatjs/intl-getcanonicallocales": "^2.1.0",
|
||||||
"@formatjs/intl-numberformat": "^7.2.5",
|
"@formatjs/intl-locale": "^3.1.1",
|
||||||
"@formatjs/intl-pluralrules": "^4.1.5",
|
"@formatjs/intl-numberformat": "^8.3.5",
|
||||||
"@formatjs/intl-relativetimeformat": "^9.3.2",
|
"@formatjs/intl-pluralrules": "^5.1.10",
|
||||||
"@fullcalendar/common": "5.9.0",
|
"@formatjs/intl-relativetimeformat": "^11.1.10",
|
||||||
"@fullcalendar/core": "5.9.0",
|
"@fullcalendar/core": "^6.1.4",
|
||||||
"@fullcalendar/daygrid": "5.9.0",
|
"@fullcalendar/daygrid": "^6.1.4",
|
||||||
"@fullcalendar/interaction": "5.9.0",
|
"@fullcalendar/interaction": "^6.1.4",
|
||||||
"@fullcalendar/list": "5.9.0",
|
"@fullcalendar/list": "^6.1.4",
|
||||||
"@fullcalendar/timegrid": "5.9.0",
|
"@fullcalendar/timegrid": "^6.1.4",
|
||||||
"@lezer/highlight": "^1.1.3",
|
"@lezer/highlight": "^1.1.3",
|
||||||
"@lit-labs/motion": "^1.0.3",
|
"@lit-labs/motion": "^1.0.3",
|
||||||
"@lit-labs/virtualizer": "^1.0.1",
|
"@lit-labs/virtualizer": "^1.0.1",
|
||||||
@@ -71,6 +71,7 @@
|
|||||||
"@material/mwc-textfield": "^0.27.0",
|
"@material/mwc-textfield": "^0.27.0",
|
||||||
"@material/mwc-top-app-bar-fixed": "^0.27.0",
|
"@material/mwc-top-app-bar-fixed": "^0.27.0",
|
||||||
"@material/top-app-bar": "=14.0.0-canary.53b3cad2f.0",
|
"@material/top-app-bar": "=14.0.0-canary.53b3cad2f.0",
|
||||||
|
"@material/web": "=1.0.0-pre.3",
|
||||||
"@mdi/js": "7.1.96",
|
"@mdi/js": "7.1.96",
|
||||||
"@mdi/svg": "7.1.96",
|
"@mdi/svg": "7.1.96",
|
||||||
"@polymer/app-layout": "^3.1.0",
|
"@polymer/app-layout": "^3.1.0",
|
||||||
@@ -88,55 +89,55 @@
|
|||||||
"@polymer/paper-tooltip": "^3.0.1",
|
"@polymer/paper-tooltip": "^3.0.1",
|
||||||
"@polymer/polymer": "3.4.1",
|
"@polymer/polymer": "3.4.1",
|
||||||
"@thomasloven/round-slider": "0.6.0",
|
"@thomasloven/round-slider": "0.6.0",
|
||||||
"@vaadin/combo-box": "^23.3.5",
|
"@vaadin/combo-box": "^23.3.7",
|
||||||
"@vaadin/vaadin-themable-mixin": "^23.3.5",
|
"@vaadin/vaadin-themable-mixin": "^23.3.7",
|
||||||
"@vibrant/color": "^3.2.1-alpha.1",
|
"@vibrant/color": "^3.2.1-alpha.1",
|
||||||
"@vibrant/core": "^3.2.1-alpha.1",
|
"@vibrant/core": "^3.2.1-alpha.1",
|
||||||
"@vibrant/quantizer-mmcq": "^3.2.1-alpha.1",
|
"@vibrant/quantizer-mmcq": "^3.2.1-alpha.1",
|
||||||
"@vue/web-component-wrapper": "^1.3.0",
|
"@vue/web-component-wrapper": "^1.3.0",
|
||||||
"@webcomponents/scoped-custom-element-registry": "^0.0.5",
|
"@webcomponents/scoped-custom-element-registry": "^0.0.8",
|
||||||
"@webcomponents/webcomponentsjs": "^2.2.10",
|
"@webcomponents/webcomponentsjs": "^2.7.0",
|
||||||
"app-datepicker": "^5.1.0",
|
"app-datepicker": "^5.1.0",
|
||||||
"chart.js": "^3.3.2",
|
"chart.js": "^3.3.2",
|
||||||
"comlink": "^4.3.1",
|
"comlink": "^4.4.1",
|
||||||
"core-js": "^3.15.2",
|
"core-js": "^3.29.0",
|
||||||
"cropperjs": "^1.5.13",
|
"cropperjs": "^1.5.13",
|
||||||
"date-fns": "^2.29.3",
|
"date-fns": "^2.29.3",
|
||||||
"date-fns-tz": "^1.3.7",
|
"date-fns-tz": "^2.0.0",
|
||||||
"deep-clone-simple": "^1.1.1",
|
"deep-clone-simple": "^1.1.1",
|
||||||
"deep-freeze": "^0.0.1",
|
"deep-freeze": "^0.0.1",
|
||||||
"fuse.js": "^6.6.2",
|
"fuse.js": "^6.6.2",
|
||||||
"google-timezones-json": "^1.0.2",
|
"google-timezones-json": "^1.0.2",
|
||||||
"hammerjs": "^2.0.8",
|
"hls.js": "^1.3.4",
|
||||||
"hls.js": "^1.3.1",
|
|
||||||
"home-assistant-js-websocket": "^8.0.1",
|
"home-assistant-js-websocket": "^8.0.1",
|
||||||
"idb-keyval": "^5.1.3",
|
"idb-keyval": "^6.2.0",
|
||||||
"intl-messageformat": "^10.2.5",
|
"intl-messageformat": "^10.3.1",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"leaflet": "^1.7.1",
|
"leaflet": "^1.9.3",
|
||||||
"leaflet-draw": "^1.0.4",
|
"leaflet-draw": "^1.0.4",
|
||||||
"lit": "^2.6.1",
|
"lit": "^2.6.1",
|
||||||
"marked": "^4.0.12",
|
"marked": "^4.2.12",
|
||||||
"memoize-one": "^6.0.0",
|
"memoize-one": "^6.0.0",
|
||||||
"node-vibrant": "3.2.1-alpha.1",
|
"node-vibrant": "3.2.1-alpha.1",
|
||||||
"proxy-polyfill": "^0.3.2",
|
"proxy-polyfill": "^0.3.2",
|
||||||
"punycode": "^2.3.0",
|
"punycode": "^2.3.0",
|
||||||
"qr-scanner": "^1.3.0",
|
"qr-scanner": "^1.4.2",
|
||||||
"qrcode": "^1.5.1",
|
"qrcode": "^1.5.1",
|
||||||
"regenerator-runtime": "^0.13.11",
|
"regenerator-runtime": "^0.13.11",
|
||||||
"resize-observer-polyfill": "^1.5.1",
|
"resize-observer-polyfill": "^1.5.1",
|
||||||
"roboto-fontface": "^0.10.0",
|
"roboto-fontface": "^0.10.0",
|
||||||
"rrule": "^2.7.1",
|
"rrule": "^2.7.2",
|
||||||
"sortablejs": "^1.14.0",
|
"sortablejs": "^1.15.0",
|
||||||
"superstruct": "^1.0.3",
|
"superstruct": "^1.0.3",
|
||||||
"tinykeys": "^1.1.3",
|
"tinykeys": "^1.4.0",
|
||||||
"tsparticles": "^1.34.0",
|
"tsparticles-engine": "^2.9.3",
|
||||||
"unfetch": "^4.1.0",
|
"tsparticles-preset-links": "^2.9.3",
|
||||||
"vis-data": "^7.1.2",
|
"unfetch": "^5.0.0",
|
||||||
"vis-network": "^8.5.4",
|
"vis-data": "^7.1.4",
|
||||||
"vue": "^2.6.12",
|
"vis-network": "^9.1.4",
|
||||||
"vue2-daterange-picker": "^0.5.1",
|
"vue": "^2.7.14",
|
||||||
"weekstart": "^1.1.0",
|
"vue2-daterange-picker": "^0.6.8",
|
||||||
|
"weekstart": "^2.0.0",
|
||||||
"workbox-cacheable-response": "^6.5.4",
|
"workbox-cacheable-response": "^6.5.4",
|
||||||
"workbox-core": "^6.5.4",
|
"workbox-core": "^6.5.4",
|
||||||
"workbox-expiration": "^6.5.4",
|
"workbox-expiration": "^6.5.4",
|
||||||
@@ -146,107 +147,110 @@
|
|||||||
"xss": "^1.0.14"
|
"xss": "^1.0.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.20.2",
|
"@babel/core": "^7.21.0",
|
||||||
"@babel/plugin-external-helpers": "^7.18.6",
|
"@babel/plugin-external-helpers": "^7.18.6",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
||||||
"@babel/plugin-proposal-decorators": "^7.20.7",
|
"@babel/plugin-proposal-decorators": "^7.21.0",
|
||||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
||||||
"@babel/plugin-proposal-object-rest-spread": "^7.20.2",
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
||||||
"@babel/plugin-proposal-optional-chaining": "^7.18.9",
|
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
||||||
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
||||||
"@babel/plugin-syntax-import-meta": "^7.10.4",
|
"@babel/plugin-syntax-import-meta": "^7.10.4",
|
||||||
"@babel/plugin-syntax-top-level-await": "^7.14.5",
|
"@babel/plugin-syntax-top-level-await": "^7.14.5",
|
||||||
"@babel/preset-env": "^7.20.2",
|
"@babel/preset-env": "^7.20.2",
|
||||||
"@babel/preset-typescript": "^7.18.6",
|
"@babel/preset-typescript": "^7.21.0",
|
||||||
"@koa/cors": "^3.1.0",
|
"@koa/cors": "^4.0.0",
|
||||||
"@octokit/auth-oauth-device": "^4.0.2",
|
"@octokit/auth-oauth-device": "^4.0.4",
|
||||||
"@octokit/rest": "^19.0.7",
|
"@octokit/rest": "^19.0.7",
|
||||||
"@open-wc/dev-server-hmr": "^0.0.2",
|
"@open-wc/dev-server-hmr": "^0.1.3",
|
||||||
"@rollup/plugin-babel": "^5.2.1",
|
"@rollup/plugin-babel": "^5.2.1",
|
||||||
"@rollup/plugin-commonjs": "^11.1.0",
|
"@rollup/plugin-commonjs": "^11.1.0",
|
||||||
"@rollup/plugin-json": "^4.0.3",
|
"@rollup/plugin-json": "^4.0.3",
|
||||||
"@rollup/plugin-node-resolve": "^7.1.3",
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
||||||
"@rollup/plugin-replace": "^2.3.2",
|
"@rollup/plugin-replace": "^2.3.2",
|
||||||
"@types/chromecast-caf-receiver": "5.0.12",
|
"@types/chromecast-caf-receiver": "5.0.12",
|
||||||
"@types/chromecast-caf-sender": "^1.0.3",
|
"@types/chromecast-caf-sender": "^1.0.5",
|
||||||
|
"@types/esprima": "^4",
|
||||||
"@types/glob": "^8",
|
"@types/glob": "^8",
|
||||||
"@types/hammerjs": "^2.0.41",
|
|
||||||
"@types/js-yaml": "^4",
|
"@types/js-yaml": "^4",
|
||||||
"@types/leaflet": "^1",
|
"@types/leaflet": "^1",
|
||||||
"@types/leaflet-draw": "^1",
|
"@types/leaflet-draw": "^1",
|
||||||
"@types/marked": "^4",
|
"@types/marked": "^4",
|
||||||
"@types/mocha": "^8",
|
"@types/mocha": "^10",
|
||||||
"@types/qrcode": "^1.5.0",
|
"@types/qrcode": "^1.5.0",
|
||||||
|
"@types/serve-handler": "^6",
|
||||||
"@types/sortablejs": "^1",
|
"@types/sortablejs": "^1",
|
||||||
"@types/tar": "^6",
|
"@types/tar": "^6",
|
||||||
"@types/webspeechapi": "^0.0.29",
|
"@types/webspeechapi": "^0.0.29",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
||||||
"@typescript-eslint/parser": "^5.49.0",
|
"@typescript-eslint/parser": "^5.54.0",
|
||||||
"@web/dev-server": "^0.0.24",
|
"@web/dev-server": "^0.1.35",
|
||||||
"@web/dev-server-rollup": "^0.2.11",
|
"@web/dev-server-rollup": "^0.2.11",
|
||||||
"babel-loader": "^9.1.0",
|
"babel-loader": "^9.1.2",
|
||||||
"chai": "^4.3.4",
|
"babel-plugin-template-html-minifier": "^4.1.0",
|
||||||
|
"chai": "^4.3.7",
|
||||||
"del": "^7.0.0",
|
"del": "^7.0.0",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^8.35.0",
|
||||||
"eslint-config-airbnb-base": "^14.2.1",
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
"eslint-config-airbnb-typescript": "^14.0.0",
|
"eslint-config-airbnb-typescript": "^17.0.0",
|
||||||
"eslint-config-prettier": "^8.6.0",
|
"eslint-config-prettier": "^8.6.0",
|
||||||
"eslint-import-resolver-webpack": "^0.13.1",
|
"eslint-import-resolver-webpack": "^0.13.2",
|
||||||
"eslint-plugin-disable": "^2.0.1",
|
"eslint-plugin-disable": "^2.0.3",
|
||||||
"eslint-plugin-import": "^2.24.2",
|
"eslint-plugin-import": "^2.27.5",
|
||||||
"eslint-plugin-lit": "^1.6.1",
|
"eslint-plugin-lit": "^1.8.2",
|
||||||
"eslint-plugin-unused-imports": "^1.1.5",
|
"eslint-plugin-lit-a11y": "^2.3.0",
|
||||||
|
"eslint-plugin-unused-imports": "^2.0.0",
|
||||||
"eslint-plugin-wc": "^1.4.0",
|
"eslint-plugin-wc": "^1.4.0",
|
||||||
|
"esprima": "^4.0.1",
|
||||||
"fancy-log": "^2.0.0",
|
"fancy-log": "^2.0.0",
|
||||||
"fs-extra": "^11.1.0",
|
"fs-extra": "^11.1.0",
|
||||||
"glob": "^8.1.0",
|
"glob": "^8.1.0",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-flatmap": "^1.0.2",
|
"gulp-flatmap": "^1.0.2",
|
||||||
"gulp-json-transform": "^0.4.6",
|
"gulp-json-transform": "^0.4.8",
|
||||||
"gulp-merge-json": "^2.1.2",
|
"gulp-merge-json": "^2.1.2",
|
||||||
"gulp-rename": "^2.0.0",
|
"gulp-rename": "^2.0.0",
|
||||||
"gulp-zopfli-green": "^3.0.1",
|
"gulp-zopfli-green": "^6.0.1",
|
||||||
"html-minifier": "^4.0.0",
|
"html-minifier": "^4.0.0",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"instant-mocha": "^1.3.1",
|
"instant-mocha": "^1.5.0",
|
||||||
"jszip": "^3.10.1",
|
"jszip": "^3.10.1",
|
||||||
"lint-staged": "^13.1.0",
|
"lint-staged": "^13.1.2",
|
||||||
"lit-analyzer": "^1.2.1",
|
"lit-analyzer": "^1.2.1",
|
||||||
"lodash.template": "^4.5.0",
|
"lodash.template": "^4.5.0",
|
||||||
"magic-string": "^0.25.7",
|
"magic-string": "^0.30.0",
|
||||||
"map-stream": "^0.0.7",
|
"map-stream": "^0.0.7",
|
||||||
"merge-stream": "^1.0.1",
|
"merge-stream": "^2.0.0",
|
||||||
"mocha": "^8.4.0",
|
"mocha": "^10.2.0",
|
||||||
"object-hash": "^3.0.0",
|
"object-hash": "^3.0.0",
|
||||||
"open": "^8.4.0",
|
"open": "^8.4.1",
|
||||||
"pinst": "^3.0.0",
|
"pinst": "^3.0.0",
|
||||||
"prettier": "^2.8.3",
|
"prettier": "^2.8.4",
|
||||||
"require-dir": "^1.2.0",
|
"require-dir": "^1.2.0",
|
||||||
"rollup": "^2.8.2",
|
"rollup": "^2.8.2",
|
||||||
"rollup-plugin-string": "^3.0.0",
|
"rollup-plugin-string": "^3.0.0",
|
||||||
"rollup-plugin-terser": "^5.3.0",
|
"rollup-plugin-terser": "^5.3.0",
|
||||||
"rollup-plugin-visualizer": "^5.9.0",
|
"rollup-plugin-visualizer": "^5.9.0",
|
||||||
"serve": "^11.3.2",
|
"serve-handler": "^6.1.5",
|
||||||
"sinon": "^15.0.1",
|
"sinon": "^15.0.1",
|
||||||
"source-map-url": "^0.4.0",
|
"source-map-url": "^0.4.1",
|
||||||
"systemjs": "^6.3.2",
|
"systemjs": "^6.14.0",
|
||||||
"tar": "^6.1.11",
|
"tar": "^6.1.13",
|
||||||
"terser-webpack-plugin": "^5.2.4",
|
"terser-webpack-plugin": "^5.3.6",
|
||||||
"ts-lit-plugin": "^1.2.1",
|
"ts-lit-plugin": "^1.2.1",
|
||||||
"typescript": "^4.9.4",
|
"typescript": "^4.9.5",
|
||||||
"vinyl-buffer": "^1.0.1",
|
"vinyl-buffer": "^1.0.1",
|
||||||
"vinyl-source-stream": "^2.0.0",
|
"vinyl-source-stream": "^2.0.0",
|
||||||
"webpack": "^5.55.1",
|
"webpack": "=5.72.1",
|
||||||
"webpack-cli": "^5.0.1",
|
"webpack-cli": "^5.0.1",
|
||||||
"webpack-dev-server": "^4.11.1",
|
"webpack-dev-server": "^4.11.1",
|
||||||
"webpack-manifest-plugin": "^4.0.2",
|
"webpack-manifest-plugin": "^5.0.0",
|
||||||
"webpackbar": "^5.0.2",
|
"webpackbar": "^5.0.2",
|
||||||
"workbox-build": "^6.5.4"
|
"workbox-build": "^6.5.4"
|
||||||
},
|
},
|
||||||
"_comment": "Polymer 3.2 contained a bug, fixed in https://github.com/Polymer/polymer/pull/5569, add as patch",
|
"_comment": "Polymer 3.2 contained a bug, fixed in https://github.com/Polymer/polymer/pull/5569, add as patch",
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"@polymer/polymer": "patch:@polymer/polymer@3.4.1#./.yarn/patches/@polymer/polymer/pr-5569.patch",
|
"@polymer/polymer": "patch:@polymer/polymer@3.4.1#./.yarn/patches/@polymer/polymer/pr-5569.patch"
|
||||||
"@webcomponents/webcomponentsjs": "^2.2.10"
|
|
||||||
},
|
},
|
||||||
"main": "src/home-assistant.js",
|
"main": "src/home-assistant.js",
|
||||||
"prettier": {
|
"prettier": {
|
||||||
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "home-assistant-frontend"
|
name = "home-assistant-frontend"
|
||||||
version = "20230128.0"
|
version = "20230302.0"
|
||||||
license = {text = "Apache-2.0"}
|
license = {text = "Apache-2.0"}
|
||||||
description = "The Home Assistant frontend"
|
description = "The Home Assistant frontend"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
@@ -6,6 +6,9 @@ set -e
|
|||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
STATS=1 NODE_ENV=production ./node_modules/.bin/webpack --profile --json > compilation-stats.json
|
export STATS=1
|
||||||
npx webpack-bundle-analyzer compilation-stats.json hass_frontend/frontend_latest
|
statsfile="compilation-stats.json"
|
||||||
rm compilation-stats.json
|
|
||||||
|
./node_modules/.bin/webpack-cli --profile --node-env=production --json=$statsfile
|
||||||
|
npx webpack-bundle-analyzer $statsfile hass_frontend/frontend_latest
|
||||||
|
rm -f $statsfile
|
||||||
|
@@ -5,10 +5,10 @@ import {
|
|||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
|
nothing,
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
TemplateResult,
|
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import "../components/ha-alert";
|
import "../components/ha-alert";
|
||||||
import "../components/ha-checkbox";
|
import "../components/ha-checkbox";
|
||||||
import { computeInitialHaFormData } from "../components/ha-form/compute-initial-ha-form-data";
|
import { computeInitialHaFormData } from "../components/ha-form/compute-initial-ha-form-data";
|
||||||
@@ -25,7 +25,8 @@ import "./ha-password-manager-polyfill";
|
|||||||
|
|
||||||
type State = "loading" | "error" | "step";
|
type State = "loading" | "error" | "step";
|
||||||
|
|
||||||
class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
@customElement("ha-auth-flow")
|
||||||
|
export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
||||||
@property({ attribute: false }) public authProvider?: AuthProvider;
|
@property({ attribute: false }) public authProvider?: AuthProvider;
|
||||||
|
|
||||||
@property() public clientId?: string;
|
@property() public clientId?: string;
|
||||||
@@ -133,11 +134,11 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
|||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _renderForm(): TemplateResult {
|
private _renderForm() {
|
||||||
switch (this._state) {
|
switch (this._state) {
|
||||||
case "step":
|
case "step":
|
||||||
if (this._step == null) {
|
if (this._step == null) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
${this._renderStep(this._step)}
|
${this._renderStep(this._step)}
|
||||||
@@ -175,11 +176,11 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
|||||||
</ha-alert>
|
</ha-alert>
|
||||||
`;
|
`;
|
||||||
default:
|
default:
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _renderStep(step: DataEntryFlowStep): TemplateResult {
|
private _renderStep(step: DataEntryFlowStep) {
|
||||||
switch (step.type) {
|
switch (step.type) {
|
||||||
case "abort":
|
case "abort":
|
||||||
return html`
|
return html`
|
||||||
@@ -201,7 +202,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
|||||||
.content=${this._computeStepDescription(step)}
|
.content=${this._computeStepDescription(step)}
|
||||||
></ha-markdown>
|
></ha-markdown>
|
||||||
`
|
`
|
||||||
: html``}
|
: nothing}
|
||||||
<ha-form
|
<ha-form
|
||||||
.data=${this._stepData}
|
.data=${this._stepData}
|
||||||
.schema=${autocompleteLoginFields(step.data_schema)}
|
.schema=${autocompleteLoginFields(step.data_schema)}
|
||||||
@@ -227,7 +228,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
|||||||
: ""}
|
: ""}
|
||||||
`;
|
`;
|
||||||
default:
|
default:
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,7 +408,6 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
customElements.define("ha-auth-flow", HaAuthFlow);
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
|
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
|
||||||
import { property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import punycode from "punycode";
|
import punycode from "punycode";
|
||||||
import { applyThemesOnElement } from "../common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../common/dom/apply_themes_on_element";
|
||||||
import { extractSearchParamsObject } from "../common/url/search-params";
|
import { extractSearchParamsObject } from "../common/url/search-params";
|
||||||
@@ -14,7 +14,8 @@ import "./ha-auth-flow";
|
|||||||
|
|
||||||
import("./ha-pick-auth-provider");
|
import("./ha-pick-auth-provider");
|
||||||
|
|
||||||
class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
|
@customElement("ha-authorize")
|
||||||
|
export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
|
||||||
@property() public clientId?: string;
|
@property() public clientId?: string;
|
||||||
|
|
||||||
@property() public redirectUri?: string;
|
@property() public redirectUri?: string;
|
||||||
@@ -183,4 +184,3 @@ class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
customElements.define("ha-authorize", HaAuthorize);
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable lit/prefer-static-styles */
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { html, LitElement, TemplateResult } from "lit";
|
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import { styleMap } from "lit/directives/style-map";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import type { HaFormSchema } from "../components/ha-form/types";
|
import type { HaFormSchema } from "../components/ha-form/types";
|
||||||
import { autocompleteLoginFields } from "../data/auth";
|
import { autocompleteLoginFields } from "../data/auth";
|
||||||
@@ -29,35 +29,43 @@ export class HaPasswordManagerPolyfill extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public boundingRect?: DOMRect;
|
@property({ attribute: false }) public boundingRect?: DOMRect;
|
||||||
|
|
||||||
|
private _styleElement?: HTMLStyleElement;
|
||||||
|
|
||||||
|
public connectedCallback() {
|
||||||
|
super.connectedCallback();
|
||||||
|
this._styleElement = document.createElement("style");
|
||||||
|
this._styleElement.textContent = css`
|
||||||
|
.password-manager-polyfill {
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
.password-manager-polyfill input {
|
||||||
|
width: 100%;
|
||||||
|
height: 62px;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
.password-manager-polyfill input[type="submit"] {
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
`.toString();
|
||||||
|
document.head.append(this._styleElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
public disconnectedCallback() {
|
||||||
|
super.disconnectedCallback();
|
||||||
|
this._styleElement?.remove();
|
||||||
|
delete this._styleElement;
|
||||||
|
}
|
||||||
|
|
||||||
protected createRenderRoot() {
|
protected createRenderRoot() {
|
||||||
// Add under document body so the element isn't placed inside any shadow roots
|
// Add under document body so the element isn't placed inside any shadow roots
|
||||||
return document.body;
|
return document.body;
|
||||||
}
|
}
|
||||||
|
|
||||||
private get styles() {
|
protected render() {
|
||||||
return `
|
|
||||||
.password-manager-polyfill {
|
|
||||||
position: absolute;
|
|
||||||
top: ${this.boundingRect?.y || 148}px;
|
|
||||||
left: calc(50% - ${(this.boundingRect?.width || 360) / 2}px);
|
|
||||||
width: ${this.boundingRect?.width || 360}px;
|
|
||||||
opacity: 0;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
.password-manager-polyfill input {
|
|
||||||
width: 100%;
|
|
||||||
height: 62px;
|
|
||||||
padding: 0;
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
.password-manager-polyfill input[type="submit"] {
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
|
||||||
if (
|
if (
|
||||||
this.step &&
|
this.step &&
|
||||||
this.step.type === "form" &&
|
this.step.type === "form" &&
|
||||||
@@ -67,6 +75,11 @@ export class HaPasswordManagerPolyfill extends LitElement {
|
|||||||
return html`
|
return html`
|
||||||
<form
|
<form
|
||||||
class="password-manager-polyfill"
|
class="password-manager-polyfill"
|
||||||
|
style=${styleMap({
|
||||||
|
top: `${this.boundingRect?.y || 148}px`,
|
||||||
|
left: `calc(50% - ${(this.boundingRect?.width || 360) / 2}px)`,
|
||||||
|
width: `${this.boundingRect?.width || 360}px`,
|
||||||
|
})}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
@submit=${this._handleSubmit}
|
@submit=${this._handleSubmit}
|
||||||
>
|
>
|
||||||
@@ -74,16 +87,13 @@ export class HaPasswordManagerPolyfill extends LitElement {
|
|||||||
this.render_input(input)
|
this.render_input(input)
|
||||||
)}
|
)}
|
||||||
<input type="submit" />
|
<input type="submit" />
|
||||||
<style>
|
|
||||||
${this.styles}
|
|
||||||
</style>
|
|
||||||
</form>
|
</form>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
private render_input(schema: HaFormSchema): TemplateResult | string {
|
private render_input(schema: HaFormSchema) {
|
||||||
const inputType = schema.name.includes("password") ? "password" : "text";
|
const inputType = schema.name.includes("password") ? "password" : "text";
|
||||||
if (schema.type !== "string") {
|
if (schema.type !== "string") {
|
||||||
return "";
|
return "";
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import "@polymer/paper-item/paper-item";
|
import "@polymer/paper-item/paper-item";
|
||||||
import "@polymer/paper-item/paper-item-body";
|
import "@polymer/paper-item/paper-item-body";
|
||||||
import { css, html, LitElement } from "lit";
|
import { css, html, LitElement } from "lit";
|
||||||
import { property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import "../components/ha-icon-next";
|
import "../components/ha-icon-next";
|
||||||
import { AuthProvider } from "../data/auth";
|
import { AuthProvider } from "../data/auth";
|
||||||
@@ -13,7 +13,8 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HaPickAuthProvider extends litLocalizeLiteMixin(LitElement) {
|
@customElement("ha-pick-auth-provider")
|
||||||
|
export class HaPickAuthProvider extends litLocalizeLiteMixin(LitElement) {
|
||||||
@property() public authProviders: AuthProvider[] = [];
|
@property() public authProviders: AuthProvider[] = [];
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
@@ -47,4 +48,3 @@ class HaPickAuthProvider extends litLocalizeLiteMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
customElements.define("ha-pick-auth-provider", HaPickAuthProvider);
|
|
||||||
|
@@ -2,6 +2,7 @@ type NonUndefined<T> = T extends undefined ? never : T;
|
|||||||
|
|
||||||
export function ensureArray(value: undefined): undefined;
|
export function ensureArray(value: undefined): undefined;
|
||||||
export function ensureArray<T>(value: T | T[]): NonUndefined<T>[];
|
export function ensureArray<T>(value: T | T[]): NonUndefined<T>[];
|
||||||
|
export function ensureArray<T>(value: T | readonly T[]): NonUndefined<T>[];
|
||||||
export function ensureArray(value) {
|
export function ensureArray(value) {
|
||||||
if (value === undefined || Array.isArray(value)) {
|
if (value === undefined || Array.isArray(value)) {
|
||||||
return value;
|
return value;
|
||||||
|
@@ -22,3 +22,11 @@ export const atLeastVersion = (
|
|||||||
Number(haPatch) >= patch)
|
Number(haPatch) >= patch)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isDevVersion = (version: string): boolean => {
|
||||||
|
if (__DEMO__) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return version.includes("dev");
|
||||||
|
};
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
/** Constants to be used in the frontend. */
|
/** Constants to be used in the frontend. */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
mdiAccount,
|
|
||||||
mdiAirFilter,
|
mdiAirFilter,
|
||||||
mdiAlert,
|
mdiAlert,
|
||||||
mdiAngleAcute,
|
mdiAngleAcute,
|
||||||
@@ -24,7 +23,6 @@ import {
|
|||||||
mdiDatabase,
|
mdiDatabase,
|
||||||
mdiEarHearing,
|
mdiEarHearing,
|
||||||
mdiEye,
|
mdiEye,
|
||||||
mdiFan,
|
|
||||||
mdiFlash,
|
mdiFlash,
|
||||||
mdiFlower,
|
mdiFlower,
|
||||||
mdiFormatListBulleted,
|
mdiFormatListBulleted,
|
||||||
@@ -49,7 +47,6 @@ import {
|
|||||||
mdiProgressClock,
|
mdiProgressClock,
|
||||||
mdiRayVertex,
|
mdiRayVertex,
|
||||||
mdiRemote,
|
mdiRemote,
|
||||||
mdiRobot,
|
|
||||||
mdiRobotVacuum,
|
mdiRobotVacuum,
|
||||||
mdiScriptText,
|
mdiScriptText,
|
||||||
mdiSineWave,
|
mdiSineWave,
|
||||||
@@ -60,15 +57,12 @@ import {
|
|||||||
mdiThermostat,
|
mdiThermostat,
|
||||||
mdiTimerOutline,
|
mdiTimerOutline,
|
||||||
mdiTransmissionTower,
|
mdiTransmissionTower,
|
||||||
mdiVideo,
|
|
||||||
mdiWater,
|
mdiWater,
|
||||||
mdiWaterPercent,
|
mdiWaterPercent,
|
||||||
mdiWeatherCloudy,
|
|
||||||
mdiWeatherPouring,
|
mdiWeatherPouring,
|
||||||
mdiWeatherRainy,
|
mdiWeatherRainy,
|
||||||
mdiWeatherWindy,
|
mdiWeatherWindy,
|
||||||
mdiWeight,
|
mdiWeight,
|
||||||
mdiWhiteBalanceSunny,
|
|
||||||
mdiWifi,
|
mdiWifi,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
|
|
||||||
@@ -83,15 +77,12 @@ export const DEFAULT_DOMAIN_ICON = mdiBookmark;
|
|||||||
export const FIXED_DOMAIN_ICONS = {
|
export const FIXED_DOMAIN_ICONS = {
|
||||||
alert: mdiAlert,
|
alert: mdiAlert,
|
||||||
air_quality: mdiAirFilter,
|
air_quality: mdiAirFilter,
|
||||||
automation: mdiRobot,
|
|
||||||
calendar: mdiCalendar,
|
calendar: mdiCalendar,
|
||||||
camera: mdiVideo,
|
|
||||||
climate: mdiThermostat,
|
climate: mdiThermostat,
|
||||||
configurator: mdiCog,
|
configurator: mdiCog,
|
||||||
conversation: mdiMicrophoneMessage,
|
conversation: mdiMicrophoneMessage,
|
||||||
counter: mdiCounter,
|
counter: mdiCounter,
|
||||||
demo: mdiHomeAssistant,
|
demo: mdiHomeAssistant,
|
||||||
fan: mdiFan,
|
|
||||||
google_assistant: mdiGoogleAssistant,
|
google_assistant: mdiGoogleAssistant,
|
||||||
group: mdiGoogleCirclesCommunities,
|
group: mdiGoogleCirclesCommunities,
|
||||||
homeassistant: mdiHomeAssistant,
|
homeassistant: mdiHomeAssistant,
|
||||||
@@ -107,7 +98,6 @@ export const FIXED_DOMAIN_ICONS = {
|
|||||||
notify: mdiCommentAlert,
|
notify: mdiCommentAlert,
|
||||||
number: mdiRayVertex,
|
number: mdiRayVertex,
|
||||||
persistent_notification: mdiBell,
|
persistent_notification: mdiBell,
|
||||||
person: mdiAccount,
|
|
||||||
plant: mdiFlower,
|
plant: mdiFlower,
|
||||||
proximity: mdiAppleSafari,
|
proximity: mdiAppleSafari,
|
||||||
remote: mdiRemote,
|
remote: mdiRemote,
|
||||||
@@ -118,13 +108,10 @@ export const FIXED_DOMAIN_ICONS = {
|
|||||||
sensor: mdiEye,
|
sensor: mdiEye,
|
||||||
siren: mdiBullhorn,
|
siren: mdiBullhorn,
|
||||||
simple_alarm: mdiBell,
|
simple_alarm: mdiBell,
|
||||||
sun: mdiWhiteBalanceSunny,
|
|
||||||
text: mdiFormTextbox,
|
text: mdiFormTextbox,
|
||||||
timer: mdiTimerOutline,
|
timer: mdiTimerOutline,
|
||||||
updater: mdiCloudUpload,
|
updater: mdiCloudUpload,
|
||||||
vacuum: mdiRobotVacuum,
|
vacuum: mdiRobotVacuum,
|
||||||
water_heater: mdiThermometer,
|
|
||||||
weather: mdiWeatherCloudy,
|
|
||||||
zone: mdiMapMarkerRadius,
|
zone: mdiMapMarkerRadius,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -10,11 +10,19 @@ export const createDurationData = (
|
|||||||
if (typeof duration !== "object") {
|
if (typeof duration !== "object") {
|
||||||
if (typeof duration === "string" || isNaN(duration)) {
|
if (typeof duration === "string" || isNaN(duration)) {
|
||||||
const parts = duration?.toString().split(":") || [];
|
const parts = duration?.toString().split(":") || [];
|
||||||
|
if (parts.length === 1) {
|
||||||
|
return { seconds: Number(parts[0]) };
|
||||||
|
}
|
||||||
|
if (parts.length > 3) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const seconds = Number(parts[2]) || 0;
|
||||||
|
const seconds_whole = Math.floor(seconds);
|
||||||
return {
|
return {
|
||||||
hours: Number(parts[0]) || 0,
|
hours: Number(parts[0]) || 0,
|
||||||
minutes: Number(parts[1]) || 0,
|
minutes: Number(parts[1]) || 0,
|
||||||
seconds: Number(parts[2]) || 0,
|
seconds: seconds_whole,
|
||||||
milliseconds: Number(parts[3]) || 0,
|
milliseconds: Math.floor((seconds - seconds_whole) * 1000),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return { seconds: duration };
|
return { seconds: duration };
|
||||||
|
@@ -1,6 +1,12 @@
|
|||||||
import { getWeekStartByLocale } from "weekstart";
|
import { getWeekStartByLocale } from "weekstart";
|
||||||
import { FrontendLocaleData, FirstWeekday } from "../../data/translation";
|
import { FrontendLocaleData, FirstWeekday } from "../../data/translation";
|
||||||
|
|
||||||
|
import { polyfillsLoaded } from "../translations/localize";
|
||||||
|
|
||||||
|
if (__BUILD__ === "latest" && polyfillsLoaded) {
|
||||||
|
await polyfillsLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
export const weekdays = [
|
export const weekdays = [
|
||||||
"sunday",
|
"sunday",
|
||||||
"monday",
|
"monday",
|
||||||
|
@@ -11,8 +11,7 @@ export const setupLeafletMap = async (
|
|||||||
throw new Error("Cannot setup Leaflet map on disconnected element");
|
throw new Error("Cannot setup Leaflet map on disconnected element");
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
const Leaflet = ((await import("leaflet")) as any)
|
const Leaflet = (await import("leaflet")).default as LeafletModuleType;
|
||||||
.default as LeafletModuleType;
|
|
||||||
Leaflet.Icon.Default.imagePath = "/static/images/leaflet/images/";
|
Leaflet.Icon.Default.imagePath = "/static/images/leaflet/images/";
|
||||||
|
|
||||||
const map = Leaflet.map(mapElement);
|
const map = Leaflet.map(mapElement);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { EntityRegistryEntry } from "../../data/entity_registry";
|
import { EntityRegistryDisplayEntry } from "../../data/entity_registry";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import { LocalizeFunc } from "../translations/localize";
|
import { LocalizeFunc } from "../translations/localize";
|
||||||
import { computeDomain } from "./compute_domain";
|
import { computeDomain } from "./compute_domain";
|
||||||
@@ -15,7 +15,7 @@ export const computeAttributeValueDisplay = (
|
|||||||
const attributeValue =
|
const attributeValue =
|
||||||
value !== undefined ? value : stateObj.attributes[attribute];
|
value !== undefined ? value : stateObj.attributes[attribute];
|
||||||
const domain = computeDomain(entityId);
|
const domain = computeDomain(entityId);
|
||||||
const entity = entities[entityId] as EntityRegistryEntry | undefined;
|
const entity = entities[entityId] as EntityRegistryDisplayEntry | undefined;
|
||||||
const translationKey = entity?.translation_key;
|
const translationKey = entity?.translation_key;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -38,7 +38,7 @@ export const computeAttributeNameDisplay = (
|
|||||||
): string => {
|
): string => {
|
||||||
const entityId = stateObj.entity_id;
|
const entityId = stateObj.entity_id;
|
||||||
const domain = computeDomain(entityId);
|
const domain = computeDomain(entityId);
|
||||||
const entity = entities[entityId] as EntityRegistryEntry | undefined;
|
const entity = entities[entityId] as EntityRegistryDisplayEntry | undefined;
|
||||||
const translationKey = entity?.translation_key;
|
const translationKey = entity?.translation_key;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { UNAVAILABLE, UNKNOWN } from "../../data/entity";
|
import { UNAVAILABLE, UNKNOWN } from "../../data/entity";
|
||||||
import { EntityRegistryEntry } from "../../data/entity_registry";
|
import { EntityRegistryDisplayEntry } from "../../data/entity_registry";
|
||||||
import { FrontendLocaleData } from "../../data/translation";
|
import { FrontendLocaleData } from "../../data/translation";
|
||||||
import {
|
import {
|
||||||
updateIsInstallingFromAttributes,
|
updateIsInstallingFromAttributes,
|
||||||
@@ -49,6 +49,8 @@ export const computeStateDisplayFromEntityAttributes = (
|
|||||||
return localize(`state.default.${state}`);
|
return localize(`state.default.${state}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const entity = entities[entityId] as EntityRegistryDisplayEntry | undefined;
|
||||||
|
|
||||||
// Entities with a `unit_of_measurement` or `state_class` are numeric values and should use `formatNumber`
|
// Entities with a `unit_of_measurement` or `state_class` are numeric values and should use `formatNumber`
|
||||||
if (isNumericFromAttributes(attributes)) {
|
if (isNumericFromAttributes(attributes)) {
|
||||||
// state is duration
|
// state is duration
|
||||||
@@ -82,7 +84,7 @@ export const computeStateDisplayFromEntityAttributes = (
|
|||||||
return `${formatNumber(
|
return `${formatNumber(
|
||||||
state,
|
state,
|
||||||
locale,
|
locale,
|
||||||
getNumberFormatOptions({ state, attributes } as HassEntity)
|
getNumberFormatOptions({ state, attributes } as HassEntity, entity)
|
||||||
)}${unit}`;
|
)}${unit}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +162,7 @@ export const computeStateDisplayFromEntityAttributes = (
|
|||||||
return formatNumber(
|
return formatNumber(
|
||||||
state,
|
state,
|
||||||
locale,
|
locale,
|
||||||
getNumberFormatOptions({ state, attributes } as HassEntity)
|
getNumberFormatOptions({ state, attributes } as HassEntity, entity)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,8 +201,6 @@ export const computeStateDisplayFromEntityAttributes = (
|
|||||||
: localize("ui.card.update.up_to_date");
|
: localize("ui.card.update.up_to_date");
|
||||||
}
|
}
|
||||||
|
|
||||||
const entity = entities[entityId] as EntityRegistryEntry | undefined;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
(entity?.translation_key &&
|
(entity?.translation_key &&
|
||||||
localize(
|
localize(
|
||||||
|
@@ -15,6 +15,8 @@ import {
|
|||||||
mdiCheckCircleOutline,
|
mdiCheckCircleOutline,
|
||||||
mdiClock,
|
mdiClock,
|
||||||
mdiCloseCircleOutline,
|
mdiCloseCircleOutline,
|
||||||
|
mdiFan,
|
||||||
|
mdiFanOff,
|
||||||
mdiGestureTapButton,
|
mdiGestureTapButton,
|
||||||
mdiLanConnect,
|
mdiLanConnect,
|
||||||
mdiLanDisconnect,
|
mdiLanDisconnect,
|
||||||
@@ -28,6 +30,8 @@ import {
|
|||||||
mdiPowerPlug,
|
mdiPowerPlug,
|
||||||
mdiPowerPlugOff,
|
mdiPowerPlugOff,
|
||||||
mdiRestart,
|
mdiRestart,
|
||||||
|
mdiRobot,
|
||||||
|
mdiRobotOff,
|
||||||
mdiSpeaker,
|
mdiSpeaker,
|
||||||
mdiSpeakerOff,
|
mdiSpeakerOff,
|
||||||
mdiSpeakerPause,
|
mdiSpeakerPause,
|
||||||
@@ -39,7 +43,12 @@ import {
|
|||||||
mdiTelevisionPlay,
|
mdiTelevisionPlay,
|
||||||
mdiToggleSwitchVariant,
|
mdiToggleSwitchVariant,
|
||||||
mdiToggleSwitchVariantOff,
|
mdiToggleSwitchVariantOff,
|
||||||
|
mdiVideo,
|
||||||
|
mdiVideoOff,
|
||||||
|
mdiWaterBoiler,
|
||||||
|
mdiWaterBoilerOff,
|
||||||
mdiWeatherNight,
|
mdiWeatherNight,
|
||||||
|
mdiWhiteBalanceSunny,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { UpdateEntity, updateIsInstalling } from "../../data/update";
|
import { UpdateEntity, updateIsInstalling } from "../../data/update";
|
||||||
@@ -81,6 +90,9 @@ export const domainIconWithoutDefault = (
|
|||||||
case "alarm_control_panel":
|
case "alarm_control_panel":
|
||||||
return alarmPanelIcon(compareState);
|
return alarmPanelIcon(compareState);
|
||||||
|
|
||||||
|
case "automation":
|
||||||
|
return compareState === "off" ? mdiRobotOff : mdiRobot;
|
||||||
|
|
||||||
case "binary_sensor":
|
case "binary_sensor":
|
||||||
return binarySensorIcon(compareState, stateObj);
|
return binarySensorIcon(compareState, stateObj);
|
||||||
|
|
||||||
@@ -94,6 +106,9 @@ export const domainIconWithoutDefault = (
|
|||||||
return mdiGestureTapButton;
|
return mdiGestureTapButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "camera":
|
||||||
|
return compareState === "off" ? mdiVideoOff : mdiVideo;
|
||||||
|
|
||||||
case "cover":
|
case "cover":
|
||||||
return coverIcon(compareState, stateObj);
|
return coverIcon(compareState, stateObj);
|
||||||
|
|
||||||
@@ -108,6 +123,9 @@ export const domainIconWithoutDefault = (
|
|||||||
}
|
}
|
||||||
return compareState === "not_home" ? mdiAccountArrowRight : mdiAccount;
|
return compareState === "not_home" ? mdiAccountArrowRight : mdiAccount;
|
||||||
|
|
||||||
|
case "fan":
|
||||||
|
return compareState === "off" ? mdiFanOff : mdiFan;
|
||||||
|
|
||||||
case "humidifier":
|
case "humidifier":
|
||||||
return compareState === "off" ? mdiAirHumidifierOff : mdiAirHumidifier;
|
return compareState === "off" ? mdiAirHumidifierOff : mdiAirHumidifier;
|
||||||
|
|
||||||
@@ -216,7 +234,7 @@ export const domainIconWithoutDefault = (
|
|||||||
|
|
||||||
case "sun":
|
case "sun":
|
||||||
return stateObj?.state === "above_horizon"
|
return stateObj?.state === "above_horizon"
|
||||||
? FIXED_DOMAIN_ICONS[domain]
|
? mdiWhiteBalanceSunny
|
||||||
: mdiWeatherNight;
|
: mdiWeatherNight;
|
||||||
|
|
||||||
case "switch_as_x":
|
case "switch_as_x":
|
||||||
@@ -232,6 +250,9 @@ export const domainIconWithoutDefault = (
|
|||||||
: mdiPackageUp
|
: mdiPackageUp
|
||||||
: mdiPackage;
|
: mdiPackage;
|
||||||
|
|
||||||
|
case "water_heater":
|
||||||
|
return compareState === "off" ? mdiWaterBoilerOff : mdiWaterBoiler;
|
||||||
|
|
||||||
case "weather":
|
case "weather":
|
||||||
return weatherIcon(stateObj?.state);
|
return weatherIcon(stateObj?.state);
|
||||||
}
|
}
|
||||||
|
@@ -4,12 +4,15 @@ import { domainToName } from "../../data/integration";
|
|||||||
import { getIntegrationDescriptions } from "../../data/integrations";
|
import { getIntegrationDescriptions } from "../../data/integrations";
|
||||||
import { showConfigFlowDialog } from "../../dialogs/config-flow/show-dialog-config-flow";
|
import { showConfigFlowDialog } from "../../dialogs/config-flow/show-dialog-config-flow";
|
||||||
import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box";
|
import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box";
|
||||||
|
import { showMatterAddDeviceDialog } from "../../panels/config/integrations/integration-panels/matter/show-dialog-add-matter-device";
|
||||||
import { showZWaveJSAddNodeDialog } from "../../panels/config/integrations/integration-panels/zwave_js/show-dialog-zwave_js-add-node";
|
import { showZWaveJSAddNodeDialog } from "../../panels/config/integrations/integration-panels/zwave_js/show-dialog-zwave_js-add-node";
|
||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
import { documentationUrl } from "../../util/documentation-url";
|
import { documentationUrl } from "../../util/documentation-url";
|
||||||
import { isComponentLoaded } from "../config/is_component_loaded";
|
import { isComponentLoaded } from "../config/is_component_loaded";
|
||||||
import { navigate } from "../navigate";
|
import { navigate } from "../navigate";
|
||||||
|
|
||||||
|
export const PROTOCOL_INTEGRATIONS = ["zha", "zwave_js", "matter"] as const;
|
||||||
|
|
||||||
export const protocolIntegrationPicked = async (
|
export const protocolIntegrationPicked = async (
|
||||||
element: HTMLElement,
|
element: HTMLElement,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@@ -113,5 +116,43 @@ export const protocolIntegrationPicked = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
navigate("/config/zha/add");
|
navigate("/config/zha/add");
|
||||||
|
} else if (domain === "matter") {
|
||||||
|
const entries = await getConfigEntries(hass, {
|
||||||
|
domain,
|
||||||
|
});
|
||||||
|
if (!isComponentLoaded(hass, domain) || !entries.length) {
|
||||||
|
// If the component isn't loaded, ask them to load the integration first
|
||||||
|
showConfirmationDialog(element, {
|
||||||
|
title: hass.localize(
|
||||||
|
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee_title",
|
||||||
|
{ integration: "Matter" }
|
||||||
|
),
|
||||||
|
text: hass.localize(
|
||||||
|
"ui.panel.config.integrations.config_flow.missing_matter",
|
||||||
|
{
|
||||||
|
integration: "Matter",
|
||||||
|
brand: options?.brand || options?.domain || "Matter",
|
||||||
|
supported_hardware_link: html`<a
|
||||||
|
href=${documentationUrl(hass, "/integrations/matter")}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>${hass.localize(
|
||||||
|
"ui.panel.config.integrations.config_flow.supported_hardware"
|
||||||
|
)}</a
|
||||||
|
>`,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
confirmText: hass.localize(
|
||||||
|
"ui.panel.config.integrations.config_flow.proceed"
|
||||||
|
),
|
||||||
|
confirm: () => {
|
||||||
|
showConfigFlowDialog(element, {
|
||||||
|
startFlowHandler: "matter",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
showMatterAddDeviceDialog(element);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -2,6 +2,7 @@ import {
|
|||||||
HassEntity,
|
HassEntity,
|
||||||
HassEntityAttributeBase,
|
HassEntityAttributeBase,
|
||||||
} from "home-assistant-js-websocket";
|
} from "home-assistant-js-websocket";
|
||||||
|
import { EntityRegistryDisplayEntry } from "../../data/entity_registry";
|
||||||
import { FrontendLocaleData, NumberFormat } from "../../data/translation";
|
import { FrontendLocaleData, NumberFormat } from "../../data/translation";
|
||||||
import { round } from "./round";
|
import { round } from "./round";
|
||||||
|
|
||||||
@@ -76,6 +77,26 @@ export const formatNumber = (
|
|||||||
).format(Number(num));
|
).format(Number(num));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!Number.isNaN(Number(num)) &&
|
||||||
|
num !== "" &&
|
||||||
|
localeOptions?.number_format === NumberFormat.none &&
|
||||||
|
Intl &&
|
||||||
|
(options?.maximumFractionDigits != null ||
|
||||||
|
options?.minimumFractionDigits != null)
|
||||||
|
) {
|
||||||
|
// If NumberFormat is none, just set the digits options for precision and use en-US format without grouping.
|
||||||
|
return new Intl.NumberFormat(
|
||||||
|
"en-US",
|
||||||
|
getDefaultFormatOptions(num, {
|
||||||
|
useGrouping: false,
|
||||||
|
maximumFractionDigits: options?.maximumFractionDigits,
|
||||||
|
minimumFractionDigits: options?.minimumFractionDigits,
|
||||||
|
})
|
||||||
|
).format(Number(num));
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof num === "string") {
|
if (typeof num === "string") {
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
@@ -90,8 +111,16 @@ export const formatNumber = (
|
|||||||
* @returns An `Intl.NumberFormatOptions` object with `maximumFractionDigits` set to 0, or `undefined`
|
* @returns An `Intl.NumberFormatOptions` object with `maximumFractionDigits` set to 0, or `undefined`
|
||||||
*/
|
*/
|
||||||
export const getNumberFormatOptions = (
|
export const getNumberFormatOptions = (
|
||||||
entityState: HassEntity
|
entityState: HassEntity,
|
||||||
|
entity?: EntityRegistryDisplayEntry
|
||||||
): Intl.NumberFormatOptions | undefined => {
|
): Intl.NumberFormatOptions | undefined => {
|
||||||
|
const precision = entity?.display_precision;
|
||||||
|
if (precision != null) {
|
||||||
|
return {
|
||||||
|
maximumFractionDigits: precision,
|
||||||
|
minimumFractionDigits: precision,
|
||||||
|
};
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
Number.isInteger(Number(entityState.attributes?.step)) &&
|
Number.isInteger(Number(entityState.attributes?.step)) &&
|
||||||
Number.isInteger(Number(entityState.state))
|
Number.isInteger(Number(entityState.state))
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
const isTemplateRegex = new RegExp("{%|{{");
|
const isTemplateRegex = /{%|{{/;
|
||||||
|
|
||||||
export const isTemplate = (value: string): boolean =>
|
export const isTemplate = (value: string): boolean =>
|
||||||
isTemplateRegex.test(value);
|
isTemplateRegex.test(value);
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { refine, string } from "superstruct";
|
import { refine, string } from "superstruct";
|
||||||
|
import { isCustomType } from "../../data/lovelace_custom_cards";
|
||||||
export const isCustomType = (value: string) => value.startsWith("custom:");
|
|
||||||
|
|
||||||
export const customType = () =>
|
export const customType = () =>
|
||||||
refine(string(), "custom element type", isCustomType);
|
refine(string(), "custom element type", isCustomType);
|
||||||
|
@@ -65,19 +65,21 @@ export interface FormatsType {
|
|||||||
|
|
||||||
const loadedPolyfillLocale = new Set();
|
const loadedPolyfillLocale = new Set();
|
||||||
|
|
||||||
|
const locale = getLocalLanguage();
|
||||||
|
|
||||||
const polyfills: Promise<any>[] = [];
|
const polyfills: Promise<any>[] = [];
|
||||||
if (__BUILD__ === "latest") {
|
if (__BUILD__ === "latest") {
|
||||||
if (shouldPolyfillLocale()) {
|
if (shouldPolyfillLocale()) {
|
||||||
polyfills.push(import("@formatjs/intl-locale/polyfill"));
|
await import("@formatjs/intl-locale/polyfill");
|
||||||
}
|
}
|
||||||
if (shouldPolyfillPluralRules()) {
|
if (shouldPolyfillPluralRules(locale)) {
|
||||||
polyfills.push(import("@formatjs/intl-pluralrules/polyfill"));
|
polyfills.push(import("@formatjs/intl-pluralrules/polyfill"));
|
||||||
polyfills.push(import("@formatjs/intl-pluralrules/locale-data/en"));
|
polyfills.push(import("@formatjs/intl-pluralrules/locale-data/en"));
|
||||||
}
|
}
|
||||||
if (shouldPolyfillRelativeTime()) {
|
if (shouldPolyfillRelativeTime(locale)) {
|
||||||
polyfills.push(import("@formatjs/intl-relativetimeformat/polyfill"));
|
polyfills.push(import("@formatjs/intl-relativetimeformat/polyfill"));
|
||||||
}
|
}
|
||||||
if (shouldPolyfillDateTime()) {
|
if (shouldPolyfillDateTime(locale)) {
|
||||||
polyfills.push(import("@formatjs/intl-datetimeformat/polyfill"));
|
polyfills.push(import("@formatjs/intl-datetimeformat/polyfill"));
|
||||||
polyfills.push(import("@formatjs/intl-datetimeformat/add-all-tz"));
|
polyfills.push(import("@formatjs/intl-datetimeformat/add-all-tz"));
|
||||||
}
|
}
|
||||||
@@ -88,7 +90,7 @@ export const polyfillsLoaded =
|
|||||||
? undefined
|
? undefined
|
||||||
: Promise.all(polyfills).then(() =>
|
: Promise.all(polyfills).then(() =>
|
||||||
// Load the default language
|
// Load the default language
|
||||||
loadPolyfillLocales(getLocalLanguage())
|
loadPolyfillLocales(locale)
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,7 +216,7 @@ export const loadPolyfillLocales = async (language: string) => {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
Intl.DateTimeFormat.__addLocaleData(await result.json());
|
Intl.DateTimeFormat.__addLocaleData(await result.json());
|
||||||
}
|
}
|
||||||
} catch (_e) {
|
} catch (e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -19,6 +19,7 @@ const SECS_PER_HOUR = SECS_PER_MIN * 60;
|
|||||||
// Adapted from https://github.com/formatjs/formatjs/blob/186cef62f980ec66252ee232f438a42d0b51b9f9/packages/intl-utils/src/diff.ts
|
// Adapted from https://github.com/formatjs/formatjs/blob/186cef62f980ec66252ee232f438a42d0b51b9f9/packages/intl-utils/src/diff.ts
|
||||||
export function selectUnit(
|
export function selectUnit(
|
||||||
from: Date | number,
|
from: Date | number,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/default-param-last
|
||||||
to: Date | number = Date.now(),
|
to: Date | number = Date.now(),
|
||||||
locale: FrontendLocaleData,
|
locale: FrontendLocaleData,
|
||||||
thresholds: Partial<Thresholds> = {}
|
thresholds: Partial<Thresholds> = {}
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
import { css, CSSResultGroup, html, LitElement } from "lit";
|
import { css, CSSResultGroup, html, LitElement } from "lit";
|
||||||
import { property, query } from "lit/decorators";
|
import { customElement, property, query } from "lit/decorators";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import "./ha-progress-button";
|
import "./ha-progress-button";
|
||||||
|
|
||||||
|
@customElement("ha-call-api-button")
|
||||||
class HaCallApiButton extends LitElement {
|
class HaCallApiButton extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@@ -69,8 +70,6 @@ class HaCallApiButton extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define("ha-call-api-button", HaCallApiButton);
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"ha-call-api-button": HaCallApiButton;
|
"ha-call-api-button": HaCallApiButton;
|
||||||
|
@@ -233,7 +233,11 @@ export default class HaChartBase extends LitElement {
|
|||||||
{
|
{
|
||||||
id: "afterRenderHook",
|
id: "afterRenderHook",
|
||||||
afterRender: (chart) => {
|
afterRender: (chart) => {
|
||||||
this._chartHeight = chart.height;
|
const change = chart.height - (this._chartHeight ?? 0);
|
||||||
|
if (!this._chartHeight || change > 0 || change < -12) {
|
||||||
|
// hysteresis to prevent infinite render loops
|
||||||
|
this._chartHeight = chart.height;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
...this.options?.plugins?.legend,
|
...this.options?.plugins?.legend,
|
||||||
|
@@ -22,7 +22,7 @@ class StateHistoryChartLine extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public data: LineChartEntity[] = [];
|
@property({ attribute: false }) public data: LineChartEntity[] = [];
|
||||||
|
|
||||||
@property() public names: boolean | Record<string, string> = false;
|
@property() public names?: Record<string, string>;
|
||||||
|
|
||||||
@property() public unit?: string;
|
@property() public unit?: string;
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ export class StateHistoryChartTimeline extends LitElement {
|
|||||||
|
|
||||||
@property() public narrow!: boolean;
|
@property() public narrow!: boolean;
|
||||||
|
|
||||||
@property() public names: boolean | Record<string, string> = false;
|
@property() public names?: Record<string, string>;
|
||||||
|
|
||||||
@property() public unit?: string;
|
@property() public unit?: string;
|
||||||
|
|
||||||
@@ -64,6 +64,8 @@ export class StateHistoryChartTimeline extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
changedProps.has("startTime") ||
|
||||||
|
changedProps.has("endTime") ||
|
||||||
changedProps.has("data") ||
|
changedProps.has("data") ||
|
||||||
this._chartTime <
|
this._chartTime <
|
||||||
new Date(this.endTime.getTime() - MIN_TIME_BETWEEN_UPDATES)
|
new Date(this.endTime.getTime() - MIN_TIME_BETWEEN_UPDATES)
|
||||||
@@ -141,7 +143,10 @@ export class StateHistoryChartTimeline extends LitElement {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
afterUpdate: (y) => {
|
afterUpdate: (y) => {
|
||||||
if (this._yWidth !== Math.floor(y.width)) {
|
if (
|
||||||
|
this._yWidth !== Math.floor(y.width) &&
|
||||||
|
y.ticks.length === this.data.length
|
||||||
|
) {
|
||||||
this._yWidth = Math.floor(y.width);
|
this._yWidth = Math.floor(y.width);
|
||||||
fireEvent(this, "y-width-changed", {
|
fireEvent(this, "y-width-changed", {
|
||||||
value: this._yWidth,
|
value: this._yWidth,
|
||||||
|
@@ -4,11 +4,12 @@ import {
|
|||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
|
nothing,
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
TemplateResult,
|
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, state, eventOptions } from "lit/decorators";
|
import { customElement, eventOptions, property, state } from "lit/decorators";
|
||||||
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
||||||
|
import { restoreScroll } from "../../common/decorators/restore-scroll";
|
||||||
import {
|
import {
|
||||||
HistoryResult,
|
HistoryResult,
|
||||||
LineChartUnit,
|
LineChartUnit,
|
||||||
@@ -17,7 +18,6 @@ import {
|
|||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
import "./state-history-chart-line";
|
import "./state-history-chart-line";
|
||||||
import "./state-history-chart-timeline";
|
import "./state-history-chart-timeline";
|
||||||
import { restoreScroll } from "../../common/decorators/restore-scroll";
|
|
||||||
|
|
||||||
const CANVAS_TIMELINE_ROWS_CHUNK = 10; // Split up the canvases to avoid hitting the render limit
|
const CANVAS_TIMELINE_ROWS_CHUNK = 10; // Split up the canvases to avoid hitting the render limit
|
||||||
|
|
||||||
@@ -38,14 +38,14 @@ declare global {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@customElement("state-history-charts")
|
@customElement("state-history-charts")
|
||||||
class StateHistoryCharts extends LitElement {
|
export class StateHistoryCharts extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property({ attribute: false }) public historyData!: HistoryResult;
|
@property({ attribute: false }) public historyData!: HistoryResult;
|
||||||
|
|
||||||
@property() public narrow!: boolean;
|
@property() public narrow!: boolean;
|
||||||
|
|
||||||
@property({ type: Boolean }) public names = false;
|
@property() public names?: Record<string, string>;
|
||||||
|
|
||||||
@property({ type: Boolean, attribute: "virtualize", reflect: true })
|
@property({ type: Boolean, attribute: "virtualize", reflect: true })
|
||||||
public virtualize = false;
|
public virtualize = false;
|
||||||
@@ -71,8 +71,7 @@ class StateHistoryCharts extends LitElement {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@restoreScroll(".container") private _savedScrollPos?: number;
|
@restoreScroll(".container") private _savedScrollPos?: number;
|
||||||
|
|
||||||
@eventOptions({ passive: true })
|
protected render() {
|
||||||
protected render(): TemplateResult {
|
|
||||||
if (!isComponentLoaded(this.hass, "history")) {
|
if (!isComponentLoaded(this.hass, "history")) {
|
||||||
return html`<div class="info">
|
return html`<div class="info">
|
||||||
${this.hass.localize("ui.components.history_charts.history_disabled")}
|
${this.hass.localize("ui.components.history_charts.history_disabled")}
|
||||||
@@ -131,9 +130,9 @@ class StateHistoryCharts extends LitElement {
|
|||||||
private _renderHistoryItem = (
|
private _renderHistoryItem = (
|
||||||
item: TimelineEntity[] | LineChartUnit,
|
item: TimelineEntity[] | LineChartUnit,
|
||||||
index: number
|
index: number
|
||||||
): TemplateResult => {
|
) => {
|
||||||
if (!item || index === undefined) {
|
if (!item || index === undefined) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
if (!Array.isArray(item)) {
|
if (!Array.isArray(item)) {
|
||||||
return html`<div class="entry-container">
|
return html`<div class="entry-container">
|
||||||
|
@@ -59,14 +59,14 @@ export const statTypeMap: Record<ExtendedStatisticType, StatisticType> = {
|
|||||||
class StatisticsChart extends LitElement {
|
class StatisticsChart extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property({ attribute: false }) public statisticsData!: Statistics;
|
@property({ attribute: false }) public statisticsData?: Statistics;
|
||||||
|
|
||||||
@property({ attribute: false }) public metadata?: Record<
|
@property({ attribute: false }) public metadata?: Record<
|
||||||
string,
|
string,
|
||||||
StatisticsMetaData
|
StatisticsMetaData
|
||||||
>;
|
>;
|
||||||
|
|
||||||
@property() public names: boolean | Record<string, string> = false;
|
@property() public names?: Record<string, string>;
|
||||||
|
|
||||||
@property() public unit?: string;
|
@property() public unit?: string;
|
||||||
|
|
||||||
@@ -99,7 +99,11 @@ class StatisticsChart extends LitElement {
|
|||||||
if (!this.hasUpdated || changedProps.has("unit")) {
|
if (!this.hasUpdated || changedProps.has("unit")) {
|
||||||
this._createOptions();
|
this._createOptions();
|
||||||
}
|
}
|
||||||
if (changedProps.has("statisticsData") || changedProps.has("statTypes")) {
|
if (
|
||||||
|
changedProps.has("statisticsData") ||
|
||||||
|
changedProps.has("statTypes") ||
|
||||||
|
changedProps.has("hideLegend")
|
||||||
|
) {
|
||||||
this._generateData();
|
this._generateData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,7 +332,10 @@ class StatisticsChart extends LitElement {
|
|||||||
prevEndTime = end;
|
prevEndTime = end;
|
||||||
};
|
};
|
||||||
|
|
||||||
const color = getGraphColorByIndex(colorIndex, this._computedStyle!);
|
const color = getGraphColorByIndex(
|
||||||
|
colorIndex,
|
||||||
|
this._computedStyle || getComputedStyle(this)
|
||||||
|
);
|
||||||
colorIndex++;
|
colorIndex++;
|
||||||
|
|
||||||
const statTypes: this["statTypes"] = [];
|
const statTypes: this["statTypes"] = [];
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import "@lit-labs/virtualizer";
|
||||||
import { mdiArrowDown, mdiArrowUp } from "@mdi/js";
|
import { mdiArrowDown, mdiArrowUp } from "@mdi/js";
|
||||||
import deepClone from "deep-clone-simple";
|
import deepClone from "deep-clone-simple";
|
||||||
import {
|
import {
|
||||||
@@ -5,6 +6,7 @@ import {
|
|||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
|
nothing,
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
@@ -21,16 +23,15 @@ import { styleMap } from "lit/directives/style-map";
|
|||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { restoreScroll } from "../../common/decorators/restore-scroll";
|
import { restoreScroll } from "../../common/decorators/restore-scroll";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import "../search-input";
|
|
||||||
import { debounce } from "../../common/util/debounce";
|
import { debounce } from "../../common/util/debounce";
|
||||||
import { nextRender } from "../../common/util/render-status";
|
import { nextRender } from "../../common/util/render-status";
|
||||||
import { haStyleScrollbar } from "../../resources/styles";
|
import { haStyleScrollbar } from "../../resources/styles";
|
||||||
|
import { HomeAssistant } from "../../types";
|
||||||
import "../ha-checkbox";
|
import "../ha-checkbox";
|
||||||
import type { HaCheckbox } from "../ha-checkbox";
|
import type { HaCheckbox } from "../ha-checkbox";
|
||||||
import "../ha-svg-icon";
|
import "../ha-svg-icon";
|
||||||
|
import "../search-input";
|
||||||
import { filterData, sortData } from "./sort-filter";
|
import { filterData, sortData } from "./sort-filter";
|
||||||
import { HomeAssistant } from "../../types";
|
|
||||||
import "@lit-labs/virtualizer";
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
// for fire event
|
// for fire event
|
||||||
@@ -73,7 +74,7 @@ export interface DataTableColumnData<T = any> extends DataTableSortColumnData {
|
|||||||
title: TemplateResult | string;
|
title: TemplateResult | string;
|
||||||
label?: TemplateResult | string;
|
label?: TemplateResult | string;
|
||||||
type?: "numeric" | "icon" | "icon-button" | "overflow-menu";
|
type?: "numeric" | "icon" | "icon-button" | "overflow-menu";
|
||||||
template?: (data: any, row: T) => TemplateResult | string;
|
template?: (data: any, row: T) => TemplateResult | string | typeof nothing;
|
||||||
width?: string;
|
width?: string;
|
||||||
maxWidth?: string;
|
maxWidth?: string;
|
||||||
grows?: boolean;
|
grows?: boolean;
|
||||||
@@ -352,13 +353,10 @@ export class HaDataTable extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _renderRow = (
|
private _renderRow = (row: DataTableRowData, index: number) => {
|
||||||
row: DataTableRowData,
|
|
||||||
index: number
|
|
||||||
): TemplateResult => {
|
|
||||||
// not sure how this happens...
|
// not sure how this happens...
|
||||||
if (!row) {
|
if (!row) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
if (row.append) {
|
if (row.append) {
|
||||||
return html` <div class="mdc-data-table__row">${row.content}</div> `;
|
return html` <div class="mdc-data-table__row">${row.content}</div> `;
|
||||||
@@ -461,7 +459,9 @@ export class HaDataTable extends LitElement {
|
|||||||
const elapsed = curTime - startTime;
|
const elapsed = curTime - startTime;
|
||||||
|
|
||||||
if (elapsed < 100) {
|
if (elapsed < 100) {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100 - elapsed));
|
await new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, 100 - elapsed);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (this.curRequest !== curRequest) {
|
if (this.curRequest !== curRequest) {
|
||||||
return;
|
return;
|
||||||
|
@@ -67,11 +67,11 @@ const sortData = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure "undefined" is always sorted to the bottom
|
// Ensure "undefined" and "null" are always sorted to the bottom
|
||||||
if (valA === undefined && valB !== undefined) {
|
if (valA == null && valB != null) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (valB === undefined && valA !== undefined) {
|
if (valB == null && valA != null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import "@material/mwc-button/mwc-button";
|
import "@material/mwc-button/mwc-button";
|
||||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
|
||||||
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
|
||||||
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
|
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
|
||||||
|
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
|
import { html, LitElement, PropertyValues, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
@@ -230,9 +230,9 @@ export class HaAreaDevicesPicker extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this._devices || !this._areas || !this._entities) {
|
if (!this._devices || !this._areas || !this._entities) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
const areas = this._getAreasWithDevices(
|
const areas = this._getAreasWithDevices(
|
||||||
this._devices,
|
this._devices,
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import "@material/mwc-list/mwc-list-item";
|
import "@material/mwc-list/mwc-list-item";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { property, state } from "lit/decorators";
|
import { property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import {
|
import {
|
||||||
@@ -85,9 +85,9 @@ export abstract class HaDeviceAutomationPicker<
|
|||||||
return `${this._automations[idx].device_id}_${idx}`;
|
return `${this._automations[idx].device_id}_${idx}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (this._renderEmpty) {
|
if (this._renderEmpty) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
const value = this._value;
|
const value = this._value;
|
||||||
return html`
|
return html`
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import "@material/mwc-list/mwc-list-item";
|
import "@material/mwc-list/mwc-list-item";
|
||||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
import { HassEntity, UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||||
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
|
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
@@ -37,6 +37,8 @@ export type HaDevicePickerDeviceFilterFunc = (
|
|||||||
device: DeviceRegistryEntry
|
device: DeviceRegistryEntry
|
||||||
) => boolean;
|
) => boolean;
|
||||||
|
|
||||||
|
export type HaDevicePickerEntityFilterFunc = (entity: HassEntity) => boolean;
|
||||||
|
|
||||||
const rowRenderer: ComboBoxLitRenderer<Device> = (item) => html`<mwc-list-item
|
const rowRenderer: ComboBoxLitRenderer<Device> = (item) => html`<mwc-list-item
|
||||||
.twoline=${!!item.area}
|
.twoline=${!!item.area}
|
||||||
>
|
>
|
||||||
@@ -94,6 +96,8 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
@property() public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
@property() public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||||
|
|
||||||
|
@property() public entityFilter?: HaDevicePickerEntityFilterFunc;
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled?: boolean;
|
@property({ type: Boolean }) public disabled?: boolean;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required?: boolean;
|
@property({ type: Boolean }) public required?: boolean;
|
||||||
@@ -113,6 +117,7 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
excludeDomains: this["excludeDomains"],
|
excludeDomains: this["excludeDomains"],
|
||||||
includeDeviceClasses: this["includeDeviceClasses"],
|
includeDeviceClasses: this["includeDeviceClasses"],
|
||||||
deviceFilter: this["deviceFilter"],
|
deviceFilter: this["deviceFilter"],
|
||||||
|
entityFilter: this["entityFilter"],
|
||||||
excludeDevices: this["excludeDevices"]
|
excludeDevices: this["excludeDevices"]
|
||||||
): Device[] => {
|
): Device[] => {
|
||||||
if (!devices.length) {
|
if (!devices.length) {
|
||||||
@@ -127,7 +132,12 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
const deviceEntityLookup: DeviceEntityLookup = {};
|
const deviceEntityLookup: DeviceEntityLookup = {};
|
||||||
|
|
||||||
if (includeDomains || excludeDomains || includeDeviceClasses) {
|
if (
|
||||||
|
includeDomains ||
|
||||||
|
excludeDomains ||
|
||||||
|
includeDeviceClasses ||
|
||||||
|
entityFilter
|
||||||
|
) {
|
||||||
for (const entity of entities) {
|
for (const entity of entities) {
|
||||||
if (!entity.device_id) {
|
if (!entity.device_id) {
|
||||||
continue;
|
continue;
|
||||||
@@ -198,6 +208,22 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entityFilter) {
|
||||||
|
inputDevices = inputDevices.filter((device) => {
|
||||||
|
const devEntities = deviceEntityLookup[device.id];
|
||||||
|
if (!devEntities || !devEntities.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return devEntities.some((entity) => {
|
||||||
|
const stateObj = this.hass.states[entity.entity_id];
|
||||||
|
if (!stateObj) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return entityFilter(stateObj);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (deviceFilter) {
|
if (deviceFilter) {
|
||||||
inputDevices = inputDevices.filter(
|
inputDevices = inputDevices.filter(
|
||||||
(device) =>
|
(device) =>
|
||||||
@@ -274,6 +300,7 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
this.excludeDomains,
|
this.excludeDomains,
|
||||||
this.includeDeviceClasses,
|
this.includeDeviceClasses,
|
||||||
this.deviceFilter,
|
this.deviceFilter,
|
||||||
|
this.entityFilter,
|
||||||
this.excludeDevices
|
this.excludeDevices
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
import { css, html, LitElement, TemplateResult } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { PolymerChangedEvent } from "../../polymer-types";
|
import { PolymerChangedEvent } from "../../polymer-types";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import "./ha-device-picker";
|
import "./ha-device-picker";
|
||||||
import type { HaDevicePickerDeviceFilterFunc } from "./ha-device-picker";
|
import type {
|
||||||
|
HaDevicePickerDeviceFilterFunc,
|
||||||
|
HaDevicePickerEntityFilterFunc,
|
||||||
|
} from "./ha-device-picker";
|
||||||
|
|
||||||
@customElement("ha-devices-picker")
|
@customElement("ha-devices-picker")
|
||||||
class HaDevicesPicker extends LitElement {
|
class HaDevicesPicker extends LitElement {
|
||||||
@@ -44,9 +47,11 @@ class HaDevicesPicker extends LitElement {
|
|||||||
|
|
||||||
@property() public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
@property() public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
@property() public entityFilter?: HaDevicePickerEntityFilterFunc;
|
||||||
|
|
||||||
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentDevices = this._currentDevices;
|
const currentDevices = this._currentDevices;
|
||||||
@@ -59,6 +64,7 @@ class HaDevicesPicker extends LitElement {
|
|||||||
.curValue=${entityId}
|
.curValue=${entityId}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.deviceFilter=${this.deviceFilter}
|
.deviceFilter=${this.deviceFilter}
|
||||||
|
.entityFilter=${this.entityFilter}
|
||||||
.includeDomains=${this.includeDomains}
|
.includeDomains=${this.includeDomains}
|
||||||
.excludeDomains=${this.excludeDomains}
|
.excludeDomains=${this.excludeDomains}
|
||||||
.includeDeviceClasses=${this.includeDeviceClasses}
|
.includeDeviceClasses=${this.includeDeviceClasses}
|
||||||
@@ -76,8 +82,10 @@ class HaDevicesPicker extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.helper=${this.helper}
|
.helper=${this.helper}
|
||||||
.deviceFilter=${this.deviceFilter}
|
.deviceFilter=${this.deviceFilter}
|
||||||
|
.entityFilter=${this.entityFilter}
|
||||||
.includeDomains=${this.includeDomains}
|
.includeDomains=${this.includeDomains}
|
||||||
.excludeDomains=${this.excludeDomains}
|
.excludeDomains=${this.excludeDomains}
|
||||||
|
.excludeDevices=${currentDevices}
|
||||||
.includeDeviceClasses=${this.includeDeviceClasses}
|
.includeDeviceClasses=${this.includeDeviceClasses}
|
||||||
.label=${this.pickDeviceLabel}
|
.label=${this.pickDeviceLabel}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import type { HassEntity } from "home-assistant-js-websocket";
|
import type { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { css, html, LitElement, TemplateResult } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
@@ -76,9 +76,9 @@ class HaEntitiesPickerLight extends LitElement {
|
|||||||
|
|
||||||
@property() public entityFilter?: HaEntityPickerEntityFilterFunc;
|
@property() public entityFilter?: HaEntityPickerEntityFilterFunc;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentEntities = this._currentEntities;
|
const currentEntities = this._currentEntities;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
import { html, LitElement, PropertyValues, nothing } from "lit";
|
||||||
import { customElement, property, query } from "lit/decorators";
|
import { customElement, property, query } from "lit/decorators";
|
||||||
import { formatAttributeName } from "../../data/entity_attributes";
|
import { formatAttributeName } from "../../data/entity_attributes";
|
||||||
import { PolymerChangedEvent } from "../../polymer-types";
|
import { PolymerChangedEvent } from "../../polymer-types";
|
||||||
@@ -60,9 +60,9 @@ class HaEntityAttributePicker extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import "@material/mwc-list/mwc-list-item";
|
import "../ha-list-item";
|
||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||||
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
|
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
|
||||||
@@ -24,13 +24,13 @@ export type HaEntityPickerEntityFilterFunc = (entity: HassEntity) => boolean;
|
|||||||
|
|
||||||
// eslint-disable-next-line lit/prefer-static-styles
|
// eslint-disable-next-line lit/prefer-static-styles
|
||||||
const rowRenderer: ComboBoxLitRenderer<HassEntityWithCachedName> = (item) =>
|
const rowRenderer: ComboBoxLitRenderer<HassEntityWithCachedName> = (item) =>
|
||||||
html`<mwc-list-item graphic="avatar" .twoline=${!!item.entity_id}>
|
html`<ha-list-item graphic="avatar" .twoline=${!!item.entity_id}>
|
||||||
${item.state
|
${item.state
|
||||||
? html`<state-badge slot="graphic" .stateObj=${item}></state-badge>`
|
? html`<state-badge slot="graphic" .stateObj=${item}></state-badge>`
|
||||||
: ""}
|
: ""}
|
||||||
<span>${item.friendly_name}</span>
|
<span>${item.friendly_name}</span>
|
||||||
<span slot="secondary">${item.entity_id}</span>
|
<span slot="secondary">${item.entity_id}</span>
|
||||||
</mwc-list-item>`;
|
</ha-list-item>`;
|
||||||
|
|
||||||
@customElement("ha-entity-picker")
|
@customElement("ha-entity-picker")
|
||||||
export class HaEntityPicker extends LitElement {
|
export class HaEntityPicker extends LitElement {
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
import { html, LitElement, PropertyValues, nothing } from "lit";
|
||||||
import { customElement, property, query } from "lit/decorators";
|
import { customElement, property, query } from "lit/decorators";
|
||||||
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { computeStateDisplay } from "../../common/entity/compute_state_display";
|
import { computeStateDisplay } from "../../common/entity/compute_state_display";
|
||||||
import { PolymerChangedEvent } from "../../polymer-types";
|
|
||||||
import { getStates } from "../../common/entity/get_states";
|
import { getStates } from "../../common/entity/get_states";
|
||||||
|
import { formatAttributeValue } from "../../data/entity_attributes";
|
||||||
|
import { PolymerChangedEvent } from "../../polymer-types";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import "../ha-combo-box";
|
import "../ha-combo-box";
|
||||||
import type { HaComboBox } from "../ha-combo-box";
|
import type { HaComboBox } from "../ha-combo-box";
|
||||||
import { formatAttributeValue } from "../../data/entity_attributes";
|
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
|
||||||
|
|
||||||
export type HaEntityPickerEntityFilterFunc = (entityId: HassEntity) => boolean;
|
export type HaEntityPickerEntityFilterFunc = (entityId: HassEntity) => boolean;
|
||||||
|
|
||||||
@@ -64,9 +64,9 @@ class HaEntityStatePicker extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
@@ -22,7 +22,7 @@ import {
|
|||||||
isNumericState,
|
isNumericState,
|
||||||
} from "../../common/number/format_number";
|
} from "../../common/number/format_number";
|
||||||
import { isUnavailableState, UNAVAILABLE, UNKNOWN } from "../../data/entity";
|
import { isUnavailableState, UNAVAILABLE, UNKNOWN } from "../../data/entity";
|
||||||
import { EntityRegistryEntry } from "../../data/entity_registry";
|
import { EntityRegistryDisplayEntry } from "../../data/entity_registry";
|
||||||
import { timerTimeRemaining } from "../../data/timer";
|
import { timerTimeRemaining } from "../../data/timer";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import "../ha-label-badge";
|
import "../ha-label-badge";
|
||||||
@@ -160,7 +160,7 @@ export class HaStateLabelBadge extends LitElement {
|
|||||||
private _computeValue(
|
private _computeValue(
|
||||||
domain: string,
|
domain: string,
|
||||||
entityState: HassEntity,
|
entityState: HassEntity,
|
||||||
entry?: EntityRegistryEntry
|
entry?: EntityRegistryDisplayEntry
|
||||||
) {
|
) {
|
||||||
switch (domain) {
|
switch (domain) {
|
||||||
case "alarm_control_panel":
|
case "alarm_control_panel":
|
||||||
@@ -186,7 +186,7 @@ export class HaStateLabelBadge extends LitElement {
|
|||||||
? formatNumber(
|
? formatNumber(
|
||||||
entityState.state,
|
entityState.state,
|
||||||
this.hass!.locale,
|
this.hass!.locale,
|
||||||
getNumberFormatOptions(entityState)
|
getNumberFormatOptions(entityState, entry)
|
||||||
)
|
)
|
||||||
: computeStateDisplay(
|
: computeStateDisplay(
|
||||||
this.hass!.localize,
|
this.hass!.localize,
|
||||||
@@ -200,7 +200,7 @@ export class HaStateLabelBadge extends LitElement {
|
|||||||
private _computeShowIcon(
|
private _computeShowIcon(
|
||||||
domain: string,
|
domain: string,
|
||||||
entityState: HassEntity,
|
entityState: HassEntity,
|
||||||
entry?: EntityRegistryEntry
|
entry?: EntityRegistryDisplayEntry
|
||||||
): boolean {
|
): boolean {
|
||||||
if (entityState.state === UNAVAILABLE) {
|
if (entityState.state === UNAVAILABLE) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import type { PolymerChangedEvent } from "../../polymer-types";
|
import type { PolymerChangedEvent } from "../../polymer-types";
|
||||||
@@ -56,9 +56,9 @@ class HaStatisticsPicker extends LitElement {
|
|||||||
})
|
})
|
||||||
public ignoreRestrictionsOnFirstStatistic = false;
|
public ignoreRestrictionsOnFirstStatistic = false;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ignoreRestriction =
|
const ignoreRestriction =
|
||||||
|
@@ -6,7 +6,7 @@ import {
|
|||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
TemplateResult,
|
nothing,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { property, state } from "lit/decorators";
|
import { property, state } from "lit/decorators";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
@@ -45,7 +45,7 @@ export class StateBadge extends LitElement {
|
|||||||
return this.stateColor || (domain === "light" && this.stateColor !== false);
|
return this.stateColor || (domain === "light" && this.stateColor !== false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
const stateObj = this.stateObj;
|
const stateObj = this.stateObj;
|
||||||
|
|
||||||
// We either need a `stateObj` or one override
|
// We either need a `stateObj` or one override
|
||||||
@@ -56,7 +56,7 @@ export class StateBadge extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this._showIcon) {
|
if (!this._showIcon) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const domain = stateObj ? computeStateDomain(stateObj) : undefined;
|
const domain = stateObj ? computeStateDomain(stateObj) : undefined;
|
||||||
@@ -133,7 +133,7 @@ export class StateBadge extends LitElement {
|
|||||||
}
|
}
|
||||||
if (stateObj.attributes.hvac_action) {
|
if (stateObj.attributes.hvac_action) {
|
||||||
const hvacAction = stateObj.attributes.hvac_action;
|
const hvacAction = stateObj.attributes.hvac_action;
|
||||||
if (["heating", "cooling", "drying", "fan"].includes(hvacAction)) {
|
if (hvacAction in HVAC_ACTION_TO_MODE) {
|
||||||
iconStyle.color = stateColorCss(
|
iconStyle.color = stateColorCss(
|
||||||
stateObj,
|
stateObj,
|
||||||
HVAC_ACTION_TO_MODE[hvacAction]
|
HVAC_ACTION_TO_MODE[hvacAction]
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import "@polymer/paper-tooltip/paper-tooltip";
|
import "@polymer/paper-tooltip/paper-tooltip";
|
||||||
import type { HassEntity } from "home-assistant-js-websocket";
|
import type { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||||
import { computeRTL } from "../../common/util/compute_rtl";
|
import { computeRTL } from "../../common/util/compute_rtl";
|
||||||
@@ -21,9 +21,9 @@ class StateInfo extends LitElement {
|
|||||||
|
|
||||||
@property() public color?: string;
|
@property() public color?: string;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render() {
|
||||||
if (!this.hass || !this.stateObj) {
|
if (!this.hass || !this.stateObj) {
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = computeStateName(this.stateObj);
|
const name = computeStateName(this.stateObj);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user