mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-23 08:09:27 +00:00
Compare commits
234 Commits
20221213.1
...
restructur
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d60639f99d | ||
![]() |
693b621dd5 | ||
![]() |
d96bb9cf20 | ||
![]() |
ec2d498334 | ||
![]() |
c9b1b92e70 | ||
![]() |
a4a2e1b99e | ||
![]() |
b31af60397 | ||
![]() |
01facc2254 | ||
![]() |
8b4587785c | ||
![]() |
89623aa7ec | ||
![]() |
afb9e826ef | ||
![]() |
ac075e44cc | ||
![]() |
fcf6bfc457 | ||
![]() |
3951646c7f | ||
![]() |
be6aabe23e | ||
![]() |
25f7a0602a | ||
![]() |
34ed446cd2 | ||
![]() |
ffd7a0c153 | ||
![]() |
b591c75377 | ||
![]() |
d2886b1ea7 | ||
![]() |
a3ba8210cf | ||
![]() |
d1a04349a4 | ||
![]() |
bb273b2b54 | ||
![]() |
00667f1296 | ||
![]() |
06368a6f0e | ||
![]() |
7c4a421e74 | ||
![]() |
3675a2b013 | ||
![]() |
0bbe6151ed | ||
![]() |
dace00ebf8 | ||
![]() |
a433ac48e9 | ||
![]() |
ddfaa67456 | ||
![]() |
8b4b19cc96 | ||
![]() |
c4183a9edb | ||
![]() |
363ad369fc | ||
![]() |
711286f7c0 | ||
![]() |
78857357f3 | ||
![]() |
3c23e6a1c3 | ||
![]() |
10369ff952 | ||
![]() |
134670604b | ||
![]() |
8935dbac20 | ||
![]() |
ccf15c7fb0 | ||
![]() |
5e4b673751 | ||
![]() |
98e799eda0 | ||
![]() |
5e9ae36577 | ||
![]() |
624bfbbaf1 | ||
![]() |
0e71eec937 | ||
![]() |
38562a42d6 | ||
![]() |
e242fbe148 | ||
![]() |
81e4f083f9 | ||
![]() |
533b4ec0b4 | ||
![]() |
50a4c0f7ce | ||
![]() |
dfee6c9b5b | ||
![]() |
fe2b4d9598 | ||
![]() |
e6dbb1da7e | ||
![]() |
095ebbc903 | ||
![]() |
9dcdf46316 | ||
![]() |
d6e0d57744 | ||
![]() |
38c1112308 | ||
![]() |
88ee409987 | ||
![]() |
8073555bf9 | ||
![]() |
b4cd4975c1 | ||
![]() |
518d4f9c5b | ||
![]() |
f991a1b819 | ||
![]() |
6fc5fd9cc4 | ||
![]() |
d15d339782 | ||
![]() |
1b922e0065 | ||
![]() |
c8883a6a8a | ||
![]() |
e14e27c01a | ||
![]() |
f101bd1a54 | ||
![]() |
3e14d825e3 | ||
![]() |
f34d9c3d75 | ||
![]() |
2b2dd74672 | ||
![]() |
815d4c165d | ||
![]() |
fd22afedd0 | ||
![]() |
522c7c08a9 | ||
![]() |
dc140f132d | ||
![]() |
4c76a2549b | ||
![]() |
a5c77928d2 | ||
![]() |
d3e20429a4 | ||
![]() |
2f1d783d22 | ||
![]() |
558f523207 | ||
![]() |
c7f4693f0a | ||
![]() |
282823ee83 | ||
![]() |
014ae06e85 | ||
![]() |
9e5442db18 | ||
![]() |
789a69fea5 | ||
![]() |
c7da1a95da | ||
![]() |
6d527d5ebe | ||
![]() |
9d529d8f13 | ||
![]() |
468aeda74a | ||
![]() |
f6a508683c | ||
![]() |
64fabbbf05 | ||
![]() |
9b95814f1b | ||
![]() |
2f2cde328c | ||
![]() |
8294e0e271 | ||
![]() |
f09859ab40 | ||
![]() |
e206e86fb3 | ||
![]() |
21f3eb9103 | ||
![]() |
932614e31a | ||
![]() |
1d20d6979e | ||
![]() |
207380d0da | ||
![]() |
d2c091536e | ||
![]() |
2eb5335a68 | ||
![]() |
1aa23d75b0 | ||
![]() |
663b6e0682 | ||
![]() |
c7f3293c1d | ||
![]() |
c63b64cff5 | ||
![]() |
7136142437 | ||
![]() |
af9a8fa3e7 | ||
![]() |
b74a2fd277 | ||
![]() |
e5350a4246 | ||
![]() |
9e5a59fbc4 | ||
![]() |
24e6b8483e | ||
![]() |
604c452ff4 | ||
![]() |
ba9551b61e | ||
![]() |
135af5bcaa | ||
![]() |
747f47524e | ||
![]() |
36b959dbc4 | ||
![]() |
1d15f81b6c | ||
![]() |
45e7f8ae06 | ||
![]() |
dcedafaef4 | ||
![]() |
8fac5f6d75 | ||
![]() |
5094e8f428 | ||
![]() |
74fb8b0427 | ||
![]() |
78768b1e2f | ||
![]() |
d55307098a | ||
![]() |
7286aa7dc4 | ||
![]() |
b44b22c723 | ||
![]() |
dcee89caeb | ||
![]() |
d1caeed05e | ||
![]() |
f2a67a5fa9 | ||
![]() |
b2d5304488 | ||
![]() |
e9aded77da | ||
![]() |
e1a94c679f | ||
![]() |
616bced37c | ||
![]() |
1585c6bf52 | ||
![]() |
caa852559f | ||
![]() |
f2fa433326 | ||
![]() |
dd109b0054 | ||
![]() |
9750e0e0b5 | ||
![]() |
b36eba0916 | ||
![]() |
18a69d633f | ||
![]() |
bf6ad3d0a5 | ||
![]() |
9836912efa | ||
![]() |
f31a7c3af0 | ||
![]() |
ebb19e4ed5 | ||
![]() |
44d91eaa4f | ||
![]() |
3cc1cb7893 | ||
![]() |
e7354ed5a2 | ||
![]() |
e3ac2c149d | ||
![]() |
afcd45a780 | ||
![]() |
fe87466351 | ||
![]() |
bdef924426 | ||
![]() |
86ea3082f7 | ||
![]() |
0374330676 | ||
![]() |
7cde3b66dd | ||
![]() |
d8a68326fb | ||
![]() |
4901d50918 | ||
![]() |
a16e41a7ac | ||
![]() |
f1d644ac51 | ||
![]() |
a9378abe31 | ||
![]() |
5c2fcd7f9b | ||
![]() |
2b8f7c46ff | ||
![]() |
0015559e24 | ||
![]() |
2fbe6809c1 | ||
![]() |
e926091e54 | ||
![]() |
1198f983aa | ||
![]() |
6a15216104 | ||
![]() |
b99a139f51 | ||
![]() |
0e9a013549 | ||
![]() |
1d1ff410b2 | ||
![]() |
d4d3a1cb65 | ||
![]() |
81e3652446 | ||
![]() |
adb61ab99b | ||
![]() |
1c139d0bc7 | ||
![]() |
419f23879a | ||
![]() |
e175c7ba3c | ||
![]() |
2575d35f2c | ||
![]() |
5eb45209e8 | ||
![]() |
0e70b866ae | ||
![]() |
c6aa2886ed | ||
![]() |
77e01812d1 | ||
![]() |
a5863a9a67 | ||
![]() |
526c34993c | ||
![]() |
3199319830 | ||
![]() |
6bb350b5ec | ||
![]() |
f41330a29b | ||
![]() |
7780ae8f76 | ||
![]() |
40cf15c1f3 | ||
![]() |
9be6a47d88 | ||
![]() |
5933c2eb8e | ||
![]() |
a8b7937d75 | ||
![]() |
4919341871 | ||
![]() |
36e99c3c0f | ||
![]() |
825008e24a | ||
![]() |
ae04a5457e | ||
![]() |
a7c3774c29 | ||
![]() |
9c24dbe333 | ||
![]() |
50f089fd4f | ||
![]() |
019ef4ba8f | ||
![]() |
b31a9d590e | ||
![]() |
b18160d987 | ||
![]() |
5b17c59a56 | ||
![]() |
139cbb363c | ||
![]() |
e8e4733fc9 | ||
![]() |
b4d6fc3c20 | ||
![]() |
25a5bd568a | ||
![]() |
77b8152c55 | ||
![]() |
ebcbfda92d | ||
![]() |
01a4b55ed8 | ||
![]() |
311d11f2da | ||
![]() |
c400e771cb | ||
![]() |
7611a99f55 | ||
![]() |
1044b3c399 | ||
![]() |
239d3ca00c | ||
![]() |
00c2cb731b | ||
![]() |
ef7d839c0f | ||
![]() |
66a22ae102 | ||
![]() |
d48853fcdd | ||
![]() |
175a388822 | ||
![]() |
872395bec5 | ||
![]() |
5faf7cf0af | ||
![]() |
e768c78dce | ||
![]() |
50cc8594be | ||
![]() |
363092ff03 | ||
![]() |
1bce5efc9e | ||
![]() |
14513e5905 | ||
![]() |
b168f8d027 | ||
![]() |
e151520d74 | ||
![]() |
02b763e8f3 | ||
![]() |
498102ddd9 | ||
![]() |
6aba5c1017 | ||
![]() |
2176d4dcea | ||
![]() |
9fdef3df6d |
@@ -1,13 +1,20 @@
|
|||||||
{
|
{
|
||||||
"name": "Home Assistant Frontend",
|
"name": "Home Assistant Frontend",
|
||||||
"build": {
|
"image": "mcr.microsoft.com/devcontainers/python:0-3.10",
|
||||||
"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": {
|
@@ -1,13 +0,0 @@
|
|||||||
# 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.9
|
|
||||||
|
|
||||||
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"
|
|
10
.github/dependabot.yml
vendored
10
.github/dependabot.yml
vendored
@@ -6,3 +6,13 @@ updates:
|
|||||||
interval: weekly
|
interval: weekly
|
||||||
time: "06:00"
|
time: "06:00"
|
||||||
open-pull-requests-limit: 10
|
open-pull-requests-limit: 10
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
time: "06:00"
|
||||||
|
open-pull-requests-limit: 5
|
||||||
|
ignore:
|
||||||
|
# Ignore rollup and plugins until everything else is updated
|
||||||
|
- dependency-name: "*rollup*"
|
||||||
|
- dependency-name: "@rollup/*"
|
||||||
|
8
.github/workflows/cast_deployment.yaml
vendored
8
.github/workflows/cast_deployment.yaml
vendored
@@ -22,12 +22,12 @@ jobs:
|
|||||||
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
with:
|
with:
|
||||||
ref: dev
|
ref: dev
|
||||||
|
|
||||||
- name: Set up Node ${{ env.NODE_VERSION }}
|
- name: Set up Node ${{ env.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3.6.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
@@ -60,12 +60,12 @@ jobs:
|
|||||||
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
with:
|
with:
|
||||||
ref: master
|
ref: master
|
||||||
|
|
||||||
- name: Set up Node ${{ env.NODE_VERSION }}
|
- name: Set up Node ${{ env.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3.6.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
|
16
.github/workflows/ci.yaml
vendored
16
.github/workflows/ci.yaml
vendored
@@ -20,9 +20,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
- name: Set up Node ${{ env.NODE_VERSION }}
|
- name: Set up Node ${{ env.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3.6.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
@@ -44,9 +44,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
- name: Set up Node ${{ env.NODE_VERSION }}
|
- name: Set up Node ${{ env.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3.6.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
@@ -63,9 +63,9 @@ jobs:
|
|||||||
needs: [lint, test]
|
needs: [lint, test]
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
- name: Set up Node ${{ env.NODE_VERSION }}
|
- name: Set up Node ${{ env.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3.6.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
@@ -82,9 +82,9 @@ jobs:
|
|||||||
needs: [lint, test]
|
needs: [lint, test]
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
- name: Set up Node ${{ env.NODE_VERSION }}
|
- name: Set up Node ${{ env.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3.6.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
|
2
.github/workflows/codeql-analysis.yml
vendored
2
.github/workflows/codeql-analysis.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
with:
|
with:
|
||||||
# We must fetch at least the immediate parents so that if this is
|
# We must fetch at least the immediate parents so that if this is
|
||||||
# a pull request then we can checkout the head.
|
# a pull request then we can checkout the head.
|
||||||
|
51
.github/workflows/demo_deployment.yaml
vendored
51
.github/workflows/demo_deployment.yaml
vendored
@@ -7,23 +7,28 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- dev
|
- dev
|
||||||
|
- master
|
||||||
|
|
||||||
env:
|
env:
|
||||||
NODE_VERSION: 16
|
NODE_VERSION: 16
|
||||||
NODE_OPTIONS: --max_old_space_size=6144
|
NODE_OPTIONS: --max_old_space_size=6144
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy_dev:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
name: Demo Development
|
||||||
|
if: github.event_name != 'push' || github.ref != 'master'
|
||||||
environment:
|
environment:
|
||||||
name: Demo
|
name: Demo Development
|
||||||
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
|
with:
|
||||||
|
ref: dev
|
||||||
|
|
||||||
- name: Set up Node ${{ env.NODE_VERSION }}
|
- name: Set up Node ${{ env.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3.6.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
@@ -46,3 +51,41 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEMO_DEV_SITE_ID }}
|
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEMO_DEV_SITE_ID }}
|
||||||
|
|
||||||
|
deploy_master:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Demo Production
|
||||||
|
if: github.event_name == 'push' && github.ref == 'master'
|
||||||
|
environment:
|
||||||
|
name: Demo Production
|
||||||
|
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
||||||
|
steps:
|
||||||
|
- name: Check out files from GitHub
|
||||||
|
uses: actions/checkout@v3.3.0
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
|
||||||
|
- name: Set up Node ${{ env.NODE_VERSION }}
|
||||||
|
uses: actions/setup-node@v3.6.0
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
cache: yarn
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: yarn install
|
||||||
|
env:
|
||||||
|
CI: true
|
||||||
|
|
||||||
|
- name: Build Demo
|
||||||
|
run: ./node_modules/.bin/gulp build-demo
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Deploy to Netlify
|
||||||
|
id: deploy
|
||||||
|
uses: netlify/actions/cli@master
|
||||||
|
with:
|
||||||
|
args: deploy --dir=demo/dist --prod
|
||||||
|
env:
|
||||||
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||||
|
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEMO_SITE_ID }}
|
4
.github/workflows/design_deployment.yaml
vendored
4
.github/workflows/design_deployment.yaml
vendored
@@ -17,10 +17,10 @@ jobs:
|
|||||||
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
|
|
||||||
- name: Set up Node ${{ env.NODE_VERSION }}
|
- name: Set up Node ${{ env.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3.6.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
|
4
.github/workflows/design_preview.yaml
vendored
4
.github/workflows/design_preview.yaml
vendored
@@ -22,10 +22,10 @@ jobs:
|
|||||||
if: github.repository == 'home-assistant/frontend' && contains(github.event.pull_request.labels.*.name, 'needs design preview')
|
if: github.repository == 'home-assistant/frontend' && contains(github.event.pull_request.labels.*.name, 'needs design preview')
|
||||||
steps:
|
steps:
|
||||||
- name: Check out files from GitHub
|
- name: Check out files from GitHub
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
|
|
||||||
- name: Set up Node ${{ env.NODE_VERSION }}
|
- name: Set up Node ${{ env.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3.6.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
|
4
.github/workflows/nightly.yaml
vendored
4
.github/workflows/nightly.yaml
vendored
@@ -21,7 +21,7 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout the repository
|
- name: Checkout the repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
|
|
||||||
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
@@ -29,7 +29,7 @@ jobs:
|
|||||||
python-version: ${{ env.PYTHON_VERSION }}
|
python-version: ${{ env.PYTHON_VERSION }}
|
||||||
|
|
||||||
- name: Set up Node ${{ env.NODE_VERSION }}
|
- name: Set up Node ${{ env.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3.6.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
|
4
.github/workflows/release.yaml
vendored
4
.github/workflows/release.yaml
vendored
@@ -24,7 +24,7 @@ jobs:
|
|||||||
contents: write # Required to upload release assets
|
contents: write # Required to upload release assets
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout the repository
|
- name: Checkout the repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
|
|
||||||
- name: Verify version
|
- name: Verify version
|
||||||
uses: home-assistant/actions/helpers/verify-version@master
|
uses: home-assistant/actions/helpers/verify-version@master
|
||||||
@@ -35,7 +35,7 @@ jobs:
|
|||||||
python-version: ${{ env.PYTHON_VERSION }}
|
python-version: ${{ env.PYTHON_VERSION }}
|
||||||
|
|
||||||
- name: Set up Node ${{ env.NODE_VERSION }}
|
- name: Set up Node ${{ env.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3.6.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache: yarn
|
cache: yarn
|
||||||
|
2
.github/workflows/stale.yml
vendored
2
.github/workflows/stale.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: 90 days stale policy
|
- name: 90 days stale policy
|
||||||
uses: actions/stale@v6.0.1
|
uses: actions/stale@v7.0.0
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
days-before-stale: 90
|
days-before-stale: 90
|
||||||
|
2
.github/workflows/translations.yaml
vendored
2
.github/workflows/translations.yaml
vendored
@@ -16,7 +16,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout the repository
|
- name: Checkout the repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3.3.0
|
||||||
|
|
||||||
- name: Upload Translations
|
- name: Upload Translations
|
||||||
run: |
|
run: |
|
||||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@@ -8,7 +8,7 @@ dist/
|
|||||||
/translations/
|
/translations/
|
||||||
|
|
||||||
# yarn
|
# yarn
|
||||||
.yarn/**
|
.yarn/*
|
||||||
!.yarn/patches
|
!.yarn/patches
|
||||||
!.yarn/releases
|
!.yarn/releases
|
||||||
!.yarn/plugins
|
!.yarn/plugins
|
||||||
@@ -31,7 +31,7 @@ pip-selfcheck.json
|
|||||||
.venv
|
.venv
|
||||||
|
|
||||||
# vscode
|
# vscode
|
||||||
.vscode/**
|
.vscode/*
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
!.vscode/launch.json
|
!.vscode/launch.json
|
||||||
!.vscode/tasks.json
|
!.vscode/tasks.json
|
||||||
|
@@ -1,29 +0,0 @@
|
|||||||
diff --git a/polyfillLoaders/EventTarget.js b/polyfillLoaders/EventTarget.js
|
|
||||||
index 4e18ade7ba485849f17f28c94c42f0e0e01ac387..8f34f4f646c7f7becc208fb5a546c96034fc74dc 100644
|
|
||||||
--- a/polyfillLoaders/EventTarget.js
|
|
||||||
+++ b/polyfillLoaders/EventTarget.js
|
|
||||||
@@ -6,16 +6,15 @@
|
|
||||||
let _ET;
|
|
||||||
let ET;
|
|
||||||
export default async function EventTarget() {
|
|
||||||
- return ET || init();
|
|
||||||
+ return ET || init();
|
|
||||||
}
|
|
||||||
async function init() {
|
|
||||||
- _ET = window.EventTarget;
|
|
||||||
- try {
|
|
||||||
- new _ET();
|
|
||||||
- }
|
|
||||||
- catch (_a) {
|
|
||||||
- _ET = (await import('event-target-shim')).EventTarget;
|
|
||||||
- }
|
|
||||||
- return (ET = _ET);
|
|
||||||
+ _ET = window.EventTarget;
|
|
||||||
+ try {
|
|
||||||
+ new _ET();
|
|
||||||
+ } catch (_a) {
|
|
||||||
+ _ET = (await import("event-target-shim")).default.EventTarget;
|
|
||||||
+ }
|
|
||||||
+ return (ET = _ET);
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=EventTarget.js.map
|
|
@@ -1,12 +0,0 @@
|
|||||||
diff --git a/mwc-icon-button-base.js b/mwc-icon-button-base.js
|
|
||||||
index 45cdaab93ccc0a6daaaaabc01266dcdc32e46bfd..b3ea5b541597308d85f86ce6c23fd00785fda835 100644
|
|
||||||
--- a/mwc-icon-button-base.js
|
|
||||||
+++ b/mwc-icon-button-base.js
|
|
||||||
@@ -63,7 +63,6 @@ export class IconButtonBase extends LitElement {
|
|
||||||
@touchend="${this.handleRippleDeactivate}"
|
|
||||||
@touchcancel="${this.handleRippleDeactivate}"
|
|
||||||
>${this.renderRipple()}
|
|
||||||
- <i class="material-icons">${this.icon}</i>
|
|
||||||
<span
|
|
||||||
><slot></slot
|
|
||||||
></span>
|
|
566
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
566
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
File diff suppressed because one or more lines are too long
5
.yarn/plugins/@yarnpkg/plugin-typescript.cjs
vendored
5
.yarn/plugins/@yarnpkg/plugin-typescript.cjs
vendored
File diff suppressed because one or more lines are too long
783
.yarn/releases/yarn-3.2.3.cjs
vendored
783
.yarn/releases/yarn-3.2.3.cjs
vendored
File diff suppressed because one or more lines are too long
823
.yarn/releases/yarn-3.3.1.cjs
vendored
Executable file
823
.yarn/releases/yarn-3.3.1.cjs
vendored
Executable file
File diff suppressed because one or more lines are too long
@@ -6,4 +6,4 @@ plugins:
|
|||||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||||
spec: "@yarnpkg/plugin-interactive-tools"
|
spec: "@yarnpkg/plugin-interactive-tools"
|
||||||
|
|
||||||
yarnPath: .yarn/releases/yarn-3.2.3.cjs
|
yarnPath: .yarn/releases/yarn-3.3.1.cjs
|
||||||
|
@@ -1,36 +1,40 @@
|
|||||||
const del = require("del");
|
const del = import("del");
|
||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
const paths = require("../paths");
|
const paths = require("../paths");
|
||||||
require("./translations");
|
require("./translations");
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"clean",
|
"clean",
|
||||||
gulp.parallel("clean-translations", () =>
|
gulp.parallel("clean-translations", async () =>
|
||||||
del([paths.app_output_root, paths.build_dir])
|
(await del).deleteSync([paths.app_output_root, paths.build_dir])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"clean-demo",
|
"clean-demo",
|
||||||
gulp.parallel("clean-translations", () =>
|
gulp.parallel("clean-translations", async () =>
|
||||||
del([paths.demo_output_root, paths.build_dir])
|
(await del).deleteSync([paths.demo_output_root, paths.build_dir])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"clean-cast",
|
"clean-cast",
|
||||||
gulp.parallel("clean-translations", () =>
|
gulp.parallel("clean-translations", async () =>
|
||||||
del([paths.cast_output_root, paths.build_dir])
|
(await del).deleteSync([paths.cast_output_root, paths.build_dir])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task("clean-hassio", () =>
|
gulp.task("clean-hassio", async () =>
|
||||||
del([paths.hassio_output_root, paths.build_dir])
|
(await del).deleteSync([paths.hassio_output_root, paths.build_dir])
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"clean-gallery",
|
"clean-gallery",
|
||||||
gulp.parallel("clean-translations", () =>
|
gulp.parallel("clean-translations", async () =>
|
||||||
del([paths.gallery_output_root, paths.gallery_build, paths.build_dir])
|
(await del).deleteSync([
|
||||||
|
paths.gallery_output_root,
|
||||||
|
paths.gallery_build,
|
||||||
|
paths.build_dir,
|
||||||
|
])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
// Task to download the latest Lokalise translations from the nightly workflow artifacts
|
// Task to download the latest Lokalise translations from the nightly workflow artifacts
|
||||||
|
|
||||||
|
const del = import("del");
|
||||||
const fs = require("fs/promises");
|
const fs = require("fs/promises");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const process = require("process");
|
const process = require("process");
|
||||||
const del = require("del");
|
|
||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
const jszip = require("jszip");
|
const jszip = require("jszip");
|
||||||
const tar = require("tar");
|
const tar = require("tar");
|
||||||
@@ -17,8 +17,8 @@ const WORKFLOW_NAME = "nightly.yaml";
|
|||||||
const ARTIFACT_NAME = "translations";
|
const ARTIFACT_NAME = "translations";
|
||||||
const CLIENT_ID = "Iv1.3914e28cb27834d1";
|
const CLIENT_ID = "Iv1.3914e28cb27834d1";
|
||||||
const EXTRACT_DIR = "translations";
|
const EXTRACT_DIR = "translations";
|
||||||
const TOKEN_FILE = path.join(EXTRACT_DIR, "token.json");
|
const TOKEN_FILE = path.posix.join(EXTRACT_DIR, "token.json");
|
||||||
const ARTIFACT_FILE = path.join(EXTRACT_DIR, "artifact.json");
|
const ARTIFACT_FILE = path.posix.join(EXTRACT_DIR, "artifact.json");
|
||||||
|
|
||||||
let allowTokenSetup = false;
|
let allowTokenSetup = false;
|
||||||
gulp.task("allow-setup-fetch-nightly-translations", (done) => {
|
gulp.task("allow-setup-fetch-nightly-translations", (done) => {
|
||||||
@@ -137,7 +137,11 @@ gulp.task("fetch-nightly-translations", async function () {
|
|||||||
|
|
||||||
// Remove the current translations
|
// Remove the current translations
|
||||||
const deleteCurrent = Promise.all(writings).then(
|
const deleteCurrent = Promise.all(writings).then(
|
||||||
del([`${EXTRACT_DIR}/*`, `!${ARTIFACT_FILE}`, `!${TOKEN_FILE}`])
|
(await del).deleteAsync([
|
||||||
|
`${EXTRACT_DIR}/*`,
|
||||||
|
`!${ARTIFACT_FILE}`,
|
||||||
|
`!${TOKEN_FILE}`,
|
||||||
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get the download URL and follow the redirect to download (stored as ArrayBuffer)
|
// Get the download URL and follow the redirect to download (stored as ArrayBuffer)
|
@@ -1,4 +1,4 @@
|
|||||||
const del = require("del");
|
const del = import("del");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
@@ -6,7 +6,7 @@ const paths = require("../paths");
|
|||||||
|
|
||||||
const outDir = "build/locale-data";
|
const outDir = "build/locale-data";
|
||||||
|
|
||||||
gulp.task("clean-locale-data", () => del([outDir]));
|
gulp.task("clean-locale-data", async () => (await del).deleteSync([outDir]));
|
||||||
|
|
||||||
gulp.task("ensure-locale-data-build-dir", (done) => {
|
gulp.task("ensure-locale-data-build-dir", (done) => {
|
||||||
if (!fs.existsSync(outDir)) {
|
if (!fs.existsSync(outDir)) {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
const del = import("del");
|
||||||
const crypto = require("crypto");
|
const crypto = require("crypto");
|
||||||
const del = require("del");
|
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const source = require("vinyl-source-stream");
|
const source = require("vinyl-source-stream");
|
||||||
const vinylBuffer = require("vinyl-buffer");
|
const vinylBuffer = require("vinyl-buffer");
|
||||||
@@ -13,7 +13,7 @@ const { mapFiles } = require("../util");
|
|||||||
const env = require("../env");
|
const env = require("../env");
|
||||||
const paths = require("../paths");
|
const paths = require("../paths");
|
||||||
|
|
||||||
require("./fetch-nightly_translations");
|
require("./fetch-nightly-translations");
|
||||||
|
|
||||||
const inFrontendDir = "translations/frontend";
|
const inFrontendDir = "translations/frontend";
|
||||||
const inBackendDir = "translations/backend";
|
const inBackendDir = "translations/backend";
|
||||||
@@ -120,7 +120,7 @@ function lokaliseTransform(data, original, file) {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.task("clean-translations", () => del([workDir]));
|
gulp.task("clean-translations", async () => (await del).deleteSync([workDir]));
|
||||||
|
|
||||||
gulp.task("ensure-translations-build-dir", (done) => {
|
gulp.task("ensure-translations-build-dir", (done) => {
|
||||||
if (!fs.existsSync(workDir)) {
|
if (!fs.existsSync(workDir)) {
|
||||||
|
@@ -22,7 +22,11 @@ class HcLayout extends LitElement {
|
|||||||
return html`
|
return html`
|
||||||
<ha-card>
|
<ha-card>
|
||||||
<div class="layout">
|
<div class="layout">
|
||||||
<img class="hero" src="/images/google-nest-hub.png" />
|
<img
|
||||||
|
class="hero"
|
||||||
|
alt="A Google Nest Hub with a Home Assistant dashboard on its screen"
|
||||||
|
src="/images/google-nest-hub.png"
|
||||||
|
/>
|
||||||
<h1 class="card-header">
|
<h1 class="card-header">
|
||||||
Home Assistant Cast${this.subtitle ? ` – ${this.subtitle}` : ""}
|
Home Assistant Cast${this.subtitle ? ` – ${this.subtitle}` : ""}
|
||||||
${this.auth
|
${this.auth
|
||||||
|
@@ -12,6 +12,7 @@ class HcLaunchScreen extends LitElement {
|
|||||||
return html`
|
return html`
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<img
|
<img
|
||||||
|
alt="Home Assistant logo on left, Nabu Casa logo on right, and red heart in center"
|
||||||
src="https://www.home-assistant.io/images/blog/2018-09-thinking-big/social.png"
|
src="https://www.home-assistant.io/images/blog/2018-09-thinking-big/social.png"
|
||||||
/>
|
/>
|
||||||
<div class="status">
|
<div class="status">
|
||||||
|
@@ -98,7 +98,9 @@ const alerts: {
|
|||||||
description: "Alert with slotted image",
|
description: "Alert with slotted image",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
iconSlot: html`<span slot="icon" class="image"
|
iconSlot: html`<span slot="icon" class="image"
|
||||||
><img src="https://www.home-assistant.io/images/home-assistant-logo.svg"
|
><img
|
||||||
|
alt="Home Assistant logo"
|
||||||
|
src="https://www.home-assistant.io/images/home-assistant-logo.svg"
|
||||||
/></span>`,
|
/></span>`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@@ -142,7 +142,8 @@ export class DemoHaBarSlider extends LitElement {
|
|||||||
}
|
}
|
||||||
.custom {
|
.custom {
|
||||||
--slider-bar-color: #ffcf4c;
|
--slider-bar-color: #ffcf4c;
|
||||||
--slider-bar-background: #ffcf4c64;
|
--slider-bar-background: #ffcf4c;
|
||||||
|
--slider-bar-background-opacity: 0.2;
|
||||||
--slider-bar-thickness: 100px;
|
--slider-bar-thickness: 100px;
|
||||||
--slider-bar-border-radius: 24px;
|
--slider-bar-border-radius: 24px;
|
||||||
}
|
}
|
||||||
|
@@ -115,8 +115,8 @@ export class DemoHaBarSwitch extends LitElement {
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.custom {
|
.custom {
|
||||||
--switch-bar-color-on: var(--rgb-green-color);
|
--switch-bar-on-color: var(--green-color);
|
||||||
--switch-bar-color-off: var(--rgb-red-color);
|
--switch-bar-off-color: var(--red-color);
|
||||||
--switch-bar-thickness: 100px;
|
--switch-bar-thickness: 100px;
|
||||||
--switch-bar-border-radius: 24px;
|
--switch-bar-border-radius: 24px;
|
||||||
--switch-bar-padding: 6px;
|
--switch-bar-padding: 6px;
|
||||||
|
@@ -99,16 +99,19 @@ const AREAS = [
|
|||||||
area_id: "backyard",
|
area_id: "backyard",
|
||||||
name: "Backyard",
|
name: "Backyard",
|
||||||
picture: null,
|
picture: null,
|
||||||
|
aliases: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
area_id: "bedroom",
|
area_id: "bedroom",
|
||||||
name: "Bedroom",
|
name: "Bedroom",
|
||||||
picture: null,
|
picture: null,
|
||||||
|
aliases: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
area_id: "livingroom",
|
area_id: "livingroom",
|
||||||
name: "Livingroom",
|
name: "Livingroom",
|
||||||
picture: null,
|
picture: null,
|
||||||
|
aliases: [],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -95,16 +95,19 @@ const AREAS = [
|
|||||||
area_id: "backyard",
|
area_id: "backyard",
|
||||||
name: "Backyard",
|
name: "Backyard",
|
||||||
picture: null,
|
picture: null,
|
||||||
|
aliases: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
area_id: "bedroom",
|
area_id: "bedroom",
|
||||||
name: "Bedroom",
|
name: "Bedroom",
|
||||||
picture: null,
|
picture: null,
|
||||||
|
aliases: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
area_id: "livingroom",
|
area_id: "livingroom",
|
||||||
name: "Livingroom",
|
name: "Livingroom",
|
||||||
picture: null,
|
picture: null,
|
||||||
|
aliases: [],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -104,15 +104,17 @@ const ENTITIES: HassEntity[] = [
|
|||||||
createEntity("alarm_control_panel.disarming", "disarming"),
|
createEntity("alarm_control_panel.disarming", "disarming"),
|
||||||
createEntity("alarm_control_panel.triggered", "triggered"),
|
createEntity("alarm_control_panel.triggered", "triggered"),
|
||||||
// Alert
|
// Alert
|
||||||
|
createEntity("alert.idle", "idle"),
|
||||||
createEntity("alert.off", "off"),
|
createEntity("alert.off", "off"),
|
||||||
createEntity("alert.on", "on"),
|
createEntity("alert.on", "on"),
|
||||||
// Automation
|
// Automation
|
||||||
createEntity("automation.off", "off"),
|
createEntity("automation.off", "off"),
|
||||||
createEntity("automation.on", "on"),
|
createEntity("automation.on", "on"),
|
||||||
// Binary Sensor
|
// Binary Sensor
|
||||||
...BINARY_SENSOR_DEVICE_CLASSES.map((dc) =>
|
...BINARY_SENSOR_DEVICE_CLASSES.map((dc) => [
|
||||||
createEntity(`binary_sensor.${dc}`, "on", dc)
|
createEntity(`binary_sensor.${dc}`, "off", dc),
|
||||||
),
|
createEntity(`binary_sensor.${dc}`, "on", dc),
|
||||||
|
]).reduce((arr, item) => [...arr, ...item], []),
|
||||||
// Button
|
// Button
|
||||||
createEntity("button.restart", "unknown", "restart"),
|
createEntity("button.restart", "unknown", "restart"),
|
||||||
createEntity("button.update", "unknown", "update"),
|
createEntity("button.update", "unknown", "update"),
|
||||||
@@ -141,6 +143,9 @@ const ENTITIES: HassEntity[] = [
|
|||||||
createEntity("climate.auto_dry", "auto", undefined, {
|
createEntity("climate.auto_dry", "auto", undefined, {
|
||||||
hvac_action: "drying",
|
hvac_action: "drying",
|
||||||
}),
|
}),
|
||||||
|
createEntity("climate.auto_fan", "auto", undefined, {
|
||||||
|
hvac_action: "fan",
|
||||||
|
}),
|
||||||
// Cover
|
// Cover
|
||||||
createEntity("cover.closing", "closing"),
|
createEntity("cover.closing", "closing"),
|
||||||
createEntity("cover.closed", "closed"),
|
createEntity("cover.closed", "closed"),
|
||||||
@@ -179,8 +184,8 @@ const ENTITIES: HassEntity[] = [
|
|||||||
createEntity("light.off", "off"),
|
createEntity("light.off", "off"),
|
||||||
createEntity("light.on", "on"),
|
createEntity("light.on", "on"),
|
||||||
// Locks
|
// Locks
|
||||||
createEntity("lock.unlocked", "unlocked"),
|
|
||||||
createEntity("lock.locked", "locked"),
|
createEntity("lock.locked", "locked"),
|
||||||
|
createEntity("lock.unlocked", "unlocked"),
|
||||||
createEntity("lock.locking", "locking"),
|
createEntity("lock.locking", "locking"),
|
||||||
createEntity("lock.unlocking", "unlocking"),
|
createEntity("lock.unlocking", "unlocking"),
|
||||||
createEntity("lock.jammed", "jammed"),
|
createEntity("lock.jammed", "jammed"),
|
||||||
@@ -204,21 +209,33 @@ const ENTITIES: HassEntity[] = [
|
|||||||
createEntity("media_player.speaker_playing", "playing", "speaker"),
|
createEntity("media_player.speaker_playing", "playing", "speaker"),
|
||||||
createEntity("media_player.speaker_paused", "paused", "speaker"),
|
createEntity("media_player.speaker_paused", "paused", "speaker"),
|
||||||
createEntity("media_player.speaker_standby", "standby", "speaker"),
|
createEntity("media_player.speaker_standby", "standby", "speaker"),
|
||||||
|
// Plant
|
||||||
|
createEntity("plant.ok", "ok"),
|
||||||
|
createEntity("plant.problem", "problem"),
|
||||||
// Remote
|
// Remote
|
||||||
createEntity("remote.off", "off"),
|
createEntity("remote.off", "off"),
|
||||||
createEntity("remote.on", "on"),
|
createEntity("remote.on", "on"),
|
||||||
|
// Schedule
|
||||||
|
createEntity("schedule.off", "off"),
|
||||||
|
createEntity("schedule.on", "on"),
|
||||||
// Script
|
// Script
|
||||||
createEntity("script.off", "off"),
|
createEntity("script.off", "off"),
|
||||||
createEntity("script.on", "on"),
|
createEntity("script.on", "on"),
|
||||||
// Sensor
|
// Sensor
|
||||||
...SENSOR_DEVICE_CLASSES.map((dc) => createEntity(`sensor.${dc}`, "10", dc)),
|
...SENSOR_DEVICE_CLASSES.map((dc) => createEntity(`sensor.${dc}`, "10", dc)),
|
||||||
// Battery sensor
|
// Battery sensor
|
||||||
...[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100].map((value) =>
|
...[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, "unknown", "not_valid"].map(
|
||||||
createEntity(`sensor.battery_${value}`, value.toString(), "battery")
|
(value) =>
|
||||||
|
createEntity(`sensor.battery_${value}`, value.toString(), "battery")
|
||||||
),
|
),
|
||||||
// Siren
|
// Siren
|
||||||
createEntity("siren.off", "off"),
|
createEntity("siren.off", "off"),
|
||||||
createEntity("siren.on", "on"),
|
createEntity("siren.on", "on"),
|
||||||
|
// Sun
|
||||||
|
createEntity("sun.below", "below_horizon"),
|
||||||
|
createEntity("sun.above", "above_horizon"),
|
||||||
|
createEntity("sun.unknown", "unknown"),
|
||||||
|
createEntity("sun.unavailable", "unavailable"),
|
||||||
// Switch
|
// Switch
|
||||||
createEntity("switch.off", "off"),
|
createEntity("switch.off", "off"),
|
||||||
createEntity("switch.on", "on"),
|
createEntity("switch.on", "on"),
|
||||||
@@ -322,7 +339,7 @@ export class DemoEntityState extends LitElement {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
entity_id: {
|
entity_id: {
|
||||||
title: "Entity id",
|
title: "Entity ID",
|
||||||
width: "30%",
|
width: "30%",
|
||||||
filterable: true,
|
filterable: true,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
|
@@ -29,7 +29,9 @@ class HassioAddonRepositoryEl extends LitElement {
|
|||||||
if (filter) {
|
if (filter) {
|
||||||
return filterAndSort(addons, filter);
|
return filterAndSort(addons, filter);
|
||||||
}
|
}
|
||||||
return addons.sort((a, b) => caseInsensitiveStringCompare(a.name, b.name));
|
return addons.sort((a, b) =>
|
||||||
|
caseInsensitiveStringCompare(a.name, b.name, this.hass.locale.language)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
|
@@ -404,6 +404,7 @@ class HassioAddonInfo extends LitElement {
|
|||||||
? html`
|
? html`
|
||||||
<img
|
<img
|
||||||
class="logo"
|
class="logo"
|
||||||
|
alt=""
|
||||||
src="/api/hassio/addons/${this.addon.slug}/logo"
|
src="/api/hassio/addons/${this.addon.slug}/logo"
|
||||||
/>
|
/>
|
||||||
`
|
`
|
||||||
|
@@ -15,7 +15,7 @@ class SupervisorFormfieldLabel extends LitElement {
|
|||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
${this.imageUrl
|
${this.imageUrl
|
||||||
? html`<img loading="lazy" .src=${this.imageUrl} class="icon" />`
|
? html`<img loading="lazy" alt="" src=${this.imageUrl} class="icon" />`
|
||||||
: this.iconPath
|
: this.iconPath
|
||||||
? html`<ha-svg-icon .path=${this.iconPath} class="icon"></ha-svg-icon>`
|
? html`<ha-svg-icon .path=${this.iconPath} class="icon"></ha-svg-icon>`
|
||||||
: ""}
|
: ""}
|
||||||
|
@@ -35,7 +35,13 @@ class HassioAddons extends LitElement {
|
|||||||
</ha-card>
|
</ha-card>
|
||||||
`
|
`
|
||||||
: this.supervisor.addon.addons
|
: this.supervisor.addon.addons
|
||||||
.sort((a, b) => caseInsensitiveStringCompare(a.name, b.name))
|
.sort((a, b) =>
|
||||||
|
caseInsensitiveStringCompare(
|
||||||
|
a.name,
|
||||||
|
b.name,
|
||||||
|
this.hass.locale.language
|
||||||
|
)
|
||||||
|
)
|
||||||
.map(
|
.map(
|
||||||
(addon) => html`
|
(addon) => html`
|
||||||
<ha-card
|
<ha-card
|
||||||
|
@@ -15,7 +15,12 @@ import { HomeAssistant } from "../../../../src/types";
|
|||||||
import { HassioHardwareDialogParams } from "./show-dialog-hassio-hardware";
|
import { HassioHardwareDialogParams } from "./show-dialog-hassio-hardware";
|
||||||
|
|
||||||
const _filterDevices = memoizeOne(
|
const _filterDevices = memoizeOne(
|
||||||
(showAdvanced: boolean, hardware: HassioHardwareInfo, filter: string) =>
|
(
|
||||||
|
showAdvanced: boolean,
|
||||||
|
hardware: HassioHardwareInfo,
|
||||||
|
filter: string,
|
||||||
|
language: string
|
||||||
|
) =>
|
||||||
hardware.devices
|
hardware.devices
|
||||||
.filter(
|
.filter(
|
||||||
(device) =>
|
(device) =>
|
||||||
@@ -28,7 +33,7 @@ const _filterDevices = memoizeOne(
|
|||||||
.toLocaleLowerCase()
|
.toLocaleLowerCase()
|
||||||
.includes(filter))
|
.includes(filter))
|
||||||
)
|
)
|
||||||
.sort((a, b) => stringCompare(a.name, b.name))
|
.sort((a, b) => stringCompare(a.name, b.name, language))
|
||||||
);
|
);
|
||||||
|
|
||||||
@customElement("dialog-hassio-hardware")
|
@customElement("dialog-hassio-hardware")
|
||||||
@@ -56,7 +61,8 @@ class HassioHardwareDialog extends LitElement {
|
|||||||
const devices = _filterDevices(
|
const devices = _filterDevices(
|
||||||
this.hass.userData?.showAdvanced || false,
|
this.hass.userData?.showAdvanced || false,
|
||||||
this._dialogParams.hardware,
|
this._dialogParams.hardware,
|
||||||
(this._filter || "").toLowerCase()
|
(this._filter || "").toLowerCase(),
|
||||||
|
this.hass.locale.language
|
||||||
);
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
@@ -68,7 +68,9 @@ class HassioRepositoriesDialog extends LitElement {
|
|||||||
repo.slug !== "a0d7b954" && // Home Assistant Community Add-ons
|
repo.slug !== "a0d7b954" && // Home Assistant Community Add-ons
|
||||||
repo.slug !== "5c53de3b" // The ESPHome repository
|
repo.slug !== "5c53de3b" // The ESPHome repository
|
||||||
)
|
)
|
||||||
.sort((a, b) => caseInsensitiveStringCompare(a.name, b.name))
|
.sort((a, b) =>
|
||||||
|
caseInsensitiveStringCompare(a.name, b.name, this.hass.locale.language)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
private _filteredUsedRepositories = memoizeOne(
|
private _filteredUsedRepositories = memoizeOne(
|
||||||
|
@@ -59,7 +59,11 @@ class HassioIngressView extends LitElement {
|
|||||||
return html` <hass-loading-screen></hass-loading-screen> `;
|
return html` <hass-loading-screen></hass-loading-screen> `;
|
||||||
}
|
}
|
||||||
|
|
||||||
const iframe = html`<iframe src=${this._addon.ingress_url!}></iframe>`;
|
const iframe = html`<iframe
|
||||||
|
title=${this._addon.name}
|
||||||
|
src=${this._addon.ingress_url!}
|
||||||
|
>
|
||||||
|
</iframe>`;
|
||||||
|
|
||||||
if (!this.ingressPanel) {
|
if (!this.ingressPanel) {
|
||||||
return html`<hass-subpage
|
return html`<hass-subpage
|
||||||
|
@@ -5,4 +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",
|
||||||
};
|
};
|
||||||
|
183
package.json
183
package.json
@@ -25,21 +25,16 @@
|
|||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@braintree/sanitize-url": "^6.0.0",
|
"@braintree/sanitize-url": "^6.0.0",
|
||||||
"@codemirror/autocomplete": "^0.19.12",
|
"@codemirror/autocomplete": "^6.4.0",
|
||||||
"@codemirror/commands": "^0.19.8",
|
"@codemirror/commands": "^6.1.3",
|
||||||
"@codemirror/gutter": "^0.19.9",
|
"@codemirror/language": "^6.4.0",
|
||||||
"@codemirror/highlight": "^0.19.7",
|
"@codemirror/legacy-modes": "^6.3.1",
|
||||||
"@codemirror/history": "^0.19.2",
|
"@codemirror/search": "^6.2.3",
|
||||||
"@codemirror/legacy-modes": "^0.19.0",
|
"@codemirror/state": "^6.2.0",
|
||||||
"@codemirror/rectangular-selection": "^0.19.1",
|
"@codemirror/view": "^6.7.1",
|
||||||
"@codemirror/search": "^0.19.6",
|
|
||||||
"@codemirror/state": "^0.19.6",
|
|
||||||
"@codemirror/stream-parser": "^0.19.5",
|
|
||||||
"@codemirror/text": "^0.19.6",
|
|
||||||
"@codemirror/view": "^0.19.40",
|
|
||||||
"@formatjs/intl-datetimeformat": "^4.2.5",
|
"@formatjs/intl-datetimeformat": "^4.2.5",
|
||||||
"@formatjs/intl-getcanonicallocales": "^1.8.0",
|
"@formatjs/intl-getcanonicallocales": "^2.0.5",
|
||||||
"@formatjs/intl-locale": "^2.4.40",
|
"@formatjs/intl-locale": "^3.0.11",
|
||||||
"@formatjs/intl-numberformat": "^7.2.5",
|
"@formatjs/intl-numberformat": "^7.2.5",
|
||||||
"@formatjs/intl-pluralrules": "^4.1.5",
|
"@formatjs/intl-pluralrules": "^4.1.5",
|
||||||
"@formatjs/intl-relativetimeformat": "^9.3.2",
|
"@formatjs/intl-relativetimeformat": "^9.3.2",
|
||||||
@@ -49,34 +44,35 @@
|
|||||||
"@fullcalendar/interaction": "5.9.0",
|
"@fullcalendar/interaction": "5.9.0",
|
||||||
"@fullcalendar/list": "5.9.0",
|
"@fullcalendar/list": "5.9.0",
|
||||||
"@fullcalendar/timegrid": "5.9.0",
|
"@fullcalendar/timegrid": "5.9.0",
|
||||||
"@lit-labs/motion": "^1.0.2",
|
"@lezer/highlight": "^1.1.3",
|
||||||
"@lit-labs/virtualizer": "patch:@lit-labs/virtualizer@0.7.0-pre.2#./.yarn/patches/@lit-labs/virtualizer/event-target-shim.patch",
|
"@lit-labs/motion": "^1.0.3",
|
||||||
"@material/chips": "14.0.0-canary.261f2db59.0",
|
"@lit-labs/virtualizer": "^1.0.1",
|
||||||
"@material/data-table": "14.0.0-canary.261f2db59.0",
|
"@material/chips": "=14.0.0-canary.53b3cad2f.0",
|
||||||
"@material/mwc-button": "0.25.3",
|
"@material/data-table": "=14.0.0-canary.53b3cad2f.0",
|
||||||
"@material/mwc-checkbox": "0.25.3",
|
"@material/mwc-button": "^0.27.0",
|
||||||
"@material/mwc-circular-progress": "0.25.3",
|
"@material/mwc-checkbox": "^0.27.0",
|
||||||
"@material/mwc-dialog": "0.25.3",
|
"@material/mwc-circular-progress": "^0.27.0",
|
||||||
"@material/mwc-drawer": "^0.25.3",
|
"@material/mwc-dialog": "^0.27.0",
|
||||||
"@material/mwc-fab": "0.25.3",
|
"@material/mwc-drawer": "^0.27.0",
|
||||||
"@material/mwc-formfield": "0.25.3",
|
"@material/mwc-fab": "^0.27.0",
|
||||||
"@material/mwc-icon-button": "patch:@material/mwc-icon-button@0.25.3#./.yarn/patches/@material/mwc-icon-button/remove-icon.patch",
|
"@material/mwc-formfield": "^0.27.0",
|
||||||
"@material/mwc-linear-progress": "0.25.3",
|
"@material/mwc-icon-button": "^0.27.0",
|
||||||
"@material/mwc-list": "^0.25.3",
|
"@material/mwc-linear-progress": "^0.27.0",
|
||||||
"@material/mwc-menu": "0.25.3",
|
"@material/mwc-list": "^0.27.0",
|
||||||
"@material/mwc-radio": "0.25.3",
|
"@material/mwc-menu": "^0.27.0",
|
||||||
"@material/mwc-ripple": "0.25.3",
|
"@material/mwc-radio": "^0.27.0",
|
||||||
"@material/mwc-select": "0.25.3",
|
"@material/mwc-ripple": "^0.27.0",
|
||||||
"@material/mwc-slider": "0.25.3",
|
"@material/mwc-select": "^0.27.0",
|
||||||
"@material/mwc-switch": "0.25.3",
|
"@material/mwc-slider": "^0.27.0",
|
||||||
"@material/mwc-tab": "0.25.3",
|
"@material/mwc-switch": "^0.27.0",
|
||||||
"@material/mwc-tab-bar": "0.25.3",
|
"@material/mwc-tab": "^0.27.0",
|
||||||
"@material/mwc-textarea": "^0.25.3",
|
"@material/mwc-tab-bar": "^0.27.0",
|
||||||
"@material/mwc-textfield": "0.25.3",
|
"@material/mwc-textarea": "^0.27.0",
|
||||||
"@material/mwc-top-app-bar-fixed": "^0.25.3",
|
"@material/mwc-textfield": "^0.27.0",
|
||||||
"@material/top-app-bar": "14.0.0-canary.261f2db59.0",
|
"@material/mwc-top-app-bar-fixed": "^0.27.0",
|
||||||
"@mdi/js": "7.0.96",
|
"@material/top-app-bar": "=14.0.0-canary.53b3cad2f.0",
|
||||||
"@mdi/svg": "7.0.96",
|
"@mdi/js": "7.1.96",
|
||||||
|
"@mdi/svg": "7.1.96",
|
||||||
"@polymer/app-layout": "^3.1.0",
|
"@polymer/app-layout": "^3.1.0",
|
||||||
"@polymer/iron-flex-layout": "^3.0.1",
|
"@polymer/iron-flex-layout": "^3.0.1",
|
||||||
"@polymer/iron-icon": "^3.0.1",
|
"@polymer/iron-icon": "^3.0.1",
|
||||||
@@ -91,47 +87,48 @@
|
|||||||
"@polymer/paper-toast": "^3.0.1",
|
"@polymer/paper-toast": "^3.0.1",
|
||||||
"@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.5.4",
|
"@thomasloven/round-slider": "0.6.0",
|
||||||
"@vaadin/combo-box": "^23.2.9",
|
"@vaadin/combo-box": "^23.3.5",
|
||||||
"@vaadin/vaadin-themable-mixin": "^23.2.9",
|
"@vaadin/vaadin-themable-mixin": "^23.3.5",
|
||||||
"@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.2.0",
|
"@vue/web-component-wrapper": "^1.3.0",
|
||||||
"@webcomponents/scoped-custom-element-registry": "^0.0.5",
|
"@webcomponents/scoped-custom-element-registry": "^0.0.5",
|
||||||
"@webcomponents/webcomponentsjs": "^2.2.10",
|
"@webcomponents/webcomponentsjs": "^2.2.10",
|
||||||
"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.3.1",
|
||||||
"core-js": "^3.15.2",
|
"core-js": "^3.15.2",
|
||||||
"cropperjs": "^1.5.12",
|
"cropperjs": "^1.5.13",
|
||||||
"date-fns": "^2.23.0",
|
"date-fns": "^2.29.3",
|
||||||
|
"date-fns-tz": "^1.3.7",
|
||||||
"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.0.0",
|
"fuse.js": "^6.6.2",
|
||||||
"google-timezones-json": "^1.0.2",
|
"google-timezones-json": "^1.0.2",
|
||||||
"hammerjs": "^2.0.8",
|
"hammerjs": "^2.0.8",
|
||||||
"hls.js": "^1.2.5",
|
"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": "^5.1.3",
|
||||||
"intl-messageformat": "^9.9.1",
|
"intl-messageformat": "^10.2.5",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"leaflet": "^1.7.1",
|
"leaflet": "^1.7.1",
|
||||||
"leaflet-draw": "^1.0.4",
|
"leaflet-draw": "^1.0.4",
|
||||||
"lit": "^2.1.2",
|
"lit": "^2.6.1",
|
||||||
"marked": "^4.0.12",
|
"marked": "^4.0.12",
|
||||||
"memoize-one": "^5.2.1",
|
"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.1.1",
|
"punycode": "^2.3.0",
|
||||||
"qr-scanner": "^1.3.0",
|
"qr-scanner": "^1.3.0",
|
||||||
"qrcode": "^1.4.4",
|
"qrcode": "^1.5.1",
|
||||||
"regenerator-runtime": "^0.13.8",
|
"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.1",
|
||||||
"sortablejs": "^1.14.0",
|
"sortablejs": "^1.14.0",
|
||||||
"superstruct": "^0.15.2",
|
"superstruct": "^1.0.3",
|
||||||
"tinykeys": "^1.1.3",
|
"tinykeys": "^1.1.3",
|
||||||
"tsparticles": "^1.34.0",
|
"tsparticles": "^1.34.0",
|
||||||
"unfetch": "^4.1.0",
|
"unfetch": "^4.1.0",
|
||||||
@@ -140,19 +137,19 @@
|
|||||||
"vue": "^2.6.12",
|
"vue": "^2.6.12",
|
||||||
"vue2-daterange-picker": "^0.5.1",
|
"vue2-daterange-picker": "^0.5.1",
|
||||||
"weekstart": "^1.1.0",
|
"weekstart": "^1.1.0",
|
||||||
"workbox-cacheable-response": "^6.4.2",
|
"workbox-cacheable-response": "^6.5.4",
|
||||||
"workbox-core": "^6.4.2",
|
"workbox-core": "^6.5.4",
|
||||||
"workbox-expiration": "^6.4.2",
|
"workbox-expiration": "^6.5.4",
|
||||||
"workbox-precaching": "^6.4.2",
|
"workbox-precaching": "^6.5.4",
|
||||||
"workbox-routing": "^6.4.2",
|
"workbox-routing": "^6.5.4",
|
||||||
"workbox-strategies": "^6.4.2",
|
"workbox-strategies": "^6.5.4",
|
||||||
"xss": "^1.0.9"
|
"xss": "^1.0.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.20.2",
|
"@babel/core": "^7.20.2",
|
||||||
"@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.2",
|
"@babel/plugin-proposal-decorators": "^7.20.7",
|
||||||
"@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.2",
|
||||||
"@babel/plugin-proposal-optional-chaining": "^7.18.9",
|
"@babel/plugin-proposal-optional-chaining": "^7.18.9",
|
||||||
@@ -163,7 +160,7 @@
|
|||||||
"@babel/preset-typescript": "^7.18.6",
|
"@babel/preset-typescript": "^7.18.6",
|
||||||
"@koa/cors": "^3.1.0",
|
"@koa/cors": "^3.1.0",
|
||||||
"@octokit/auth-oauth-device": "^4.0.2",
|
"@octokit/auth-oauth-device": "^4.0.2",
|
||||||
"@octokit/rest": "^19.0.4",
|
"@octokit/rest": "^19.0.7",
|
||||||
"@open-wc/dev-server-hmr": "^0.0.2",
|
"@open-wc/dev-server-hmr": "^0.0.2",
|
||||||
"@rollup/plugin-babel": "^5.2.1",
|
"@rollup/plugin-babel": "^5.2.1",
|
||||||
"@rollup/plugin-commonjs": "^11.1.0",
|
"@rollup/plugin-commonjs": "^11.1.0",
|
||||||
@@ -172,93 +169,89 @@
|
|||||||
"@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.3",
|
||||||
"@types/glob": "^7",
|
"@types/glob": "^8",
|
||||||
"@types/hammerjs": "^2.0.41",
|
"@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": "^8",
|
||||||
"@types/qrcode": "^1.4.2",
|
"@types/qrcode": "^1.5.0",
|
||||||
"@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.44.0",
|
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
||||||
"@typescript-eslint/parser": "^5.44.0",
|
"@typescript-eslint/parser": "^5.49.0",
|
||||||
"@web/dev-server": "^0.0.24",
|
"@web/dev-server": "^0.0.24",
|
||||||
"@web/dev-server-rollup": "^0.2.11",
|
"@web/dev-server-rollup": "^0.2.11",
|
||||||
"babel-loader": "^9.1.0",
|
"babel-loader": "^9.1.0",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"del": "^4.0.0",
|
"del": "^7.0.0",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-config-airbnb-base": "^14.2.1",
|
"eslint-config-airbnb-base": "^14.2.1",
|
||||||
"eslint-config-airbnb-typescript": "^14.0.0",
|
"eslint-config-airbnb-typescript": "^14.0.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.6.0",
|
||||||
"eslint-import-resolver-webpack": "^0.13.1",
|
"eslint-import-resolver-webpack": "^0.13.1",
|
||||||
"eslint-plugin-disable": "^2.0.1",
|
"eslint-plugin-disable": "^2.0.1",
|
||||||
"eslint-plugin-import": "^2.24.2",
|
"eslint-plugin-import": "^2.24.2",
|
||||||
"eslint-plugin-lit": "^1.6.1",
|
"eslint-plugin-lit": "^1.6.1",
|
||||||
"eslint-plugin-unused-imports": "^1.1.5",
|
"eslint-plugin-unused-imports": "^1.1.5",
|
||||||
"eslint-plugin-wc": "^1.3.2",
|
"eslint-plugin-wc": "^1.4.0",
|
||||||
"fancy-log": "^1.3.3",
|
"fancy-log": "^2.0.0",
|
||||||
"fs-extra": "^7.0.1",
|
"fs-extra": "^11.1.0",
|
||||||
"glob": "^7.2.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.6",
|
||||||
"gulp-merge-json": "^1.3.1",
|
"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": "^3.0.1",
|
||||||
"html-minifier": "^4.0.0",
|
"html-minifier": "^4.0.0",
|
||||||
"husky": "^8.0.1",
|
"husky": "^8.0.3",
|
||||||
"instant-mocha": "^1.3.1",
|
"instant-mocha": "^1.3.1",
|
||||||
"jszip": "^3.10.1",
|
"jszip": "^3.10.1",
|
||||||
"lint-staged": "^13.0.3",
|
"lint-staged": "^13.1.0",
|
||||||
"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.25.7",
|
||||||
"map-stream": "^0.0.7",
|
"map-stream": "^0.0.7",
|
||||||
"merge-stream": "^1.0.1",
|
"merge-stream": "^1.0.1",
|
||||||
"mocha": "^8.4.0",
|
"mocha": "^8.4.0",
|
||||||
"object-hash": "^2.0.3",
|
"object-hash": "^3.0.0",
|
||||||
"open": "^7.0.4",
|
"open": "^8.4.0",
|
||||||
"pinst": "^3.0.0",
|
"pinst": "^3.0.0",
|
||||||
"prettier": "^2.8.1",
|
"prettier": "^2.8.3",
|
||||||
"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": "^4.0.4",
|
"rollup-plugin-visualizer": "^5.9.0",
|
||||||
"serve": "^11.3.2",
|
"serve": "^11.3.2",
|
||||||
"sinon": "^11.0.0",
|
"sinon": "^15.0.1",
|
||||||
"source-map-url": "^0.4.0",
|
"source-map-url": "^0.4.0",
|
||||||
"systemjs": "^6.3.2",
|
"systemjs": "^6.3.2",
|
||||||
"tar": "^6.1.11",
|
"tar": "^6.1.11",
|
||||||
"terser-webpack-plugin": "^5.2.4",
|
"terser-webpack-plugin": "^5.2.4",
|
||||||
"ts-lit-plugin": "^1.2.1",
|
"ts-lit-plugin": "^1.2.1",
|
||||||
"typescript": "^4.9.3",
|
"typescript": "^4.9.4",
|
||||||
"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.55.1",
|
||||||
"webpack-cli": "^4.8.0",
|
"webpack-cli": "^5.0.1",
|
||||||
"webpack-dev-server": "^4.3.0",
|
"webpack-dev-server": "^4.11.1",
|
||||||
"webpack-manifest-plugin": "^4.0.2",
|
"webpack-manifest-plugin": "^4.0.2",
|
||||||
"webpackbar": "^5.0.0-3",
|
"webpackbar": "^5.0.2",
|
||||||
"workbox-build": "^6.4.2"
|
"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",
|
"@webcomponents/webcomponentsjs": "^2.2.10"
|
||||||
"lit": "^2.1.2",
|
|
||||||
"lit-html": "2.1.2",
|
|
||||||
"lit-element": "3.1.2",
|
|
||||||
"@lit/reactive-element": "1.2.1"
|
|
||||||
},
|
},
|
||||||
"main": "src/home-assistant.js",
|
"main": "src/home-assistant.js",
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
"arrowParens": "always"
|
"arrowParens": "always"
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@3.2.3"
|
"packageManager": "yarn@3.3.1"
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "home-assistant-frontend"
|
name = "home-assistant-frontend"
|
||||||
version = "20221213.1"
|
version = "20230128.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"
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
import { hex2rgb } from "./convert-color";
|
|
||||||
|
|
||||||
export const THEME_COLORS = new Set([
|
export const THEME_COLORS = new Set([
|
||||||
"primary",
|
"primary",
|
||||||
"accent",
|
"accent",
|
||||||
@@ -21,22 +19,17 @@ export const THEME_COLORS = new Set([
|
|||||||
"orange",
|
"orange",
|
||||||
"deep-orange",
|
"deep-orange",
|
||||||
"brown",
|
"brown",
|
||||||
|
"light-grey",
|
||||||
"grey",
|
"grey",
|
||||||
|
"dark-grey",
|
||||||
"blue-grey",
|
"blue-grey",
|
||||||
"black",
|
"black",
|
||||||
"white",
|
"white",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export function computeRgbColor(color: string): string {
|
export function computeCssColor(color: string): string {
|
||||||
if (THEME_COLORS.has(color)) {
|
if (THEME_COLORS.has(color)) {
|
||||||
return `var(--rgb-${color}-color)`;
|
return `var(--${color}-color)`;
|
||||||
}
|
|
||||||
if (color.startsWith("#")) {
|
|
||||||
try {
|
|
||||||
return hex2rgb(color).join(", ");
|
|
||||||
} catch (err) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,8 @@ import {
|
|||||||
mdiCommentAlert,
|
mdiCommentAlert,
|
||||||
mdiCounter,
|
mdiCounter,
|
||||||
mdiCurrentAc,
|
mdiCurrentAc,
|
||||||
|
mdiDatabase,
|
||||||
|
mdiEarHearing,
|
||||||
mdiEye,
|
mdiEye,
|
||||||
mdiFan,
|
mdiFan,
|
||||||
mdiFlash,
|
mdiFlash,
|
||||||
@@ -57,6 +59,7 @@ import {
|
|||||||
mdiThermometerLines,
|
mdiThermometerLines,
|
||||||
mdiThermostat,
|
mdiThermostat,
|
||||||
mdiTimerOutline,
|
mdiTimerOutline,
|
||||||
|
mdiTransmissionTower,
|
||||||
mdiVideo,
|
mdiVideo,
|
||||||
mdiWater,
|
mdiWater,
|
||||||
mdiWaterPercent,
|
mdiWaterPercent,
|
||||||
@@ -133,6 +136,8 @@ export const FIXED_DEVICE_CLASS_ICONS = {
|
|||||||
carbon_dioxide: mdiMoleculeCo2,
|
carbon_dioxide: mdiMoleculeCo2,
|
||||||
carbon_monoxide: mdiMoleculeCo,
|
carbon_monoxide: mdiMoleculeCo,
|
||||||
current: mdiCurrentAc,
|
current: mdiCurrentAc,
|
||||||
|
data_rate: mdiTransmissionTower,
|
||||||
|
data_size: mdiDatabase,
|
||||||
date: mdiCalendar,
|
date: mdiCalendar,
|
||||||
distance: mdiArrowLeftRight,
|
distance: mdiArrowLeftRight,
|
||||||
duration: mdiProgressClock,
|
duration: mdiProgressClock,
|
||||||
@@ -158,6 +163,7 @@ export const FIXED_DEVICE_CLASS_ICONS = {
|
|||||||
pressure: mdiGauge,
|
pressure: mdiGauge,
|
||||||
reactive_power: mdiFlash,
|
reactive_power: mdiFlash,
|
||||||
signal_strength: mdiWifi,
|
signal_strength: mdiWifi,
|
||||||
|
sound_pressure: mdiEarHearing,
|
||||||
speed: mdiSpeedometer,
|
speed: mdiSpeedometer,
|
||||||
sulphur_dioxide: mdiMolecule,
|
sulphur_dioxide: mdiMolecule,
|
||||||
temperature: mdiThermometer,
|
temperature: mdiThermometer,
|
||||||
@@ -195,6 +201,7 @@ export const DOMAINS_WITH_CARD = [
|
|||||||
export const SENSOR_ENTITIES = [
|
export const SENSOR_ENTITIES = [
|
||||||
"sensor",
|
"sensor",
|
||||||
"binary_sensor",
|
"binary_sensor",
|
||||||
|
"calendar",
|
||||||
"camera",
|
"camera",
|
||||||
"device_tracker",
|
"device_tracker",
|
||||||
"weather",
|
"weather",
|
||||||
|
@@ -18,7 +18,7 @@ export const relativeTime = (
|
|||||||
to?: Date,
|
to?: Date,
|
||||||
includeTense = true
|
includeTense = true
|
||||||
): string => {
|
): string => {
|
||||||
const diff = selectUnit(from, to);
|
const diff = selectUnit(from, to, locale);
|
||||||
if (includeTense) {
|
if (includeTense) {
|
||||||
return formatRelTimeMem(locale).format(diff.value, diff.unit);
|
return formatRelTimeMem(locale).format(diff.value, diff.unit);
|
||||||
}
|
}
|
||||||
|
@@ -39,5 +39,5 @@ export default function scrollToTarget(element, target) {
|
|||||||
);
|
);
|
||||||
requestAnimationFrame(updateFrame.bind(element));
|
requestAnimationFrame(updateFrame.bind(element));
|
||||||
}
|
}
|
||||||
}.call(element));
|
}).call(element);
|
||||||
}
|
}
|
||||||
|
@@ -1,21 +0,0 @@
|
|||||||
export const alarmControlPanelColor = (state?: string): string | undefined => {
|
|
||||||
switch (state) {
|
|
||||||
case "armed_away":
|
|
||||||
case "armed_vacation":
|
|
||||||
case "armed_home":
|
|
||||||
case "armed_night":
|
|
||||||
case "armed_custom_bypass":
|
|
||||||
return "alarm-armed";
|
|
||||||
case "pending":
|
|
||||||
return "alarm-pending";
|
|
||||||
case "arming":
|
|
||||||
case "disarming":
|
|
||||||
return "alarm-arming";
|
|
||||||
case "triggered":
|
|
||||||
return "alarm-triggered";
|
|
||||||
case "disarmed":
|
|
||||||
return "alarm-disarmed";
|
|
||||||
default:
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
};
|
|
@@ -1,13 +1,15 @@
|
|||||||
export const batteryStateColor = (state: string) => {
|
export const batteryStateColorProperty = (
|
||||||
|
state: string
|
||||||
|
): string | undefined => {
|
||||||
const value = Number(state);
|
const value = Number(state);
|
||||||
if (isNaN(value)) {
|
if (isNaN(value)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (value >= 70) {
|
if (value >= 70) {
|
||||||
return "sensor-battery-high";
|
return "--state-sensor-battery-high-color";
|
||||||
}
|
}
|
||||||
if (value >= 30) {
|
if (value >= 30) {
|
||||||
return "sensor-battery-medium";
|
return "--state-sensor-battery-medium-color";
|
||||||
}
|
}
|
||||||
return "sensor-battery-low";
|
return "--state-sensor-battery-low-color";
|
||||||
};
|
};
|
||||||
|
@@ -1,29 +0,0 @@
|
|||||||
import { HassEntity } from "home-assistant-js-websocket";
|
|
||||||
import { stateActive } from "../state_active";
|
|
||||||
|
|
||||||
const ALERTING_DEVICE_CLASSES = new Set([
|
|
||||||
"battery",
|
|
||||||
"carbon_monoxide",
|
|
||||||
"gas",
|
|
||||||
"heat",
|
|
||||||
"lock",
|
|
||||||
"moisture",
|
|
||||||
"problem",
|
|
||||||
"safety",
|
|
||||||
"smoke",
|
|
||||||
"tamper",
|
|
||||||
]);
|
|
||||||
|
|
||||||
export const binarySensorColor = (
|
|
||||||
stateObj: HassEntity,
|
|
||||||
state: string
|
|
||||||
): string | undefined => {
|
|
||||||
const deviceClass = stateObj?.attributes.device_class;
|
|
||||||
|
|
||||||
if (!stateActive(stateObj, state)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return deviceClass && ALERTING_DEVICE_CLASSES.has(deviceClass)
|
|
||||||
? "binary-sensor-alerting"
|
|
||||||
: "binary-sensor";
|
|
||||||
};
|
|
@@ -1,28 +0,0 @@
|
|||||||
import { HvacAction } from "../../../data/climate";
|
|
||||||
|
|
||||||
export const CLIMATE_HVAC_ACTION_COLORS: Record<HvacAction, string> = {
|
|
||||||
cooling: "var(--rgb-state-climate-cool-color)",
|
|
||||||
drying: "var(--rgb-state-climate-dry-color)",
|
|
||||||
heating: "var(--rgb-state-climate-heat-color)",
|
|
||||||
idle: "var(--rgb-state-climate-idle-color)",
|
|
||||||
off: "var(--rgb-state-climate-off-color)",
|
|
||||||
};
|
|
||||||
|
|
||||||
export const climateColor = (state: string): string | undefined => {
|
|
||||||
switch (state) {
|
|
||||||
case "auto":
|
|
||||||
return "climate-auto";
|
|
||||||
case "cool":
|
|
||||||
return "climate-cool";
|
|
||||||
case "dry":
|
|
||||||
return "climate-dry";
|
|
||||||
case "fan_only":
|
|
||||||
return "climate-fan-only";
|
|
||||||
case "heat":
|
|
||||||
return "climate-heat";
|
|
||||||
case "heat_cool":
|
|
||||||
return "climate-heat-cool";
|
|
||||||
default:
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
};
|
|
@@ -1,15 +0,0 @@
|
|||||||
export const lockColor = (state?: string): string | undefined => {
|
|
||||||
switch (state) {
|
|
||||||
case "unlocked":
|
|
||||||
return "lock-unlocked";
|
|
||||||
case "locked":
|
|
||||||
return "lock-locked";
|
|
||||||
case "jammed":
|
|
||||||
return "lock-jammed";
|
|
||||||
case "locking":
|
|
||||||
case "unlocking":
|
|
||||||
return "lock-pending";
|
|
||||||
default:
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
};
|
|
@@ -1,10 +0,0 @@
|
|||||||
export const personColor = (state: string): string | undefined => {
|
|
||||||
switch (state) {
|
|
||||||
case "home":
|
|
||||||
return "person-home";
|
|
||||||
case "not_home":
|
|
||||||
return "person-not-home";
|
|
||||||
default:
|
|
||||||
return "person-zone";
|
|
||||||
}
|
|
||||||
};
|
|
@@ -1,15 +0,0 @@
|
|||||||
import { HassEntity } from "home-assistant-js-websocket";
|
|
||||||
import { batteryStateColor } from "./battery_color";
|
|
||||||
|
|
||||||
export const sensorColor = (
|
|
||||||
stateObj: HassEntity,
|
|
||||||
state: string
|
|
||||||
): string | undefined => {
|
|
||||||
const deviceClass = stateObj?.attributes.device_class;
|
|
||||||
|
|
||||||
if (deviceClass === "battery") {
|
|
||||||
return batteryStateColor(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
};
|
|
@@ -1,15 +0,0 @@
|
|||||||
import { HassEntity } from "home-assistant-js-websocket";
|
|
||||||
import { UpdateEntity, updateIsInstalling } from "../../../data/update";
|
|
||||||
import { stateActive } from "../state_active";
|
|
||||||
|
|
||||||
export const updateColor = (
|
|
||||||
stateObj: HassEntity,
|
|
||||||
state: string
|
|
||||||
): string | undefined => {
|
|
||||||
if (!stateActive(stateObj, state)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return updateIsInstalling(stateObj as UpdateEntity)
|
|
||||||
? "update-installing"
|
|
||||||
: "update";
|
|
||||||
};
|
|
52
src/common/entity/compute_attribute_display.ts
Normal file
52
src/common/entity/compute_attribute_display.ts
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
|
import { EntityRegistryEntry } from "../../data/entity_registry";
|
||||||
|
import { HomeAssistant } from "../../types";
|
||||||
|
import { LocalizeFunc } from "../translations/localize";
|
||||||
|
import { computeDomain } from "./compute_domain";
|
||||||
|
|
||||||
|
export const computeAttributeValueDisplay = (
|
||||||
|
localize: LocalizeFunc,
|
||||||
|
stateObj: HassEntity,
|
||||||
|
entities: HomeAssistant["entities"],
|
||||||
|
attribute: string,
|
||||||
|
value?: any
|
||||||
|
): string => {
|
||||||
|
const entityId = stateObj.entity_id;
|
||||||
|
const attributeValue =
|
||||||
|
value !== undefined ? value : stateObj.attributes[attribute];
|
||||||
|
const domain = computeDomain(entityId);
|
||||||
|
const entity = entities[entityId] as EntityRegistryEntry | undefined;
|
||||||
|
const translationKey = entity?.translation_key;
|
||||||
|
|
||||||
|
return (
|
||||||
|
(translationKey &&
|
||||||
|
localize(
|
||||||
|
`component.${entity.platform}.entity.${domain}.${translationKey}.state_attributes.${attribute}.state.${attributeValue}`
|
||||||
|
)) ||
|
||||||
|
localize(
|
||||||
|
`component.${domain}.state_attributes._.${attribute}.state.${attributeValue}`
|
||||||
|
) ||
|
||||||
|
attributeValue
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const computeAttributeNameDisplay = (
|
||||||
|
localize: LocalizeFunc,
|
||||||
|
stateObj: HassEntity,
|
||||||
|
entities: HomeAssistant["entities"],
|
||||||
|
attribute: string
|
||||||
|
): string => {
|
||||||
|
const entityId = stateObj.entity_id;
|
||||||
|
const domain = computeDomain(entityId);
|
||||||
|
const entity = entities[entityId] as EntityRegistryEntry | undefined;
|
||||||
|
const translationKey = entity?.translation_key;
|
||||||
|
|
||||||
|
return (
|
||||||
|
(translationKey &&
|
||||||
|
localize(
|
||||||
|
`component.${entity.platform}.entity.${domain}.${translationKey}.state_attributes.${attribute}.name`
|
||||||
|
)) ||
|
||||||
|
localize(`component.${domain}.state_attributes._.${attribute}.name`) ||
|
||||||
|
attribute
|
||||||
|
);
|
||||||
|
};
|
@@ -3,6 +3,8 @@ import {
|
|||||||
mdiAccountArrowRight,
|
mdiAccountArrowRight,
|
||||||
mdiAirHumidifier,
|
mdiAirHumidifier,
|
||||||
mdiAirHumidifierOff,
|
mdiAirHumidifierOff,
|
||||||
|
mdiAudioVideo,
|
||||||
|
mdiAudioVideoOff,
|
||||||
mdiBluetooth,
|
mdiBluetooth,
|
||||||
mdiBluetoothConnect,
|
mdiBluetoothConnect,
|
||||||
mdiCalendar,
|
mdiCalendar,
|
||||||
@@ -25,8 +27,6 @@ import {
|
|||||||
mdiPackageUp,
|
mdiPackageUp,
|
||||||
mdiPowerPlug,
|
mdiPowerPlug,
|
||||||
mdiPowerPlugOff,
|
mdiPowerPlugOff,
|
||||||
mdiAudioVideo,
|
|
||||||
mdiAudioVideoOff,
|
|
||||||
mdiRestart,
|
mdiRestart,
|
||||||
mdiSpeaker,
|
mdiSpeaker,
|
||||||
mdiSpeakerOff,
|
mdiSpeakerOff,
|
||||||
@@ -53,6 +53,7 @@ import { DEFAULT_DOMAIN_ICON, FIXED_DOMAIN_ICONS } from "../const";
|
|||||||
import { alarmPanelIcon } from "./alarm_panel_icon";
|
import { alarmPanelIcon } from "./alarm_panel_icon";
|
||||||
import { binarySensorIcon } from "./binary_sensor_icon";
|
import { binarySensorIcon } from "./binary_sensor_icon";
|
||||||
import { coverIcon } from "./cover_icon";
|
import { coverIcon } from "./cover_icon";
|
||||||
|
import { numberIcon } from "./number_icon";
|
||||||
import { sensorIcon } from "./sensor_icon";
|
import { sensorIcon } from "./sensor_icon";
|
||||||
|
|
||||||
export const domainIcon = (
|
export const domainIcon = (
|
||||||
@@ -108,7 +109,7 @@ export const domainIconWithoutDefault = (
|
|||||||
return compareState === "not_home" ? mdiAccountArrowRight : mdiAccount;
|
return compareState === "not_home" ? mdiAccountArrowRight : mdiAccount;
|
||||||
|
|
||||||
case "humidifier":
|
case "humidifier":
|
||||||
return state && state === "off" ? mdiAirHumidifierOff : mdiAirHumidifier;
|
return compareState === "off" ? mdiAirHumidifierOff : mdiAirHumidifier;
|
||||||
|
|
||||||
case "input_boolean":
|
case "input_boolean":
|
||||||
return compareState === "on"
|
return compareState === "on"
|
||||||
@@ -180,6 +181,15 @@ export const domainIconWithoutDefault = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "number": {
|
||||||
|
const icon = numberIcon(stateObj);
|
||||||
|
if (icon) {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "person":
|
case "person":
|
||||||
return compareState === "not_home" ? mdiAccountArrowRight : mdiAccount;
|
return compareState === "not_home" ? mdiAccountArrowRight : mdiAccount;
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ import { HassEntity } from "home-assistant-js-websocket";
|
|||||||
import { computeStateDomain } from "./compute_state_domain";
|
import { computeStateDomain } from "./compute_state_domain";
|
||||||
import { UNAVAILABLE_STATES } from "../../data/entity";
|
import { UNAVAILABLE_STATES } from "../../data/entity";
|
||||||
|
|
||||||
const FIXED_DOMAIN_STATES = {
|
export const FIXED_DOMAIN_STATES = {
|
||||||
alarm_control_panel: [
|
alarm_control_panel: [
|
||||||
"armed_away",
|
"armed_away",
|
||||||
"armed_custom_bypass",
|
"armed_custom_bypass",
|
||||||
@@ -57,7 +57,7 @@ const FIXED_DOMAIN_STATES = {
|
|||||||
"windy-variant",
|
"windy-variant",
|
||||||
"windy",
|
"windy",
|
||||||
],
|
],
|
||||||
};
|
} as const;
|
||||||
|
|
||||||
const FIXED_DOMAIN_ATTRIBUTE_STATES = {
|
const FIXED_DOMAIN_ATTRIBUTE_STATES = {
|
||||||
alarm_control_panel: {
|
alarm_control_panel: {
|
||||||
|
13
src/common/entity/number_icon.ts
Normal file
13
src/common/entity/number_icon.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/** Return an icon representing a number state. */
|
||||||
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
|
import { FIXED_DEVICE_CLASS_ICONS } from "../const";
|
||||||
|
|
||||||
|
export const numberIcon = (stateObj?: HassEntity): string | undefined => {
|
||||||
|
const dclass = stateObj?.attributes.device_class;
|
||||||
|
|
||||||
|
if (dclass && dclass in FIXED_DEVICE_CLASS_ICONS) {
|
||||||
|
return FIXED_DEVICE_CLASS_ICONS[dclass];
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
};
|
@@ -1,5 +1,5 @@
|
|||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { OFF_STATES, UNAVAILABLE } from "../../data/entity";
|
import { isUnavailableState, OFF, UNAVAILABLE } from "../../data/entity";
|
||||||
import { computeDomain } from "./compute_domain";
|
import { computeDomain } from "./compute_domain";
|
||||||
|
|
||||||
export function stateActive(stateObj: HassEntity, state?: string): boolean {
|
export function stateActive(stateObj: HassEntity, state?: string): boolean {
|
||||||
@@ -10,7 +10,15 @@ export function stateActive(stateObj: HassEntity, state?: string): boolean {
|
|||||||
return compareState !== UNAVAILABLE;
|
return compareState !== UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OFF_STATES.includes(compareState)) {
|
if (isUnavailableState(compareState)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The "off" check is relevant for most domains, but there are exceptions
|
||||||
|
// such as "alert" where "off" is still a somewhat active state and
|
||||||
|
// therefore gets a custom color and "idle" is instead the state that
|
||||||
|
// matches what most other domains consider inactive.
|
||||||
|
if (compareState === OFF && domain !== "alert") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,8 +26,11 @@ export function stateActive(stateObj: HassEntity, state?: string): boolean {
|
|||||||
switch (domain) {
|
switch (domain) {
|
||||||
case "alarm_control_panel":
|
case "alarm_control_panel":
|
||||||
return compareState !== "disarmed";
|
return compareState !== "disarmed";
|
||||||
|
case "alert":
|
||||||
|
// "on" and "off" are active, as "off" just means alert was acknowledged but is still active
|
||||||
|
return compareState !== "idle";
|
||||||
case "cover":
|
case "cover":
|
||||||
return !["closed", "closing"].includes(compareState);
|
return compareState !== "closed";
|
||||||
case "device_tracker":
|
case "device_tracker":
|
||||||
case "person":
|
case "person":
|
||||||
return compareState !== "not_home";
|
return compareState !== "not_home";
|
||||||
@@ -37,7 +48,7 @@ export function stateActive(stateObj: HassEntity, state?: string): boolean {
|
|||||||
return compareState === "active";
|
return compareState === "active";
|
||||||
case "camera":
|
case "camera":
|
||||||
return compareState === "streaming";
|
return compareState === "streaming";
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -1,91 +1,102 @@
|
|||||||
/** Return an color representing a state. */
|
/** Return an color representing a state. */
|
||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { UNAVAILABLE } from "../../data/entity";
|
import { UNAVAILABLE } from "../../data/entity";
|
||||||
import { alarmControlPanelColor } from "./color/alarm_control_panel_color";
|
import { computeCssVariable } from "../../resources/css-variables";
|
||||||
import { binarySensorColor } from "./color/binary_sensor_color";
|
import { slugify } from "../string/slugify";
|
||||||
import { climateColor } from "./color/climate_color";
|
import { batteryStateColorProperty } from "./color/battery_color";
|
||||||
import { lockColor } from "./color/lock_color";
|
|
||||||
import { personColor } from "./color/person_color";
|
|
||||||
import { sensorColor } from "./color/sensor_color";
|
|
||||||
import { updateColor } from "./color/update_color";
|
|
||||||
import { computeDomain } from "./compute_domain";
|
import { computeDomain } from "./compute_domain";
|
||||||
import { stateActive } from "./state_active";
|
import { stateActive } from "./state_active";
|
||||||
|
|
||||||
const STATIC_ACTIVE_COLORED_DOMAIN = new Set([
|
const STATE_COLORED_DOMAIN = new Set([
|
||||||
|
"alarm_control_panel",
|
||||||
"alert",
|
"alert",
|
||||||
"automation",
|
"automation",
|
||||||
|
"binary_sensor",
|
||||||
"calendar",
|
"calendar",
|
||||||
"camera",
|
"camera",
|
||||||
|
"climate",
|
||||||
"cover",
|
"cover",
|
||||||
|
"device_tracker",
|
||||||
"fan",
|
"fan",
|
||||||
"group",
|
"group",
|
||||||
"humidifier",
|
"humidifier",
|
||||||
"input_boolean",
|
"input_boolean",
|
||||||
"light",
|
"light",
|
||||||
|
"lock",
|
||||||
"media_player",
|
"media_player",
|
||||||
|
"person",
|
||||||
|
"plant",
|
||||||
"remote",
|
"remote",
|
||||||
|
"schedule",
|
||||||
"script",
|
"script",
|
||||||
"siren",
|
"siren",
|
||||||
|
"sun",
|
||||||
"switch",
|
"switch",
|
||||||
"timer",
|
"timer",
|
||||||
|
"update",
|
||||||
"vacuum",
|
"vacuum",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const stateColorCss = (stateObj: HassEntity, state?: string) => {
|
export const stateColorCss = (stateObj: HassEntity, state?: string) => {
|
||||||
const compareState = state !== undefined ? state : stateObj?.state;
|
const compareState = state !== undefined ? state : stateObj?.state;
|
||||||
if (compareState === UNAVAILABLE) {
|
if (compareState === UNAVAILABLE) {
|
||||||
return `var(--rgb-state-unavailable-color)`;
|
return `var(--state-unavailable-color)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const domainColor = stateColor(stateObj, state);
|
const properties = stateColorProperties(stateObj, state);
|
||||||
|
if (properties) {
|
||||||
if (domainColor) {
|
return computeCssVariable(properties);
|
||||||
return `var(--rgb-state-${domainColor}-color)`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!stateActive(stateObj, state)) {
|
|
||||||
return `var(--rgb-state-inactive-color)`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const stateColor = (stateObj: HassEntity, state?: string) => {
|
export const domainStateColorProperties = (
|
||||||
|
stateObj: HassEntity,
|
||||||
|
state?: string
|
||||||
|
): string[] => {
|
||||||
|
const compareState = state !== undefined ? state : stateObj.state;
|
||||||
|
const domain = computeDomain(stateObj.entity_id);
|
||||||
|
const active = stateActive(stateObj, state);
|
||||||
|
|
||||||
|
const properties: string[] = [];
|
||||||
|
|
||||||
|
const stateKey = slugify(compareState, "_");
|
||||||
|
const activeKey = active ? "active" : "inactive";
|
||||||
|
|
||||||
|
const dc = stateObj.attributes.device_class;
|
||||||
|
|
||||||
|
if (dc) {
|
||||||
|
properties.push(`--state-${domain}-${dc}-${stateKey}-color`);
|
||||||
|
}
|
||||||
|
|
||||||
|
properties.push(
|
||||||
|
`--state-${domain}-${stateKey}-color`,
|
||||||
|
`--state-${domain}-${activeKey}-color`,
|
||||||
|
`--state-${activeKey}-color`
|
||||||
|
);
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const stateColorProperties = (
|
||||||
|
stateObj: HassEntity,
|
||||||
|
state?: string
|
||||||
|
): string[] | undefined => {
|
||||||
const compareState = state !== undefined ? state : stateObj?.state;
|
const compareState = state !== undefined ? state : stateObj?.state;
|
||||||
const domain = computeDomain(stateObj.entity_id);
|
const domain = computeDomain(stateObj.entity_id);
|
||||||
|
const dc = stateObj.attributes.device_class;
|
||||||
|
|
||||||
if (
|
// Special rules for battery coloring
|
||||||
STATIC_ACTIVE_COLORED_DOMAIN.has(domain) &&
|
if (domain === "sensor" && dc === "battery") {
|
||||||
stateActive(stateObj, state)
|
const property = batteryStateColorProperty(compareState);
|
||||||
) {
|
if (property) {
|
||||||
return domain.replace("_", "-");
|
return [property];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (domain) {
|
if (STATE_COLORED_DOMAIN.has(domain)) {
|
||||||
case "alarm_control_panel":
|
return domainStateColorProperties(stateObj, state);
|
||||||
return alarmControlPanelColor(compareState);
|
|
||||||
|
|
||||||
case "binary_sensor":
|
|
||||||
return binarySensorColor(stateObj, compareState);
|
|
||||||
|
|
||||||
case "climate":
|
|
||||||
return climateColor(compareState);
|
|
||||||
|
|
||||||
case "lock":
|
|
||||||
return lockColor(compareState);
|
|
||||||
|
|
||||||
case "person":
|
|
||||||
case "device_tracker":
|
|
||||||
return personColor(compareState);
|
|
||||||
|
|
||||||
case "sensor":
|
|
||||||
return sensorColor(stateObj, compareState);
|
|
||||||
|
|
||||||
case "sun":
|
|
||||||
return compareState === "above_horizon" ? "sun-day" : "sun-night";
|
|
||||||
|
|
||||||
case "update":
|
|
||||||
return updateColor(stateObj, compareState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@@ -86,7 +86,7 @@ export const protocolIntegrationPicked = async (
|
|||||||
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee",
|
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee",
|
||||||
{
|
{
|
||||||
integration: "Zigbee",
|
integration: "Zigbee",
|
||||||
brand: options?.brand || options?.domain || "Z-Wave",
|
brand: options?.brand || options?.domain || "Zigbee",
|
||||||
supported_hardware_link: html`<a
|
supported_hardware_link: html`<a
|
||||||
href=${documentationUrl(
|
href=${documentationUrl(
|
||||||
hass,
|
hass,
|
||||||
|
@@ -1,4 +1,15 @@
|
|||||||
export const stringCompare = (a: string, b: string) => {
|
import memoizeOne from "memoize-one";
|
||||||
|
|
||||||
|
const collator = memoizeOne(
|
||||||
|
(language: string | undefined) => new Intl.Collator(language)
|
||||||
|
);
|
||||||
|
|
||||||
|
const caseInsensitiveCollator = memoizeOne(
|
||||||
|
(language: string | undefined) =>
|
||||||
|
new Intl.Collator(language, { sensitivity: "accent" })
|
||||||
|
);
|
||||||
|
|
||||||
|
const fallbackStringCompare = (a: string, b: string) => {
|
||||||
if (a < b) {
|
if (a < b) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -9,5 +20,28 @@ export const stringCompare = (a: string, b: string) => {
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const caseInsensitiveStringCompare = (a: string, b: string) =>
|
export const stringCompare = (
|
||||||
stringCompare(a.toLowerCase(), b.toLowerCase());
|
a: string,
|
||||||
|
b: string,
|
||||||
|
language: string | undefined = undefined
|
||||||
|
) => {
|
||||||
|
// @ts-ignore
|
||||||
|
if (Intl?.Collator) {
|
||||||
|
return collator(language).compare(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fallbackStringCompare(a, b);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const caseInsensitiveStringCompare = (
|
||||||
|
a: string,
|
||||||
|
b: string,
|
||||||
|
language: string | undefined = undefined
|
||||||
|
) => {
|
||||||
|
// @ts-ignore
|
||||||
|
if (Intl?.Collator) {
|
||||||
|
return caseInsensitiveCollator(language).compare(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fallbackStringCompare(a.toLowerCase(), b.toLowerCase());
|
||||||
|
};
|
||||||
|
@@ -22,6 +22,6 @@ export const iconColorCSS = css`
|
|||||||
|
|
||||||
/* Color the icon if unavailable */
|
/* Color the icon if unavailable */
|
||||||
ha-state-icon[data-state="unavailable"] {
|
ha-state-icon[data-state="unavailable"] {
|
||||||
color: rgb(var(--rgb-state-unavailable-color));
|
color: var(--state-unavailable-color);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
@@ -12,9 +12,6 @@ import { getLocalLanguage } from "../../util/common-translation";
|
|||||||
export type LocalizeKeys =
|
export type LocalizeKeys =
|
||||||
| FlattenObjectKeys<Omit<TranslationDict, "supervisor">>
|
| FlattenObjectKeys<Omit<TranslationDict, "supervisor">>
|
||||||
| `panel.${string}`
|
| `panel.${string}`
|
||||||
| `state.${string}`
|
|
||||||
| `state_attributes.${string}`
|
|
||||||
| `state_badge.${string}`
|
|
||||||
| `ui.card.alarm_control_panel.${string}`
|
| `ui.card.alarm_control_panel.${string}`
|
||||||
| `ui.card.weather.attributes.${string}`
|
| `ui.card.weather.attributes.${string}`
|
||||||
| `ui.card.weather.cardinal_direction.${string}`
|
| `ui.card.weather.cardinal_direction.${string}`
|
||||||
@@ -32,11 +29,9 @@ export type LocalizeKeys =
|
|||||||
| `ui.panel.config.devices.${string}`
|
| `ui.panel.config.devices.${string}`
|
||||||
| `ui.panel.config.energy.${string}`
|
| `ui.panel.config.energy.${string}`
|
||||||
| `ui.panel.config.info.${string}`
|
| `ui.panel.config.info.${string}`
|
||||||
| `ui.panel.config.logs.${string}`
|
|
||||||
| `ui.panel.config.lovelace.${string}`
|
| `ui.panel.config.lovelace.${string}`
|
||||||
| `ui.panel.config.network.${string}`
|
| `ui.panel.config.network.${string}`
|
||||||
| `ui.panel.config.scene.${string}`
|
| `ui.panel.config.scene.${string}`
|
||||||
| `ui.panel.config.url.${string}`
|
|
||||||
| `ui.panel.config.zha.${string}`
|
| `ui.panel.config.zha.${string}`
|
||||||
| `ui.panel.config.zwave_js.${string}`
|
| `ui.panel.config.zwave_js.${string}`
|
||||||
| `ui.panel.lovelace.card.${string}`
|
| `ui.panel.lovelace.card.${string}`
|
||||||
|
@@ -1,3 +1,7 @@
|
|||||||
|
import { differenceInDays, differenceInWeeks, startOfWeek } from "date-fns/esm";
|
||||||
|
import { FrontendLocaleData } from "../../data/translation";
|
||||||
|
import { firstWeekdayIndex } from "../datetime/first_weekday";
|
||||||
|
|
||||||
export type Unit =
|
export type Unit =
|
||||||
| "second"
|
| "second"
|
||||||
| "minute"
|
| "minute"
|
||||||
@@ -11,13 +15,12 @@ export type Unit =
|
|||||||
const MS_PER_SECOND = 1e3;
|
const MS_PER_SECOND = 1e3;
|
||||||
const SECS_PER_MIN = 60;
|
const SECS_PER_MIN = 60;
|
||||||
const SECS_PER_HOUR = SECS_PER_MIN * 60;
|
const SECS_PER_HOUR = SECS_PER_MIN * 60;
|
||||||
const SECS_PER_DAY = SECS_PER_HOUR * 24;
|
|
||||||
const SECS_PER_WEEK = SECS_PER_DAY * 7;
|
|
||||||
|
|
||||||
// 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,
|
||||||
to: Date | number = Date.now(),
|
to: Date | number = Date.now(),
|
||||||
|
locale: FrontendLocaleData,
|
||||||
thresholds: Partial<Thresholds> = {}
|
thresholds: Partial<Thresholds> = {}
|
||||||
): { value: number; unit: Unit } {
|
): { value: number; unit: Unit } {
|
||||||
const resolvedThresholds: Thresholds = {
|
const resolvedThresholds: Thresholds = {
|
||||||
@@ -49,29 +52,56 @@ export function selectUnit(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const days = secs / SECS_PER_DAY;
|
const fromDate = new Date(from);
|
||||||
|
const toDate = new Date(to);
|
||||||
|
|
||||||
|
// Set time component to zero, which allows us to compare only the days
|
||||||
|
fromDate.setHours(0, 0, 0, 0);
|
||||||
|
toDate.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
const days = differenceInDays(fromDate, toDate);
|
||||||
|
if (days === 0) {
|
||||||
|
return {
|
||||||
|
value: Math.round(hours),
|
||||||
|
unit: "hour",
|
||||||
|
};
|
||||||
|
}
|
||||||
if (Math.abs(days) < resolvedThresholds.day) {
|
if (Math.abs(days) < resolvedThresholds.day) {
|
||||||
return {
|
return {
|
||||||
value: Math.round(days),
|
value: days,
|
||||||
unit: "day",
|
unit: "day",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const weeks = secs / SECS_PER_WEEK;
|
const firstWeekday = firstWeekdayIndex(locale);
|
||||||
|
const fromWeek = startOfWeek(fromDate, { weekStartsOn: firstWeekday });
|
||||||
|
const toWeek = startOfWeek(toDate, { weekStartsOn: firstWeekday });
|
||||||
|
|
||||||
|
const weeks = differenceInWeeks(fromWeek, toWeek);
|
||||||
|
if (weeks === 0) {
|
||||||
|
return {
|
||||||
|
value: days,
|
||||||
|
unit: "day",
|
||||||
|
};
|
||||||
|
}
|
||||||
if (Math.abs(weeks) < resolvedThresholds.week) {
|
if (Math.abs(weeks) < resolvedThresholds.week) {
|
||||||
return {
|
return {
|
||||||
value: Math.round(weeks),
|
value: weeks,
|
||||||
unit: "week",
|
unit: "week",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const fromDate = new Date(from);
|
|
||||||
const toDate = new Date(to);
|
|
||||||
const years = fromDate.getFullYear() - toDate.getFullYear();
|
const years = fromDate.getFullYear() - toDate.getFullYear();
|
||||||
const months = years * 12 + fromDate.getMonth() - toDate.getMonth();
|
const months = years * 12 + fromDate.getMonth() - toDate.getMonth();
|
||||||
if (Math.round(Math.abs(months)) < resolvedThresholds.month) {
|
if (months === 0) {
|
||||||
return {
|
return {
|
||||||
value: Math.round(months),
|
value: weeks,
|
||||||
|
unit: "week",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (Math.abs(months) < resolvedThresholds.month || years === 0) {
|
||||||
|
return {
|
||||||
|
value: months,
|
||||||
unit: "month",
|
unit: "month",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,8 @@ import { customElement, property, state } from "lit/decorators";
|
|||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
import { styleMap } from "lit/directives/style-map";
|
import { styleMap } from "lit/directives/style-map";
|
||||||
import { clamp } from "../../common/number/clamp";
|
import { clamp } from "../../common/number/clamp";
|
||||||
|
import { computeRTL } from "../../common/util/compute_rtl";
|
||||||
|
import { HomeAssistant } from "../../types";
|
||||||
|
|
||||||
export const MIN_TIME_BETWEEN_UPDATES = 60 * 5 * 1000;
|
export const MIN_TIME_BETWEEN_UPDATES = 60 * 5 * 1000;
|
||||||
|
|
||||||
@@ -22,6 +24,8 @@ interface Tooltip extends TooltipModel<any> {
|
|||||||
export default class HaChartBase extends LitElement {
|
export default class HaChartBase extends LitElement {
|
||||||
public chart?: Chart;
|
public chart?: Chart;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property({ attribute: "chart-type", reflect: true })
|
@property({ attribute: "chart-type", reflect: true })
|
||||||
public chartType: ChartType = "line";
|
public chartType: ChartType = "line";
|
||||||
|
|
||||||
@@ -33,6 +37,8 @@ export default class HaChartBase extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Number }) public height?: number;
|
@property({ type: Number }) public height?: number;
|
||||||
|
|
||||||
|
@property({ type: Number }) public paddingYAxis = 0;
|
||||||
|
|
||||||
@state() private _chartHeight?: number;
|
@state() private _chartHeight?: number;
|
||||||
|
|
||||||
@state() private _tooltip?: Tooltip;
|
@state() private _tooltip?: Tooltip;
|
||||||
@@ -128,6 +134,8 @@ export default class HaChartBase extends LitElement {
|
|||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
height: `${this.height ?? this._chartHeight}px`,
|
height: `${this.height ?? this._chartHeight}px`,
|
||||||
overflow: this._chartHeight ? "initial" : "hidden",
|
overflow: this._chartHeight ? "initial" : "hidden",
|
||||||
|
"padding-left": `${computeRTL(this.hass) ? 0 : this.paddingYAxis}px`,
|
||||||
|
"padding-right": `${computeRTL(this.hass) ? this.paddingYAxis : 0}px`,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<canvas></canvas>
|
<canvas></canvas>
|
||||||
|
@@ -2,6 +2,8 @@ import type { ChartData, ChartDataset, ChartOptions } from "chart.js";
|
|||||||
import { html, LitElement, PropertyValues } from "lit";
|
import { html, LitElement, PropertyValues } from "lit";
|
||||||
import { property, state } from "lit/decorators";
|
import { property, state } from "lit/decorators";
|
||||||
import { getGraphColorByIndex } from "../../common/color/colors";
|
import { getGraphColorByIndex } from "../../common/color/colors";
|
||||||
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
|
import { computeRTL } from "../../common/util/compute_rtl";
|
||||||
import {
|
import {
|
||||||
formatNumber,
|
formatNumber,
|
||||||
numberFormatToLocale,
|
numberFormatToLocale,
|
||||||
@@ -30,17 +32,25 @@ class StateHistoryChartLine extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public endTime!: Date;
|
@property({ attribute: false }) public endTime!: Date;
|
||||||
|
|
||||||
|
@property({ type: Number }) public paddingYAxis = 0;
|
||||||
|
|
||||||
|
@property({ type: Number }) public chartIndex?;
|
||||||
|
|
||||||
@state() private _chartData?: ChartData<"line">;
|
@state() private _chartData?: ChartData<"line">;
|
||||||
|
|
||||||
@state() private _chartOptions?: ChartOptions;
|
@state() private _chartOptions?: ChartOptions;
|
||||||
|
|
||||||
|
@state() private _yWidth = 0;
|
||||||
|
|
||||||
private _chartTime: Date = new Date();
|
private _chartTime: Date = new Date();
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
<ha-chart-base
|
<ha-chart-base
|
||||||
|
.hass=${this.hass}
|
||||||
.data=${this._chartData}
|
.data=${this._chartData}
|
||||||
.options=${this._chartOptions}
|
.options=${this._chartOptions}
|
||||||
|
.paddingYAxis=${this.paddingYAxis - this._yWidth}
|
||||||
chart-type="line"
|
chart-type="line"
|
||||||
></ha-chart-base>
|
></ha-chart-base>
|
||||||
`;
|
`;
|
||||||
@@ -84,6 +94,16 @@ class StateHistoryChartLine extends LitElement {
|
|||||||
display: true,
|
display: true,
|
||||||
text: this.unit,
|
text: this.unit,
|
||||||
},
|
},
|
||||||
|
afterUpdate: (y) => {
|
||||||
|
if (this._yWidth !== Math.floor(y.width)) {
|
||||||
|
this._yWidth = Math.floor(y.width);
|
||||||
|
fireEvent(this, "y-width-changed", {
|
||||||
|
value: this._yWidth,
|
||||||
|
chartIndex: this.chartIndex,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
position: computeRTL(this.hass) ? "right" : "left",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: {
|
plugins: {
|
||||||
|
@@ -2,6 +2,7 @@ import type { ChartData, ChartDataset, ChartOptions } from "chart.js";
|
|||||||
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
|
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { formatDateTimeWithSeconds } from "../../common/datetime/format_date_time";
|
import { formatDateTimeWithSeconds } from "../../common/datetime/format_date_time";
|
||||||
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { numberFormatToLocale } from "../../common/number/format_number";
|
import { numberFormatToLocale } from "../../common/number/format_number";
|
||||||
import { computeRTL } from "../../common/util/compute_rtl";
|
import { computeRTL } from "../../common/util/compute_rtl";
|
||||||
import { TimelineEntity } from "../../data/history";
|
import { TimelineEntity } from "../../data/history";
|
||||||
@@ -32,18 +33,26 @@ export class StateHistoryChartTimeline extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public endTime!: Date;
|
@property({ attribute: false }) public endTime!: Date;
|
||||||
|
|
||||||
|
@property({ type: Number }) public paddingYAxis = 0;
|
||||||
|
|
||||||
|
@property({ type: Number }) public chartIndex?;
|
||||||
|
|
||||||
@state() private _chartData?: ChartData<"timeline">;
|
@state() private _chartData?: ChartData<"timeline">;
|
||||||
|
|
||||||
@state() private _chartOptions?: ChartOptions<"timeline">;
|
@state() private _chartOptions?: ChartOptions<"timeline">;
|
||||||
|
|
||||||
|
@state() private _yWidth = 0;
|
||||||
|
|
||||||
private _chartTime: Date = new Date();
|
private _chartTime: Date = new Date();
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
<ha-chart-base
|
<ha-chart-base
|
||||||
|
.hass=${this.hass}
|
||||||
.data=${this._chartData}
|
.data=${this._chartData}
|
||||||
.options=${this._chartOptions}
|
.options=${this._chartOptions}
|
||||||
.height=${this.data.length * 30 + 30}
|
.height=${this.data.length * 30 + 30}
|
||||||
|
.paddingYAxis=${this.paddingYAxis - this._yWidth}
|
||||||
chart-type="timeline"
|
chart-type="timeline"
|
||||||
></ha-chart-base>
|
></ha-chart-base>
|
||||||
`;
|
`;
|
||||||
@@ -131,6 +140,15 @@ export class StateHistoryChartTimeline extends LitElement {
|
|||||||
scaleInstance.width = narrow ? 105 : 185;
|
scaleInstance.width = narrow ? 105 : 185;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
afterUpdate: (y) => {
|
||||||
|
if (this._yWidth !== Math.floor(y.width)) {
|
||||||
|
this._yWidth = Math.floor(y.width);
|
||||||
|
fireEvent(this, "y-width-changed", {
|
||||||
|
value: this._yWidth,
|
||||||
|
chartIndex: this.chartIndex,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
position: computeRTL(this.hass) ? "right" : "left",
|
position: computeRTL(this.hass) ? "right" : "left",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -31,6 +31,12 @@ const chunkData = (inputArray: any[], chunks: number) =>
|
|||||||
return results;
|
return results;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HASSDomEvents {
|
||||||
|
"y-width-changed": { value: number; chartIndex: number };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@customElement("state-history-charts")
|
@customElement("state-history-charts")
|
||||||
class StateHistoryCharts extends LitElement {
|
class StateHistoryCharts extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
@@ -56,6 +62,12 @@ class StateHistoryCharts extends LitElement {
|
|||||||
|
|
||||||
@state() private _computedEndTime!: Date;
|
@state() private _computedEndTime!: Date;
|
||||||
|
|
||||||
|
@state() private _maxYWidth = 0;
|
||||||
|
|
||||||
|
@state() private _childYWidths: number[] = [];
|
||||||
|
|
||||||
|
@state() private _chartCount = 0;
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@restoreScroll(".container") private _savedScrollPos?: number;
|
@restoreScroll(".container") private _savedScrollPos?: number;
|
||||||
|
|
||||||
@@ -99,6 +111,8 @@ class StateHistoryCharts extends LitElement {
|
|||||||
).concat(this.historyData.line)
|
).concat(this.historyData.line)
|
||||||
: this.historyData.line;
|
: this.historyData.line;
|
||||||
|
|
||||||
|
this._chartCount = combinedItems.length;
|
||||||
|
|
||||||
return this.virtualize
|
return this.virtualize
|
||||||
? html`<div class="container ha-scrollbar" @scroll=${this._saveScrollPos}>
|
? html`<div class="container ha-scrollbar" @scroll=${this._saveScrollPos}>
|
||||||
<lit-virtualizer
|
<lit-virtualizer
|
||||||
@@ -130,7 +144,10 @@ class StateHistoryCharts extends LitElement {
|
|||||||
.identifier=${item.identifier}
|
.identifier=${item.identifier}
|
||||||
.showNames=${this.showNames}
|
.showNames=${this.showNames}
|
||||||
.endTime=${this._computedEndTime}
|
.endTime=${this._computedEndTime}
|
||||||
|
.paddingYAxis=${this._maxYWidth}
|
||||||
.names=${this.names}
|
.names=${this.names}
|
||||||
|
.chartIndex=${index}
|
||||||
|
@y-width-changed=${this._yWidthChanged}
|
||||||
></state-history-chart-line>
|
></state-history-chart-line>
|
||||||
</div> `;
|
</div> `;
|
||||||
}
|
}
|
||||||
@@ -144,6 +161,9 @@ class StateHistoryCharts extends LitElement {
|
|||||||
.names=${this.names}
|
.names=${this.names}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
.chunked=${this.virtualize}
|
.chunked=${this.virtualize}
|
||||||
|
.paddingYAxis=${this._maxYWidth}
|
||||||
|
.chartIndex=${index}
|
||||||
|
@y-width-changed=${this._yWidthChanged}
|
||||||
></state-history-chart-timeline>
|
></state-history-chart-timeline>
|
||||||
</div> `;
|
</div> `;
|
||||||
};
|
};
|
||||||
@@ -152,6 +172,21 @@ class StateHistoryCharts extends LitElement {
|
|||||||
return !(changedProps.size === 1 && changedProps.has("hass"));
|
return !(changedProps.size === 1 && changedProps.has("hass"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected updated(changedProps: PropertyValues) {
|
||||||
|
if (changedProps.has("_chartCount")) {
|
||||||
|
if (this._chartCount < this._childYWidths.length) {
|
||||||
|
this._childYWidths.length = this._chartCount;
|
||||||
|
this._maxYWidth =
|
||||||
|
this._childYWidths.length === 0 ? 0 : Math.max(...this._childYWidths);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _yWidthChanged(e: CustomEvent<HASSDomEvents["y-width-changed"]>) {
|
||||||
|
this._childYWidths[e.detail.chartIndex] = e.detail.value;
|
||||||
|
this._maxYWidth = Math.max(...this._childYWidths);
|
||||||
|
}
|
||||||
|
|
||||||
private _isHistoryEmpty(): boolean {
|
private _isHistoryEmpty(): boolean {
|
||||||
const historyDataEmpty =
|
const historyDataEmpty =
|
||||||
!this.historyData ||
|
!this.historyData ||
|
||||||
|
@@ -133,6 +133,7 @@ class StatisticsChart extends LitElement {
|
|||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-chart-base
|
<ha-chart-base
|
||||||
|
.hass=${this.hass}
|
||||||
.data=${this._chartData}
|
.data=${this._chartData}
|
||||||
.options=${this._chartOptions}
|
.options=${this._chartOptions}
|
||||||
.chartType=${this.chartType}
|
.chartType=${this.chartType}
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { getGraphColorByIndex } from "../../../common/color/colors";
|
import { getGraphColorByIndex } from "../../../common/color/colors";
|
||||||
import { lab2hex, rgb2hex, rgb2lab } from "../../../common/color/convert-color";
|
import { hex2rgb, lab2hex, rgb2lab } from "../../../common/color/convert-color";
|
||||||
import { labBrighten } from "../../../common/color/lab";
|
import { labBrighten } from "../../../common/color/lab";
|
||||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||||
import { stateActive } from "../../../common/entity/state_active";
|
import { stateColorProperties } from "../../../common/entity/state_color";
|
||||||
import { stateColor } from "../../../common/entity/state_color";
|
import { UNAVAILABLE, UNKNOWN } from "../../../data/entity";
|
||||||
import { UNAVAILABLE } from "../../../data/entity";
|
import { computeCssValue } from "../../../resources/css-variables";
|
||||||
|
|
||||||
const DOMAIN_STATE_SHADES: Record<string, Record<string, number>> = {
|
const DOMAIN_STATE_SHADES: Record<string, Record<string, number>> = {
|
||||||
media_player: {
|
media_player: {
|
||||||
@@ -17,61 +17,35 @@ const DOMAIN_STATE_SHADES: Record<string, Record<string, number>> = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const cssColorMap: Map<string, [number, number, number]> = new Map();
|
|
||||||
|
|
||||||
function cssToRgb(
|
|
||||||
cssVariable: string,
|
|
||||||
computedStyles: CSSStyleDeclaration
|
|
||||||
): [number, number, number] | undefined {
|
|
||||||
if (!cssVariable.startsWith("--rgb")) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cssColorMap.has(cssVariable)) {
|
|
||||||
return cssColorMap.get(cssVariable)!;
|
|
||||||
}
|
|
||||||
|
|
||||||
const value = computedStyles.getPropertyValue(cssVariable);
|
|
||||||
|
|
||||||
if (!value) return undefined;
|
|
||||||
|
|
||||||
const rgb = value.split(",").map((v) => Number(v)) as [
|
|
||||||
number,
|
|
||||||
number,
|
|
||||||
number
|
|
||||||
];
|
|
||||||
cssColorMap.set(cssVariable, rgb);
|
|
||||||
|
|
||||||
return rgb;
|
|
||||||
}
|
|
||||||
|
|
||||||
function computeTimelineStateColor(
|
function computeTimelineStateColor(
|
||||||
state: string,
|
state: string,
|
||||||
computedStyles: CSSStyleDeclaration,
|
computedStyles: CSSStyleDeclaration,
|
||||||
stateObj?: HassEntity
|
stateObj?: HassEntity
|
||||||
): string | undefined {
|
): string | undefined {
|
||||||
if (!stateObj || state === UNAVAILABLE) {
|
if (!stateObj || state === UNAVAILABLE) {
|
||||||
return "transparent";
|
return computeCssValue("--history-unavailable-color", computedStyles);
|
||||||
}
|
}
|
||||||
|
|
||||||
const color = stateColor(stateObj, state);
|
if (state === UNKNOWN) {
|
||||||
|
return computeCssValue("--history-unknown-color", computedStyles);
|
||||||
if (!color && !stateActive(stateObj, state)) {
|
|
||||||
const rgb = cssToRgb("--rgb-state-inactive-color", computedStyles);
|
|
||||||
if (!rgb) return undefined;
|
|
||||||
return rgb2hex(rgb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const rgb = cssToRgb(`--rgb-state-${color}-color`, computedStyles);
|
const properties = stateColorProperties(stateObj, state);
|
||||||
|
|
||||||
|
if (!properties) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rgb = computeCssValue(properties, computedStyles);
|
||||||
|
|
||||||
if (!rgb) return undefined;
|
if (!rgb) return undefined;
|
||||||
|
|
||||||
const domain = computeDomain(stateObj.entity_id);
|
const domain = computeDomain(stateObj.entity_id);
|
||||||
const shade = DOMAIN_STATE_SHADES[domain]?.[state] as number | number;
|
const shade = DOMAIN_STATE_SHADES[domain]?.[state] as number | number;
|
||||||
if (!shade) {
|
if (!shade) {
|
||||||
return rgb2hex(rgb);
|
return rgb;
|
||||||
}
|
}
|
||||||
return lab2hex(labBrighten(rgb2lab(rgb), shade));
|
return lab2hex(labBrighten(rgb2lab(hex2rgb(rgb)), shade));
|
||||||
}
|
}
|
||||||
|
|
||||||
let colorIndex = 0;
|
let colorIndex = 0;
|
||||||
|
@@ -266,14 +266,16 @@ export const getCountryOptions = memoizeOne((language?: string) => {
|
|||||||
value: country,
|
value: country,
|
||||||
label: countryDisplayNames ? countryDisplayNames.of(country)! : country,
|
label: countryDisplayNames ? countryDisplayNames.of(country)! : country,
|
||||||
}));
|
}));
|
||||||
options.sort((a, b) => caseInsensitiveStringCompare(a.label, b.label));
|
options.sort((a, b) =>
|
||||||
|
caseInsensitiveStringCompare(a.label, b.label, language)
|
||||||
|
);
|
||||||
return options;
|
return options;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const createCountryListEl = () => {
|
export const createCountryListEl = (language?: string) => {
|
||||||
const list = document.createElement("datalist");
|
const list = document.createElement("datalist");
|
||||||
list.id = "countries";
|
list.id = "countries";
|
||||||
const options = getCountryOptions();
|
const options = getCountryOptions(language);
|
||||||
for (const country of options) {
|
for (const country of options) {
|
||||||
const option = document.createElement("option");
|
const option = document.createElement("option");
|
||||||
option.value = country.value;
|
option.value = country.value;
|
||||||
|
@@ -157,7 +157,7 @@ export const CURRENCIES = [
|
|||||||
"XPF",
|
"XPF",
|
||||||
"YER",
|
"YER",
|
||||||
"ZAR",
|
"ZAR",
|
||||||
"ZMK",
|
"ZMW",
|
||||||
"ZWL",
|
"ZWL",
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -173,14 +173,16 @@ export const getCurrencyOptions = memoizeOne((language?: string) => {
|
|||||||
value: currency,
|
value: currency,
|
||||||
label: currencyDisplayNames ? currencyDisplayNames.of(currency)! : currency,
|
label: currencyDisplayNames ? currencyDisplayNames.of(currency)! : currency,
|
||||||
}));
|
}));
|
||||||
options.sort((a, b) => caseInsensitiveStringCompare(a.label, b.label));
|
options.sort((a, b) =>
|
||||||
|
caseInsensitiveStringCompare(a.label, b.label, language)
|
||||||
|
);
|
||||||
return options;
|
return options;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const createCurrencyListEl = () => {
|
export const createCurrencyListEl = (language: string) => {
|
||||||
const list = document.createElement("datalist");
|
const list = document.createElement("datalist");
|
||||||
list.id = "currencies";
|
list.id = "currencies";
|
||||||
for (const currency of getCurrencyOptions()) {
|
for (const currency of getCurrencyOptions(language)) {
|
||||||
const option = document.createElement("option");
|
const option = document.createElement("option");
|
||||||
option.value = currency.value;
|
option.value = currency.value;
|
||||||
option.innerText = currency.label;
|
option.innerText = currency.label;
|
||||||
|
@@ -200,7 +200,6 @@ export class HaDataTable extends LitElement {
|
|||||||
Object.values(clonedColumns).forEach(
|
Object.values(clonedColumns).forEach(
|
||||||
(column: ClonedDataTableColumnData) => {
|
(column: ClonedDataTableColumnData) => {
|
||||||
delete column.title;
|
delete column.title;
|
||||||
delete column.type;
|
|
||||||
delete column.template;
|
delete column.template;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@@ -55,11 +55,16 @@ const sortData = (
|
|||||||
? b[column.valueColumn || sortColumn][column.filterKey]
|
? b[column.valueColumn || sortColumn][column.filterKey]
|
||||||
: b[column.valueColumn || sortColumn];
|
: b[column.valueColumn || sortColumn];
|
||||||
|
|
||||||
if (typeof valA === "string") {
|
if (column.type === "numeric") {
|
||||||
valA = valA.toUpperCase();
|
valA = isNaN(valA) ? undefined : Number(valA);
|
||||||
}
|
valB = isNaN(valB) ? undefined : Number(valB);
|
||||||
if (typeof valB === "string") {
|
} else {
|
||||||
valB = valB.toUpperCase();
|
if (typeof valA === "string") {
|
||||||
|
valA = valA.toUpperCase();
|
||||||
|
}
|
||||||
|
if (typeof valB === "string") {
|
||||||
|
valB = valB.toUpperCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure "undefined" is always sorted to the bottom
|
// Ensure "undefined" is always sorted to the bottom
|
||||||
|
@@ -5,7 +5,6 @@ import DateRangePicker from "vue2-daterange-picker";
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import dateRangePickerStyles from "vue2-daterange-picker/dist/vue2-daterange-picker.css";
|
import dateRangePickerStyles from "vue2-daterange-picker/dist/vue2-daterange-picker.css";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import { Constructor } from "../types";
|
|
||||||
|
|
||||||
const Component = Vue.extend({
|
const Component = Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
@@ -47,35 +46,26 @@ const Component = Vue.extend({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
render(createElement) {
|
render(createElement) {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
return createElement(DateRangePicker, {
|
return createElement(DateRangePicker, {
|
||||||
props: {
|
props: {
|
||||||
// @ts-ignore
|
|
||||||
"time-picker": this.timePicker,
|
"time-picker": this.timePicker,
|
||||||
// @ts-ignore
|
|
||||||
"auto-apply": this.autoApply,
|
"auto-apply": this.autoApply,
|
||||||
opens: "right",
|
opens: "right",
|
||||||
"show-dropdowns": false,
|
"show-dropdowns": false,
|
||||||
// @ts-ignore
|
|
||||||
"time-picker24-hour": this.twentyfourHours,
|
"time-picker24-hour": this.twentyfourHours,
|
||||||
// @ts-ignore
|
|
||||||
disabled: this.disabled,
|
disabled: this.disabled,
|
||||||
// @ts-ignore
|
|
||||||
ranges: this.ranges ? {} : false,
|
ranges: this.ranges ? {} : false,
|
||||||
"locale-data": {
|
"locale-data": {
|
||||||
// @ts-ignore
|
|
||||||
firstDay: this.firstDay,
|
firstDay: this.firstDay,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
model: {
|
model: {
|
||||||
value: {
|
value: {
|
||||||
// @ts-ignore
|
|
||||||
startDate: this.startDate,
|
startDate: this.startDate,
|
||||||
// @ts-ignore
|
|
||||||
endDate: this.endDate,
|
endDate: this.endDate,
|
||||||
},
|
},
|
||||||
callback: (value) => {
|
callback: (value) => {
|
||||||
// @ts-ignore
|
|
||||||
fireEvent(this.$el as HTMLElement, "change", value);
|
fireEvent(this.$el as HTMLElement, "change", value);
|
||||||
},
|
},
|
||||||
expression: "dateRange",
|
expression: "dateRange",
|
||||||
@@ -106,7 +96,11 @@ const Component = Vue.extend({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const WrappedElement: Constructor<HTMLElement> = wrap(Vue, Component);
|
// Assertion corrects HTMLElement type from package
|
||||||
|
const WrappedElement = wrap(
|
||||||
|
Vue,
|
||||||
|
Component
|
||||||
|
) as unknown as CustomElementConstructor;
|
||||||
|
|
||||||
@customElement("date-range-picker")
|
@customElement("date-range-picker")
|
||||||
class DateRangePickerElement extends WrappedElement {
|
class DateRangePickerElement extends WrappedElement {
|
||||||
|
@@ -189,7 +189,8 @@ export class HaAreaDevicesPicker extends SubscribeMixin(LitElement) {
|
|||||||
.sort((a, b) =>
|
.sort((a, b) =>
|
||||||
stringCompare(
|
stringCompare(
|
||||||
devicesByArea[a].name || "",
|
devicesByArea[a].name || "",
|
||||||
devicesByArea[b].name || ""
|
devicesByArea[b].name || "",
|
||||||
|
this.hass.locale.language
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.map((key) => devicesByArea[key]);
|
.map((key) => devicesByArea[key]);
|
||||||
|
@@ -84,6 +84,14 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
@property({ type: Array, attribute: "include-device-classes" })
|
@property({ type: Array, attribute: "include-device-classes" })
|
||||||
public includeDeviceClasses?: string[];
|
public includeDeviceClasses?: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of devices to be excluded.
|
||||||
|
* @type {Array}
|
||||||
|
* @attr exclude-devices
|
||||||
|
*/
|
||||||
|
@property({ type: Array, attribute: "exclude-devices" })
|
||||||
|
public excludeDevices?: string[];
|
||||||
|
|
||||||
@property() public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
@property() public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled?: boolean;
|
@property({ type: Boolean }) public disabled?: boolean;
|
||||||
@@ -104,7 +112,8 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
includeDomains: this["includeDomains"],
|
includeDomains: this["includeDomains"],
|
||||||
excludeDomains: this["excludeDomains"],
|
excludeDomains: this["excludeDomains"],
|
||||||
includeDeviceClasses: this["includeDeviceClasses"],
|
includeDeviceClasses: this["includeDeviceClasses"],
|
||||||
deviceFilter: this["deviceFilter"]
|
deviceFilter: this["deviceFilter"],
|
||||||
|
excludeDevices: this["excludeDevices"]
|
||||||
): Device[] => {
|
): Device[] => {
|
||||||
if (!devices.length) {
|
if (!devices.length) {
|
||||||
return [
|
return [
|
||||||
@@ -164,6 +173,12 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (excludeDevices) {
|
||||||
|
inputDevices = inputDevices.filter(
|
||||||
|
(device) => !excludeDevices!.includes(device.id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (includeDeviceClasses) {
|
if (includeDeviceClasses) {
|
||||||
inputDevices = inputDevices.filter((device) => {
|
inputDevices = inputDevices.filter((device) => {
|
||||||
const devEntities = deviceEntityLookup[device.id];
|
const devEntities = deviceEntityLookup[device.id];
|
||||||
@@ -216,7 +231,7 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
return outputDevices;
|
return outputDevices;
|
||||||
}
|
}
|
||||||
return outputDevices.sort((a, b) =>
|
return outputDevices.sort((a, b) =>
|
||||||
stringCompare(a.name || "", b.name || "")
|
stringCompare(a.name || "", b.name || "", this.hass.locale.language)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -258,7 +273,8 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
this.includeDomains,
|
this.includeDomains,
|
||||||
this.excludeDomains,
|
this.excludeDomains,
|
||||||
this.includeDeviceClasses,
|
this.includeDeviceClasses,
|
||||||
this.deviceFilter
|
this.deviceFilter,
|
||||||
|
this.excludeDevices
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
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, TemplateResult } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import memoizeOne from "memoize-one";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { isValidEntityId } from "../../common/entity/valid_entity_id";
|
import { isValidEntityId } from "../../common/entity/valid_entity_id";
|
||||||
import type { PolymerChangedEvent } from "../../polymer-types";
|
import type { PolymerChangedEvent } from "../../polymer-types";
|
||||||
@@ -95,7 +96,10 @@ class HaEntitiesPickerLight extends LitElement {
|
|||||||
.excludeEntities=${this.excludeEntities}
|
.excludeEntities=${this.excludeEntities}
|
||||||
.includeDeviceClasses=${this.includeDeviceClasses}
|
.includeDeviceClasses=${this.includeDeviceClasses}
|
||||||
.includeUnitOfMeasurement=${this.includeUnitOfMeasurement}
|
.includeUnitOfMeasurement=${this.includeUnitOfMeasurement}
|
||||||
.entityFilter=${this._entityFilter}
|
.entityFilter=${this._getEntityFilter(
|
||||||
|
this.value,
|
||||||
|
this.entityFilter
|
||||||
|
)}
|
||||||
.value=${entityId}
|
.value=${entityId}
|
||||||
.label=${this.pickedEntityLabel}
|
.label=${this.pickedEntityLabel}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
@@ -114,7 +118,7 @@ class HaEntitiesPickerLight extends LitElement {
|
|||||||
.excludeEntities=${this.excludeEntities}
|
.excludeEntities=${this.excludeEntities}
|
||||||
.includeDeviceClasses=${this.includeDeviceClasses}
|
.includeDeviceClasses=${this.includeDeviceClasses}
|
||||||
.includeUnitOfMeasurement=${this.includeUnitOfMeasurement}
|
.includeUnitOfMeasurement=${this.includeUnitOfMeasurement}
|
||||||
.entityFilter=${this._entityFilter}
|
.entityFilter=${this._getEntityFilter(this.value, this.entityFilter)}
|
||||||
.label=${this.pickEntityLabel}
|
.label=${this.pickEntityLabel}
|
||||||
.helper=${this.helper}
|
.helper=${this.helper}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
@@ -125,11 +129,15 @@ class HaEntitiesPickerLight extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _entityFilter: HaEntityPickerEntityFilterFunc = (
|
private _getEntityFilter = memoizeOne(
|
||||||
stateObj: HassEntity
|
(
|
||||||
) =>
|
value: string[] | undefined,
|
||||||
(!this.value || !this.value.includes(stateObj.entity_id)) &&
|
entityFilter: HaEntityPickerEntityFilterFunc | undefined
|
||||||
(!this.entityFilter || this.entityFilter(stateObj));
|
): HaEntityPickerEntityFilterFunc =>
|
||||||
|
(stateObj: HassEntity) =>
|
||||||
|
(!value || !value.includes(stateObj.entity_id)) &&
|
||||||
|
(!entityFilter || entityFilter(stateObj))
|
||||||
|
);
|
||||||
|
|
||||||
private get _currentEntities() {
|
private get _currentEntities() {
|
||||||
return this.value || [];
|
return this.value || [];
|
||||||
|
@@ -174,7 +174,8 @@ export class HaEntityPicker extends LitElement {
|
|||||||
.sort((entityA, entityB) =>
|
.sort((entityA, entityB) =>
|
||||||
caseInsensitiveStringCompare(
|
caseInsensitiveStringCompare(
|
||||||
entityA.friendly_name,
|
entityA.friendly_name,
|
||||||
entityB.friendly_name
|
entityB.friendly_name,
|
||||||
|
this.hass.locale.language
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -205,7 +206,8 @@ export class HaEntityPicker extends LitElement {
|
|||||||
.sort((entityA, entityB) =>
|
.sort((entityA, entityB) =>
|
||||||
caseInsensitiveStringCompare(
|
caseInsensitiveStringCompare(
|
||||||
entityA.friendly_name,
|
entityA.friendly_name,
|
||||||
entityB.friendly_name
|
entityB.friendly_name,
|
||||||
|
this.hass.locale.language
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ import { property, state } from "lit/decorators";
|
|||||||
import { STATES_OFF } from "../../common/const";
|
import { STATES_OFF } from "../../common/const";
|
||||||
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
||||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||||
import { UNAVAILABLE, UNAVAILABLE_STATES, UNKNOWN } from "../../data/entity";
|
import { isUnavailableState, UNAVAILABLE, UNKNOWN } from "../../data/entity";
|
||||||
import { forwardHaptic } from "../../data/haptics";
|
import { forwardHaptic } from "../../data/haptics";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import "../ha-formfield";
|
import "../ha-formfield";
|
||||||
@@ -22,7 +22,7 @@ import "../ha-switch";
|
|||||||
const isOn = (stateObj?: HassEntity) =>
|
const isOn = (stateObj?: HassEntity) =>
|
||||||
stateObj !== undefined &&
|
stateObj !== undefined &&
|
||||||
!STATES_OFF.includes(stateObj.state) &&
|
!STATES_OFF.includes(stateObj.state) &&
|
||||||
!UNAVAILABLE_STATES.includes(stateObj.state);
|
!isUnavailableState(stateObj.state);
|
||||||
|
|
||||||
export class HaEntityToggle extends LitElement {
|
export class HaEntityToggle extends LitElement {
|
||||||
// hass is not a property so that we only re-render on stateObj changes
|
// hass is not a property so that we only re-render on stateObj changes
|
||||||
|
@@ -10,21 +10,46 @@ import {
|
|||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
|
import { arrayLiteralIncludes } from "../../common/array/literal-includes";
|
||||||
import secondsToDuration from "../../common/datetime/seconds_to_duration";
|
import secondsToDuration from "../../common/datetime/seconds_to_duration";
|
||||||
import { computeStateDisplay } from "../../common/entity/compute_state_display";
|
import { computeStateDisplay } from "../../common/entity/compute_state_display";
|
||||||
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
||||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||||
|
import { FIXED_DOMAIN_STATES } from "../../common/entity/get_states";
|
||||||
import {
|
import {
|
||||||
formatNumber,
|
formatNumber,
|
||||||
getNumberFormatOptions,
|
getNumberFormatOptions,
|
||||||
isNumericState,
|
isNumericState,
|
||||||
} from "../../common/number/format_number";
|
} from "../../common/number/format_number";
|
||||||
import { UNAVAILABLE, UNKNOWN } from "../../data/entity";
|
import { isUnavailableState, UNAVAILABLE, UNKNOWN } from "../../data/entity";
|
||||||
|
import { EntityRegistryEntry } 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";
|
||||||
import "../ha-state-icon";
|
import "../ha-state-icon";
|
||||||
|
|
||||||
|
// Define the domains whose states have special truncated strings
|
||||||
|
const TRUNCATED_DOMAINS = [
|
||||||
|
"alarm_control_panel",
|
||||||
|
"device_tracker",
|
||||||
|
"person",
|
||||||
|
] as const satisfies ReadonlyArray<keyof typeof FIXED_DOMAIN_STATES>;
|
||||||
|
|
||||||
|
type TruncatedDomain = (typeof TRUNCATED_DOMAINS)[number];
|
||||||
|
type TruncatedKey = {
|
||||||
|
[T in TruncatedDomain]: `${T}.${(typeof FIXED_DOMAIN_STATES)[T][number]}`;
|
||||||
|
}[TruncatedDomain];
|
||||||
|
|
||||||
|
const getTruncatedKey = (domainKey: string, stateKey: string) => {
|
||||||
|
if (
|
||||||
|
arrayLiteralIncludes(TRUNCATED_DOMAINS)(domainKey) &&
|
||||||
|
arrayLiteralIncludes(FIXED_DOMAIN_STATES[domainKey])(stateKey)
|
||||||
|
) {
|
||||||
|
return `${domainKey}.${stateKey}` as TruncatedKey;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
@customElement("ha-state-label-badge")
|
@customElement("ha-state-label-badge")
|
||||||
export class HaStateLabelBadge extends LitElement {
|
export class HaStateLabelBadge extends LitElement {
|
||||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||||
@@ -79,8 +104,10 @@ export class HaStateLabelBadge extends LitElement {
|
|||||||
// 4. Icon determined via entity state
|
// 4. Icon determined via entity state
|
||||||
// 5. Value string as fallback
|
// 5. Value string as fallback
|
||||||
const domain = computeStateDomain(entityState);
|
const domain = computeStateDomain(entityState);
|
||||||
|
const entry = this.hass?.entities[entityState.entity_id];
|
||||||
|
|
||||||
const showIcon = this.icon || this._computeShowIcon(domain, entityState);
|
const showIcon =
|
||||||
|
this.icon || this._computeShowIcon(domain, entityState, entry);
|
||||||
const image = this.icon
|
const image = this.icon
|
||||||
? ""
|
? ""
|
||||||
: this.image
|
: this.image
|
||||||
@@ -88,7 +115,9 @@ export class HaStateLabelBadge extends LitElement {
|
|||||||
: entityState.attributes.entity_picture_local ||
|
: entityState.attributes.entity_picture_local ||
|
||||||
entityState.attributes.entity_picture;
|
entityState.attributes.entity_picture;
|
||||||
const value =
|
const value =
|
||||||
!image && !showIcon ? this._computeValue(domain, entityState) : undefined;
|
!image && !showIcon
|
||||||
|
? this._computeValue(domain, entityState, entry)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-label-badge
|
<ha-label-badge
|
||||||
@@ -128,7 +157,11 @@ export class HaStateLabelBadge extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _computeValue(domain: string, entityState: HassEntity) {
|
private _computeValue(
|
||||||
|
domain: string,
|
||||||
|
entityState: HassEntity,
|
||||||
|
entry?: EntityRegistryEntry
|
||||||
|
) {
|
||||||
switch (domain) {
|
switch (domain) {
|
||||||
case "alarm_control_panel":
|
case "alarm_control_panel":
|
||||||
case "binary_sensor":
|
case "binary_sensor":
|
||||||
@@ -141,7 +174,7 @@ export class HaStateLabelBadge extends LitElement {
|
|||||||
return null;
|
return null;
|
||||||
// @ts-expect-error we don't break and go to default
|
// @ts-expect-error we don't break and go to default
|
||||||
case "sensor":
|
case "sensor":
|
||||||
if (entityState.attributes.device_class === "moon__phase") {
|
if (entry?.platform === "moon") {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line: disable=no-fallthrough
|
// eslint-disable-next-line: disable=no-fallthrough
|
||||||
@@ -164,7 +197,11 @@ export class HaStateLabelBadge extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _computeShowIcon(domain: string, entityState: HassEntity): boolean {
|
private _computeShowIcon(
|
||||||
|
domain: string,
|
||||||
|
entityState: HassEntity,
|
||||||
|
entry?: EntityRegistryEntry
|
||||||
|
): boolean {
|
||||||
if (entityState.state === UNAVAILABLE) {
|
if (entityState.state === UNAVAILABLE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -180,25 +217,28 @@ export class HaStateLabelBadge extends LitElement {
|
|||||||
case "timer":
|
case "timer":
|
||||||
return true;
|
return true;
|
||||||
case "sensor":
|
case "sensor":
|
||||||
return entityState.attributes.device_class === "moon__phase";
|
return entry?.platform === "moon";
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _computeLabel(domain, entityState, _timerTimeRemaining) {
|
private _computeLabel(
|
||||||
if (
|
domain: string,
|
||||||
entityState.state === UNAVAILABLE ||
|
entityState: HassEntity,
|
||||||
["device_tracker", "alarm_control_panel", "person"].includes(domain)
|
_timerTimeRemaining = 0
|
||||||
) {
|
) {
|
||||||
// Localize the state with a special state_badge namespace, which has variations of
|
// For unavailable states or certain domains, use a special translation that is truncated to fit within the badge label
|
||||||
// the state translations that are truncated to fit within the badge label. Translations
|
if (isUnavailableState(entityState.state)) {
|
||||||
// are only added for device_tracker, alarm_control_panel and person.
|
return this.hass!.localize(`state_badge.default.${entityState.state}`);
|
||||||
return (
|
}
|
||||||
this.hass!.localize(`state_badge.${domain}.${entityState.state}`) ||
|
const domainStateKey = getTruncatedKey(domain, entityState.state);
|
||||||
this.hass!.localize(`state_badge.default.${entityState.state}`) ||
|
if (domainStateKey) {
|
||||||
entityState.state
|
return this.hass!.localize(`state_badge.${domainStateKey}`);
|
||||||
);
|
}
|
||||||
|
// Person and device tracker state can be zone name
|
||||||
|
if (domain === "person" || domain === "device_tracker") {
|
||||||
|
return entityState.state;
|
||||||
}
|
}
|
||||||
if (domain === "timer") {
|
if (domain === "timer") {
|
||||||
return secondsToDuration(_timerTimeRemaining);
|
return secondsToDuration(_timerTimeRemaining);
|
||||||
|
@@ -177,7 +177,9 @@ export class HaStatisticPicker extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (output.length > 1) {
|
if (output.length > 1) {
|
||||||
output.sort((a, b) => stringCompare(a.name || "", b.name || ""));
|
output.sort((a, b) =>
|
||||||
|
stringCompare(a.name || "", b.name || "", this.hass.locale.language)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
output.push({
|
output.push({
|
||||||
|
@@ -11,13 +11,12 @@ import {
|
|||||||
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";
|
||||||
import { styleMap } from "lit/directives/style-map";
|
import { styleMap } from "lit/directives/style-map";
|
||||||
import { CLIMATE_HVAC_ACTION_COLORS } from "../../common/entity/color/climate_color";
|
|
||||||
import { computeDomain } from "../../common/entity/compute_domain";
|
import { computeDomain } from "../../common/entity/compute_domain";
|
||||||
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
||||||
import { stateActive } from "../../common/entity/state_active";
|
|
||||||
import { stateColorCss } from "../../common/entity/state_color";
|
import { stateColorCss } from "../../common/entity/state_color";
|
||||||
import { iconColorCSS } from "../../common/style/icon_color_css";
|
import { iconColorCSS } from "../../common/style/icon_color_css";
|
||||||
import { cameraUrlWithWidthHeight } from "../../data/camera";
|
import { cameraUrlWithWidthHeight } from "../../data/camera";
|
||||||
|
import { HVAC_ACTION_TO_MODE } from "../../data/climate";
|
||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
import "../ha-state-icon";
|
import "../ha-state-icon";
|
||||||
|
|
||||||
@@ -32,6 +31,8 @@ export class StateBadge extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public stateColor?: boolean;
|
@property({ type: Boolean }) public stateColor?: boolean;
|
||||||
|
|
||||||
|
@property() public color?: string;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true, attribute: "icon" })
|
@property({ type: Boolean, reflect: true, attribute: "icon" })
|
||||||
private _showIcon = true;
|
private _showIcon = true;
|
||||||
|
|
||||||
@@ -75,7 +76,8 @@ export class StateBadge extends LitElement {
|
|||||||
!changedProps.has("stateObj") &&
|
!changedProps.has("stateObj") &&
|
||||||
!changedProps.has("overrideImage") &&
|
!changedProps.has("overrideImage") &&
|
||||||
!changedProps.has("overrideIcon") &&
|
!changedProps.has("overrideIcon") &&
|
||||||
!changedProps.has("stateColor")
|
!changedProps.has("stateColor") &&
|
||||||
|
!changedProps.has("color")
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -106,10 +108,13 @@ export class StateBadge extends LitElement {
|
|||||||
}
|
}
|
||||||
hostStyle.backgroundImage = `url(${imageUrl})`;
|
hostStyle.backgroundImage = `url(${imageUrl})`;
|
||||||
this._showIcon = false;
|
this._showIcon = false;
|
||||||
} else if (this._stateColor && stateActive(stateObj)) {
|
} else if (this.color) {
|
||||||
|
// Externally provided overriding color wins over state color
|
||||||
|
iconStyle.color = this.color;
|
||||||
|
} else if (this._stateColor) {
|
||||||
const color = stateColorCss(stateObj);
|
const color = stateColorCss(stateObj);
|
||||||
if (color) {
|
if (color) {
|
||||||
iconStyle.color = `rgb(${color})`;
|
iconStyle.color = color;
|
||||||
}
|
}
|
||||||
if (stateObj.attributes.rgb_color) {
|
if (stateObj.attributes.rgb_color) {
|
||||||
iconStyle.color = `rgb(${stateObj.attributes.rgb_color.join(",")})`;
|
iconStyle.color = `rgb(${stateObj.attributes.rgb_color.join(",")})`;
|
||||||
@@ -128,8 +133,11 @@ 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"].includes(hvacAction)) {
|
if (["heating", "cooling", "drying", "fan"].includes(hvacAction)) {
|
||||||
iconStyle.color = `rgb(${CLIMATE_HVAC_ACTION_COLORS[hvacAction]})`;
|
iconStyle.color = stateColorCss(
|
||||||
|
stateObj,
|
||||||
|
HVAC_ACTION_TO_MODE[hvacAction]
|
||||||
|
)!;
|
||||||
} else {
|
} else {
|
||||||
delete iconStyle.color;
|
delete iconStyle.color;
|
||||||
}
|
}
|
||||||
@@ -164,6 +172,7 @@ export class StateBadge extends LitElement {
|
|||||||
line-height: 40px;
|
line-height: 40px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
--state-inactive-color: initial;
|
||||||
}
|
}
|
||||||
:host(:focus) {
|
:host(:focus) {
|
||||||
outline: none;
|
outline: none;
|
||||||
|
@@ -19,6 +19,8 @@ class StateInfo extends LitElement {
|
|||||||
// property used only in CSS
|
// property used only in CSS
|
||||||
@property({ type: Boolean, reflect: true }) public rtl = false;
|
@property({ type: Boolean, reflect: true }) public rtl = false;
|
||||||
|
|
||||||
|
@property() public color?: string;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
if (!this.hass || !this.stateObj) {
|
if (!this.hass || !this.stateObj) {
|
||||||
return html``;
|
return html``;
|
||||||
@@ -29,6 +31,7 @@ class StateInfo extends LitElement {
|
|||||||
return html`<state-badge
|
return html`<state-badge
|
||||||
.stateObj=${this.stateObj}
|
.stateObj=${this.stateObj}
|
||||||
.stateColor=${true}
|
.stateColor=${true}
|
||||||
|
.color=${this.color}
|
||||||
></state-badge>
|
></state-badge>
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<div class="name" .title=${name} .inDialog=${this.inDialog}>
|
<div class="name" .title=${name} .inDialog=${this.inDialog}>
|
||||||
|
@@ -16,7 +16,11 @@ const rowRenderer: ComboBoxLitRenderer<HassioAddonInfo> = (
|
|||||||
<span>${item.name}</span>
|
<span>${item.name}</span>
|
||||||
<span slot="secondary">${item.slug}</span>
|
<span slot="secondary">${item.slug}</span>
|
||||||
${item.icon
|
${item.icon
|
||||||
? html`<img slot="graphic" .src="/api/hassio/addons/${item.slug}/icon" />`
|
? html`<img
|
||||||
|
alt=""
|
||||||
|
slot="graphic"
|
||||||
|
.src="/api/hassio/addons/${item.slug}/icon"
|
||||||
|
/>`
|
||||||
: ""}
|
: ""}
|
||||||
</mwc-list-item>`;
|
</mwc-list-item>`;
|
||||||
|
|
||||||
@@ -80,7 +84,9 @@ class HaAddonPicker extends LitElement {
|
|||||||
const addonsInfo = await fetchHassioAddonsInfo(this.hass);
|
const addonsInfo = await fetchHassioAddonsInfo(this.hass);
|
||||||
this._addons = addonsInfo.addons
|
this._addons = addonsInfo.addons
|
||||||
.filter((addon) => addon.version)
|
.filter((addon) => addon.version)
|
||||||
.sort((a, b) => stringCompare(a.name, b.name));
|
.sort((a, b) =>
|
||||||
|
stringCompare(a.name, b.name, this.hass.locale.language)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
title: this.hass.localize(
|
title: this.hass.localize(
|
||||||
|
@@ -73,6 +73,14 @@ export class HaAreaPicker extends LitElement {
|
|||||||
@property({ type: Array, attribute: "include-device-classes" })
|
@property({ type: Array, attribute: "include-device-classes" })
|
||||||
public includeDeviceClasses?: string[];
|
public includeDeviceClasses?: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of areas to be excluded.
|
||||||
|
* @type {Array}
|
||||||
|
* @attr exclude-areas
|
||||||
|
*/
|
||||||
|
@property({ type: Array, attribute: "exclude-areas" })
|
||||||
|
public excludeAreas?: string[];
|
||||||
|
|
||||||
@property() public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
@property() public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||||
|
|
||||||
@property() public entityFilter?: (entity: EntityRegistryEntry) => boolean;
|
@property() public entityFilter?: (entity: EntityRegistryEntry) => boolean;
|
||||||
@@ -109,7 +117,8 @@ export class HaAreaPicker extends LitElement {
|
|||||||
includeDeviceClasses: this["includeDeviceClasses"],
|
includeDeviceClasses: this["includeDeviceClasses"],
|
||||||
deviceFilter: this["deviceFilter"],
|
deviceFilter: this["deviceFilter"],
|
||||||
entityFilter: this["entityFilter"],
|
entityFilter: this["entityFilter"],
|
||||||
noAdd: this["noAdd"]
|
noAdd: this["noAdd"],
|
||||||
|
excludeAreas: this["excludeAreas"]
|
||||||
): AreaRegistryEntry[] => {
|
): AreaRegistryEntry[] => {
|
||||||
if (!areas.length) {
|
if (!areas.length) {
|
||||||
return [
|
return [
|
||||||
@@ -117,6 +126,7 @@ export class HaAreaPicker extends LitElement {
|
|||||||
area_id: "no_areas",
|
area_id: "no_areas",
|
||||||
name: this.hass.localize("ui.components.area-picker.no_areas"),
|
name: this.hass.localize("ui.components.area-picker.no_areas"),
|
||||||
picture: null,
|
picture: null,
|
||||||
|
aliases: [],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -235,12 +245,19 @@ export class HaAreaPicker extends LitElement {
|
|||||||
outputAreas = areas.filter((area) => areaIds!.includes(area.area_id));
|
outputAreas = areas.filter((area) => areaIds!.includes(area.area_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (excludeAreas) {
|
||||||
|
outputAreas = outputAreas.filter(
|
||||||
|
(area) => !excludeAreas!.includes(area.area_id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!outputAreas.length) {
|
if (!outputAreas.length) {
|
||||||
outputAreas = [
|
outputAreas = [
|
||||||
{
|
{
|
||||||
area_id: "no_areas",
|
area_id: "no_areas",
|
||||||
name: this.hass.localize("ui.components.area-picker.no_match"),
|
name: this.hass.localize("ui.components.area-picker.no_match"),
|
||||||
picture: null,
|
picture: null,
|
||||||
|
aliases: [],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -253,6 +270,7 @@ export class HaAreaPicker extends LitElement {
|
|||||||
area_id: "add_new",
|
area_id: "add_new",
|
||||||
name: this.hass.localize("ui.components.area-picker.add_new"),
|
name: this.hass.localize("ui.components.area-picker.add_new"),
|
||||||
picture: null,
|
picture: null,
|
||||||
|
aliases: [],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -264,7 +282,7 @@ export class HaAreaPicker extends LitElement {
|
|||||||
(this._init && changedProps.has("_opened") && this._opened)
|
(this._init && changedProps.has("_opened") && this._opened)
|
||||||
) {
|
) {
|
||||||
this._init = true;
|
this._init = true;
|
||||||
(this.comboBox as any).items = this._getAreas(
|
const areas = this._getAreas(
|
||||||
Object.values(this.hass.areas),
|
Object.values(this.hass.areas),
|
||||||
Object.values(this.hass.devices),
|
Object.values(this.hass.devices),
|
||||||
Object.values(this.hass.entities),
|
Object.values(this.hass.entities),
|
||||||
@@ -273,8 +291,11 @@ export class HaAreaPicker extends LitElement {
|
|||||||
this.includeDeviceClasses,
|
this.includeDeviceClasses,
|
||||||
this.deviceFilter,
|
this.deviceFilter,
|
||||||
this.entityFilter,
|
this.entityFilter,
|
||||||
this.noAdd
|
this.noAdd,
|
||||||
|
this.excludeAreas
|
||||||
);
|
);
|
||||||
|
(this.comboBox as any).items = areas;
|
||||||
|
(this.comboBox as any).filteredItems = areas;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,7 +405,8 @@ export class HaAreaPicker extends LitElement {
|
|||||||
this.includeDeviceClasses,
|
this.includeDeviceClasses,
|
||||||
this.deviceFilter,
|
this.deviceFilter,
|
||||||
this.entityFilter,
|
this.entityFilter,
|
||||||
this.noAdd
|
this.noAdd,
|
||||||
|
this.excludeAreas
|
||||||
);
|
);
|
||||||
await this.updateComplete;
|
await this.updateComplete;
|
||||||
await this.comboBox.updateComplete;
|
await this.comboBox.updateComplete;
|
||||||
|
@@ -271,12 +271,18 @@ export class HaBarSlider extends LitElement {
|
|||||||
return css`
|
return css`
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
--slider-bar-color: rgb(var(--rgb-primary-color));
|
--slider-bar-color: var(--primary-color);
|
||||||
--slider-bar-background: rgba(var(--rgb-disabled-color), 0.2);
|
--slider-bar-background: var(--disabled-color);
|
||||||
|
--slider-bar-background-opacity: 0.2;
|
||||||
--slider-bar-thickness: 40px;
|
--slider-bar-thickness: 40px;
|
||||||
--slider-bar-border-radius: 10px;
|
--slider-bar-border-radius: 10px;
|
||||||
height: var(--slider-bar-thickness);
|
height: var(--slider-bar-thickness);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
border-radius: var(--slider-bar-border-radius);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
:host(:focus-visible) {
|
||||||
|
box-shadow: 0 0 0 2px var(--slider-bar-color);
|
||||||
}
|
}
|
||||||
:host([vertical]) {
|
:host([vertical]) {
|
||||||
width: var(--slider-bar-thickness);
|
width: var(--slider-bar-thickness);
|
||||||
@@ -301,6 +307,7 @@ export class HaBarSlider extends LitElement {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: var(--slider-bar-background);
|
background: var(--slider-bar-background);
|
||||||
|
opacity: var(--slider-bar-background-opacity);
|
||||||
}
|
}
|
||||||
.slider .slider-track-bar {
|
.slider .slider-track-bar {
|
||||||
--border-radius: var(--slider-bar-border-radius);
|
--border-radius: var(--slider-bar-border-radius);
|
||||||
@@ -394,7 +401,7 @@ export class HaBarSlider extends LitElement {
|
|||||||
.slider .slider-track-cursor:after {
|
.slider .slider-track-cursor:after {
|
||||||
display: block;
|
display: block;
|
||||||
content: "";
|
content: "";
|
||||||
background-color: rgb(var(--rgb-secondary-text-color));
|
background-color: var(--secondary-text-color);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
@@ -74,6 +74,7 @@ export class HaBarSwitch extends LitElement {
|
|||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<div class="switch">
|
<div class="switch">
|
||||||
|
<div class="background"></div>
|
||||||
<div class="button" aria-hidden="true">
|
<div class="button" aria-hidden="true">
|
||||||
${this.checked
|
${this.checked
|
||||||
? this.pathOn
|
? this.pathOn
|
||||||
@@ -91,8 +92,9 @@ export class HaBarSwitch extends LitElement {
|
|||||||
return css`
|
return css`
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
--switch-bar-color-on: var(--rgb-primary-color);
|
--switch-bar-on-color: var(--primary-color);
|
||||||
--switch-bar-color-off: var(--rgb-disabled-color);
|
--switch-bar-off-color: var(--disabled-color);
|
||||||
|
--switch-bar-background-opacity: 0.2;
|
||||||
--switch-bar-thickness: 40px;
|
--switch-bar-thickness: 40px;
|
||||||
--switch-bar-border-radius: 12px;
|
--switch-bar-border-radius: 12px;
|
||||||
--switch-bar-padding: 4px;
|
--switch-bar-padding: 4px;
|
||||||
@@ -102,6 +104,14 @@ export class HaBarSwitch extends LitElement {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
border-radius: var(--switch-bar-border-radius);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
:host(:focus-visible) {
|
||||||
|
box-shadow: 0 0 0 2px var(--switch-bar-off-color);
|
||||||
|
}
|
||||||
|
:host([checked]:focus-visible) {
|
||||||
|
box-shadow: 0 0 0 2px var(--switch-bar-on-color);
|
||||||
}
|
}
|
||||||
.switch {
|
.switch {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -109,11 +119,20 @@ export class HaBarSwitch extends LitElement {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-radius: var(--switch-bar-border-radius);
|
border-radius: var(--switch-bar-border-radius);
|
||||||
background-color: rgba(var(--switch-bar-color-off), 0.3);
|
overflow: hidden;
|
||||||
padding: var(--switch-bar-padding);
|
padding: var(--switch-bar-padding);
|
||||||
transition: background-color 180ms ease-in-out;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
.switch .background {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
background-color: var(--switch-bar-off-color);
|
||||||
|
transition: background-color 180ms ease-in-out;
|
||||||
|
opacity: var(--switch-bar-background-opacity);
|
||||||
|
}
|
||||||
.switch .button {
|
.switch .button {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -123,18 +142,18 @@ export class HaBarSwitch extends LitElement {
|
|||||||
);
|
);
|
||||||
transition: transform 180ms ease-in-out,
|
transition: transform 180ms ease-in-out,
|
||||||
background-color 180ms ease-in-out;
|
background-color 180ms ease-in-out;
|
||||||
background-color: rgb(var(--switch-bar-color-off));
|
background-color: var(--switch-bar-off-color);
|
||||||
color: white;
|
color: white;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
:host([checked]) .switch {
|
:host([checked]) .switch .background {
|
||||||
background-color: rgba(var(--switch-bar-color-on), 0.3);
|
background-color: var(--switch-bar-on-color);
|
||||||
}
|
}
|
||||||
:host([checked]) .switch .button {
|
:host([checked]) .switch .button {
|
||||||
transform: translateX(100%);
|
transform: translateX(100%);
|
||||||
background-color: rgb(var(--switch-bar-color-on));
|
background-color: var(--switch-bar-on-color);
|
||||||
}
|
}
|
||||||
:host([reversed]) .switch {
|
:host([reversed]) .switch {
|
||||||
flex-direction: row-reverse;
|
flex-direction: row-reverse;
|
||||||
|
@@ -266,6 +266,9 @@ export class HaBaseTimeInput extends LitElement {
|
|||||||
seconds: this.seconds,
|
seconds: this.seconds,
|
||||||
milliseconds: this.milliseconds,
|
milliseconds: this.milliseconds,
|
||||||
};
|
};
|
||||||
|
if (this.enableDay) {
|
||||||
|
value.days = this.days;
|
||||||
|
}
|
||||||
if (this.format === 12) {
|
if (this.format === 12) {
|
||||||
value.amPm = this.amPm;
|
value.amPm = this.amPm;
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,9 @@ class HaBluePrintPicker extends LitElement {
|
|||||||
...(blueprint as Blueprint).metadata,
|
...(blueprint as Blueprint).metadata,
|
||||||
path,
|
path,
|
||||||
}));
|
}));
|
||||||
return result.sort((a, b) => stringCompare(a.name, b.name));
|
return result.sort((a, b) =>
|
||||||
|
stringCompare(a.name, b.name, this.hass!.locale.language)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
|
@@ -1,37 +1,42 @@
|
|||||||
import { HassEntity } from "home-assistant-js-websocket";
|
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import { computeAttributeValueDisplay } from "../common/entity/compute_attribute_display";
|
||||||
|
import { computeStateDisplay } from "../common/entity/compute_state_display";
|
||||||
import { formatNumber } from "../common/number/format_number";
|
import { formatNumber } from "../common/number/format_number";
|
||||||
import { CLIMATE_PRESET_NONE } from "../data/climate";
|
import { blankBeforePercent } from "../common/translations/blank_before_percent";
|
||||||
import { UNAVAILABLE_STATES } from "../data/entity";
|
import { ClimateEntity, CLIMATE_PRESET_NONE } from "../data/climate";
|
||||||
|
import { isUnavailableState } from "../data/entity";
|
||||||
import type { HomeAssistant } from "../types";
|
import type { HomeAssistant } from "../types";
|
||||||
|
|
||||||
@customElement("ha-climate-state")
|
@customElement("ha-climate-state")
|
||||||
class HaClimateState extends LitElement {
|
class HaClimateState extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property({ attribute: false }) public stateObj!: HassEntity;
|
@property({ attribute: false }) public stateObj!: ClimateEntity;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
const currentStatus = this._computeCurrentStatus();
|
const currentStatus = this._computeCurrentStatus();
|
||||||
|
|
||||||
return html`<div class="target">
|
return html`<div class="target">
|
||||||
${!UNAVAILABLE_STATES.includes(this.stateObj.state)
|
${!isUnavailableState(this.stateObj.state)
|
||||||
? html`<span class="state-label">
|
? html`<span class="state-label">
|
||||||
${this._localizeState()}
|
${this._localizeState()}
|
||||||
${this.stateObj.attributes.preset_mode &&
|
${this.stateObj.attributes.preset_mode &&
|
||||||
this.stateObj.attributes.preset_mode !== CLIMATE_PRESET_NONE
|
this.stateObj.attributes.preset_mode !== CLIMATE_PRESET_NONE
|
||||||
? html`-
|
? html`-
|
||||||
${this.hass.localize(
|
${computeAttributeValueDisplay(
|
||||||
`state_attributes.climate.preset_mode.${this.stateObj.attributes.preset_mode}`
|
this.hass.localize,
|
||||||
) || this.stateObj.attributes.preset_mode}`
|
this.stateObj,
|
||||||
|
this.hass.entities,
|
||||||
|
"preset_mode"
|
||||||
|
)}`
|
||||||
: ""}
|
: ""}
|
||||||
</span>
|
</span>
|
||||||
<div class="unit">${this._computeTarget()}</div>`
|
<div class="unit">${this._computeTarget()}</div>`
|
||||||
: this._localizeState()}
|
: this._localizeState()}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
${currentStatus && !UNAVAILABLE_STATES.includes(this.stateObj.state)
|
${currentStatus && !isUnavailableState(this.stateObj.state)
|
||||||
? html`<div class="current">
|
? html`<div class="current">
|
||||||
${this.hass.localize("ui.card.climate.currently")}:
|
${this.hass.localize("ui.card.climate.currently")}:
|
||||||
<div class="unit">${currentStatus}</div>
|
<div class="unit">${currentStatus}</div>
|
||||||
@@ -43,6 +48,19 @@ class HaClimateState extends LitElement {
|
|||||||
if (!this.hass || !this.stateObj) {
|
if (!this.hass || !this.stateObj) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
this.stateObj.attributes.current_temperature != null &&
|
||||||
|
this.stateObj.attributes.current_humidity != null
|
||||||
|
) {
|
||||||
|
return `${formatNumber(
|
||||||
|
this.stateObj.attributes.current_temperature,
|
||||||
|
this.hass.locale
|
||||||
|
)} ${this.hass.config.unit_system.temperature}/
|
||||||
|
${formatNumber(
|
||||||
|
this.stateObj.attributes.current_humidity,
|
||||||
|
this.hass.locale
|
||||||
|
)}${blankBeforePercent(this.hass.locale)}%`;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.stateObj.attributes.current_temperature != null) {
|
if (this.stateObj.attributes.current_temperature != null) {
|
||||||
return `${formatNumber(
|
return `${formatNumber(
|
||||||
@@ -55,7 +73,7 @@ class HaClimateState extends LitElement {
|
|||||||
return `${formatNumber(
|
return `${formatNumber(
|
||||||
this.stateObj.attributes.current_humidity,
|
this.stateObj.attributes.current_humidity,
|
||||||
this.hass.locale
|
this.hass.locale
|
||||||
)} %`;
|
)}${blankBeforePercent(this.hass.locale)}%`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -109,17 +127,23 @@ class HaClimateState extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _localizeState(): string {
|
private _localizeState(): string {
|
||||||
if (UNAVAILABLE_STATES.includes(this.stateObj.state)) {
|
if (isUnavailableState(this.stateObj.state)) {
|
||||||
return this.hass.localize(`state.default.${this.stateObj.state}`);
|
return this.hass.localize(`state.default.${this.stateObj.state}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const stateString = this.hass.localize(
|
const stateString = computeStateDisplay(
|
||||||
`component.climate.state._.${this.stateObj.state}`
|
this.hass.localize,
|
||||||
|
this.stateObj,
|
||||||
|
this.hass.locale,
|
||||||
|
this.hass.entities
|
||||||
);
|
);
|
||||||
|
|
||||||
return this.stateObj.attributes.hvac_action
|
return this.stateObj.attributes.hvac_action
|
||||||
? `${this.hass.localize(
|
? `${computeAttributeValueDisplay(
|
||||||
`state_attributes.climate.hvac_action.${this.stateObj.attributes.hvac_action}`
|
this.hass.localize,
|
||||||
|
this.stateObj,
|
||||||
|
this.hass.entities,
|
||||||
|
"hvac_action"
|
||||||
)} (${stateString})`
|
)} (${stateString})`
|
||||||
: stateString;
|
: stateString;
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@ import type {
|
|||||||
CompletionResult,
|
CompletionResult,
|
||||||
CompletionSource,
|
CompletionSource,
|
||||||
} from "@codemirror/autocomplete";
|
} from "@codemirror/autocomplete";
|
||||||
|
import type { Extension } from "@codemirror/state";
|
||||||
import type { EditorView, KeyBinding, ViewUpdate } from "@codemirror/view";
|
import type { EditorView, KeyBinding, ViewUpdate } from "@codemirror/view";
|
||||||
import { HassEntities } from "home-assistant-js-websocket";
|
import { HassEntities } from "home-assistant-js-websocket";
|
||||||
import { css, CSSResultGroup, PropertyValues, ReactiveElement } from "lit";
|
import { css, CSSResultGroup, PropertyValues, ReactiveElement } from "lit";
|
||||||
@@ -72,9 +73,9 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
if (!this.codemirror || !this._loadedCodeMirror) {
|
if (!this.codemirror || !this._loadedCodeMirror) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const className = this._loadedCodeMirror.HighlightStyle.get(
|
const className = this._loadedCodeMirror.highlightingFor(
|
||||||
this.codemirror.state,
|
this.codemirror.state,
|
||||||
this._loadedCodeMirror.tags.comment
|
[this._loadedCodeMirror.tags.comment]
|
||||||
);
|
);
|
||||||
return !!this.shadowRoot!.querySelector(`span.${className}`);
|
return !!this.shadowRoot!.querySelector(`span.${className}`);
|
||||||
}
|
}
|
||||||
@@ -136,7 +137,7 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
|
|
||||||
private async _load(): Promise<void> {
|
private async _load(): Promise<void> {
|
||||||
this._loadedCodeMirror = await loadCodeMirror();
|
this._loadedCodeMirror = await loadCodeMirror();
|
||||||
const extensions = [
|
const extensions: Extension[] = [
|
||||||
this._loadedCodeMirror.lineNumbers(),
|
this._loadedCodeMirror.lineNumbers(),
|
||||||
this._loadedCodeMirror.EditorState.allowMultipleSelections.of(true),
|
this._loadedCodeMirror.EditorState.allowMultipleSelections.of(true),
|
||||||
this._loadedCodeMirror.history(),
|
this._loadedCodeMirror.history(),
|
||||||
@@ -152,10 +153,8 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
saveKeyBinding,
|
saveKeyBinding,
|
||||||
] as KeyBinding[]),
|
] as KeyBinding[]),
|
||||||
this._loadedCodeMirror.langCompartment.of(this._mode),
|
this._loadedCodeMirror.langCompartment.of(this._mode),
|
||||||
this._loadedCodeMirror.theme,
|
this._loadedCodeMirror.haTheme,
|
||||||
this._loadedCodeMirror.Prec.fallback(
|
this._loadedCodeMirror.haSyntaxHighlighting,
|
||||||
this._loadedCodeMirror.highlightStyle
|
|
||||||
),
|
|
||||||
this._loadedCodeMirror.readonlyCompartment.of(
|
this._loadedCodeMirror.readonlyCompartment.of(
|
||||||
this._loadedCodeMirror.EditorView.editable.of(!this.readOnly)
|
this._loadedCodeMirror.EditorView.editable.of(!this.readOnly)
|
||||||
),
|
),
|
||||||
@@ -227,7 +226,7 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
return {
|
return {
|
||||||
from: Number(entityWord.from),
|
from: Number(entityWord.from),
|
||||||
options: states,
|
options: states,
|
||||||
span: /^[a-z_]{3,}\.\w*$/,
|
validFor: /^[a-z_]{3,}\.\w*$/,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +267,7 @@ export class HaCodeEditor extends ReactiveElement {
|
|||||||
return {
|
return {
|
||||||
from: Number(match.from),
|
from: Number(match.from),
|
||||||
options: iconItems,
|
options: iconItems,
|
||||||
span: /^mdi:\S*$/,
|
validFor: /^mdi:\S*$/,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,6 +59,7 @@ class HaConfigEntryPicker extends LitElement {
|
|||||||
>
|
>
|
||||||
<span slot="secondary">${item.localized_domain_name}</span>
|
<span slot="secondary">${item.localized_domain_name}</span>
|
||||||
<img
|
<img
|
||||||
|
alt=""
|
||||||
slot="graphic"
|
slot="graphic"
|
||||||
src=${brandsUrl({
|
src=${brandsUrl({
|
||||||
domain: item.domain,
|
domain: item.domain,
|
||||||
@@ -121,7 +122,8 @@ class HaConfigEntryPicker extends LitElement {
|
|||||||
.sort((conf1, conf2) =>
|
.sort((conf1, conf2) =>
|
||||||
caseInsensitiveStringCompare(
|
caseInsensitiveStringCompare(
|
||||||
conf1.localized_domain_name + conf1.title,
|
conf1.localized_domain_name + conf1.title,
|
||||||
conf2.localized_domain_name + conf2.title
|
conf2.localized_domain_name + conf2.title,
|
||||||
|
this.hass.locale.language
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -3,10 +3,12 @@ import { styles } from "@material/mwc-dialog/mwc-dialog.css";
|
|||||||
import { mdiClose } from "@mdi/js";
|
import { mdiClose } from "@mdi/js";
|
||||||
import { css, html, TemplateResult } from "lit";
|
import { css, html, TemplateResult } from "lit";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
import type { HomeAssistant } from "../types";
|
|
||||||
import { FOCUS_TARGET } from "../dialogs/make-dialog-manager";
|
import { FOCUS_TARGET } from "../dialogs/make-dialog-manager";
|
||||||
|
import type { HomeAssistant } from "../types";
|
||||||
import "./ha-icon-button";
|
import "./ha-icon-button";
|
||||||
|
|
||||||
|
const SUPPRESS_DEFAULT_PRESS_SELECTOR = ["button"];
|
||||||
|
|
||||||
export const createCloseHeading = (
|
export const createCloseHeading = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
title: string | TemplateResult
|
title: string | TemplateResult
|
||||||
@@ -32,6 +34,14 @@ export class HaDialog extends DialogBase {
|
|||||||
return html`<slot name="heading"> ${super.renderHeading()} </slot>`;
|
return html`<slot name="heading"> ${super.renderHeading()} </slot>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected firstUpdated(): void {
|
||||||
|
super.firstUpdated();
|
||||||
|
this.suppressDefaultPressSelector = [
|
||||||
|
this.suppressDefaultPressSelector,
|
||||||
|
SUPPRESS_DEFAULT_PRESS_SELECTOR,
|
||||||
|
].join(", ");
|
||||||
|
}
|
||||||
|
|
||||||
static override styles = [
|
static override styles = [
|
||||||
styles,
|
styles,
|
||||||
css`
|
css`
|
||||||
|
@@ -67,6 +67,9 @@ export class HaFormInteger extends LitElement implements HaFormElement {
|
|||||||
@change=${this._valueChanged}
|
@change=${this._valueChanged}
|
||||||
></ha-slider>
|
></ha-slider>
|
||||||
</div>
|
</div>
|
||||||
|
${this.helper
|
||||||
|
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
||||||
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,8 @@ export class HaForm extends LitElement implements HaFormElement {
|
|||||||
|
|
||||||
@property() public computeHelper?: (schema: any) => string | undefined;
|
@property() public computeHelper?: (schema: any) => string | undefined;
|
||||||
|
|
||||||
|
@property() public localizeValue?: (key: string) => string;
|
||||||
|
|
||||||
public focus() {
|
public focus() {
|
||||||
const root = this.shadowRoot?.querySelector(".root");
|
const root = this.shadowRoot?.querySelector(".root");
|
||||||
if (!root) {
|
if (!root) {
|
||||||
@@ -85,8 +87,10 @@ export class HaForm extends LitElement implements HaFormElement {
|
|||||||
.selector=${item.selector}
|
.selector=${item.selector}
|
||||||
.value=${getValue(this.data, item)}
|
.value=${getValue(this.data, item)}
|
||||||
.label=${this._computeLabel(item, this.data)}
|
.label=${this._computeLabel(item, this.data)}
|
||||||
.disabled=${item.disabled || this.disabled}
|
.disabled=${item.disabled || this.disabled || false}
|
||||||
|
.placeholder=${item.required ? "" : item.default}
|
||||||
.helper=${this._computeHelper(item)}
|
.helper=${this._computeHelper(item)}
|
||||||
|
.localizeValue=${this.localizeValue}
|
||||||
.required=${item.required || false}
|
.required=${item.required || false}
|
||||||
.context=${this._generateContext(item)}
|
.context=${this._generateContext(item)}
|
||||||
></ha-selector>`
|
></ha-selector>`
|
||||||
@@ -95,7 +99,7 @@ export class HaForm extends LitElement implements HaFormElement {
|
|||||||
data: getValue(this.data, item),
|
data: getValue(this.data, item),
|
||||||
label: this._computeLabel(item, this.data),
|
label: this._computeLabel(item, this.data),
|
||||||
helper: this._computeHelper(item),
|
helper: this._computeHelper(item),
|
||||||
disabled: this.disabled || item.disabled,
|
disabled: this.disabled || item.disabled || false,
|
||||||
hass: this.hass,
|
hass: this.hass,
|
||||||
computeLabel: this.computeLabel,
|
computeLabel: this.computeLabel,
|
||||||
computeHelper: this.computeHelper,
|
computeHelper: this.computeHelper,
|
||||||
|
@@ -39,7 +39,7 @@ export class HaNumberSelector extends LitElement {
|
|||||||
<ha-slider
|
<ha-slider
|
||||||
.min=${this.selector.number?.min}
|
.min=${this.selector.number?.min}
|
||||||
.max=${this.selector.number?.max}
|
.max=${this.selector.number?.max}
|
||||||
.value=${this._value}
|
.value=${this.value ?? ""}
|
||||||
.step=${this.selector.number?.step ?? 1}
|
.step=${this.selector.number?.step ?? 1}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
@@ -81,17 +81,11 @@ export class HaNumberSelector extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private get _value() {
|
|
||||||
return this.value ?? (this.selector.number?.min || 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private _handleInputChange(ev) {
|
private _handleInputChange(ev) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const value =
|
const value =
|
||||||
ev.target.value === "" || isNaN(ev.target.value)
|
ev.target.value === "" || isNaN(ev.target.value)
|
||||||
? this.required
|
? undefined
|
||||||
? this.selector.number?.min || 0
|
|
||||||
: undefined
|
|
||||||
: Number(ev.target.value);
|
: Number(ev.target.value);
|
||||||
if (this.value === value) {
|
if (this.value === value) {
|
||||||
return;
|
return;
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
import { html, LitElement } from "lit";
|
import { html, LitElement, PropertyValues } from "lit";
|
||||||
import { customElement, property } 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-yaml-editor";
|
import "../ha-yaml-editor";
|
||||||
import "../ha-input-helper-text";
|
import "../ha-input-helper-text";
|
||||||
|
import type { HaYamlEditor } from "../ha-yaml-editor";
|
||||||
|
|
||||||
@customElement("ha-selector-object")
|
@customElement("ha-selector-object")
|
||||||
export class HaObjectSelector extends LitElement {
|
export class HaObjectSelector extends LitElement {
|
||||||
@@ -21,6 +22,10 @@ export class HaObjectSelector extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public required = true;
|
@property({ type: Boolean }) public required = true;
|
||||||
|
|
||||||
|
@query("ha-yaml-editor", true) private _yamlEditor!: HaYamlEditor;
|
||||||
|
|
||||||
|
private _valueChangedFromChild = false;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`<ha-yaml-editor
|
return html`<ha-yaml-editor
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -36,7 +41,16 @@ export class HaObjectSelector extends LitElement {
|
|||||||
: ""} `;
|
: ""} `;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected updated(changedProps: PropertyValues) {
|
||||||
|
super.updated(changedProps);
|
||||||
|
if (changedProps.has("value") && !this._valueChangedFromChild) {
|
||||||
|
this._yamlEditor.setValue(this.value);
|
||||||
|
}
|
||||||
|
this._valueChangedFromChild = false;
|
||||||
|
}
|
||||||
|
|
||||||
private _handleChange(ev) {
|
private _handleChange(ev) {
|
||||||
|
this._valueChangedFromChild = true;
|
||||||
const value = ev.target.value;
|
const value = ev.target.value;
|
||||||
if (!ev.target.isValid) {
|
if (!ev.target.isValid) {
|
||||||
return;
|
return;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user