Compare commits

..

1 Commits

Author SHA1 Message Date
Paul Bottein
261cc6598d Add conditional form schema 2023-06-08 16:38:07 +02:00
728 changed files with 13328 additions and 36759 deletions

View File

@@ -10,12 +10,6 @@ supports es6-module-dynamic-import
not Safari < 13 not Safari < 13
not iOS < 13 not iOS < 13
# Exclude KaiOS, QQ, and UC browsers due to lack of sufficient feature support data
# Babel ignores these automatically, but we need here for Webpack to output ESM with dynamic imports
not KaiOS > 0
not QQAndroid > 0
not UCAndroid > 0
# Exclude unsupported browsers # Exclude unsupported browsers
not dead not dead

View File

@@ -1,5 +1,5 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.148.1/containers/python-3/.devcontainer/base.Dockerfile # 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.11 FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.10
ENV \ ENV \
DEBIAN_FRONTEND=noninteractive \ DEBIAN_FRONTEND=noninteractive \

View File

@@ -6,6 +6,3 @@ updates:
interval: weekly interval: weekly
time: "06:00" time: "06:00"
open-pull-requests-limit: 10 open-pull-requests-limit: 10
labels:
- Dependencies
- GitHub Actions

31
.github/labeler.yml vendored
View File

@@ -1,31 +0,0 @@
Build:
- build-scripts/**
- .browserslistrc
- gulpfile.js
Cast:
- cast/src/**
- src/cast/**
Demo:
- demo/src/**
- src/fake_data/**
Design:
- gallery/src/**
- src/fake_data/**
Dependencies:
- package.json
- renovate.json
- yarn.lock
- .yarn/**
- .yarnrc.yml
- .nvmrc
GitHub Actions:
- .github/workflows/**
- .github/*.yml
Supervisor:
- hassio/src/**

View File

@@ -1,8 +1,3 @@
categories:
- title: "Dependency updates"
collapse-after: 3
labels:
- "Dependencies"
template: | template: |
## What's Changed ## What's Changed

View File

@@ -21,12 +21,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.6.0 uses: actions/checkout@v3.5.2
with: with:
ref: dev ref: dev
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3.8.1 uses: actions/setup-node@v3.6.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: yarn cache: yarn
@@ -57,12 +57,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.6.0 uses: actions/checkout@v3.5.2
with: with:
ref: master ref: master
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3.8.1 uses: actions/setup-node@v3.6.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: yarn cache: yarn

View File

@@ -24,9 +24,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.6.0 uses: actions/checkout@v3.5.2
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3.8.1 uses: actions/setup-node@v3.6.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: yarn cache: yarn
@@ -36,14 +36,6 @@ jobs:
run: yarn dedupe --check run: yarn dedupe --check
- name: Build resources - name: Build resources
run: ./node_modules/.bin/gulp gen-icons-json build-translations build-locale-data gather-gallery-pages run: ./node_modules/.bin/gulp gen-icons-json build-translations build-locale-data gather-gallery-pages
- name: Setup lint cache
uses: actions/cache@v3.3.1
with:
path: |
node_modules/.cache/prettier
node_modules/.cache/eslint
key: lint-${{ github.sha }}
restore-keys: lint-
- name: Run eslint - name: Run eslint
run: yarn run lint:eslint --quiet run: yarn run lint:eslint --quiet
- name: Run tsc - name: Run tsc
@@ -55,9 +47,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.6.0 uses: actions/checkout@v3.5.2
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3.8.1 uses: actions/setup-node@v3.6.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: yarn cache: yarn
@@ -73,9 +65,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.6.0 uses: actions/checkout@v3.5.2
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3.8.1 uses: actions/setup-node@v3.6.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: yarn cache: yarn
@@ -91,9 +83,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.6.0 uses: actions/checkout@v3.5.2
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3.8.1 uses: actions/setup-node@v3.6.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: yarn cache: yarn

View File

@@ -17,44 +17,44 @@ jobs:
matrix: matrix:
# Override automatic language detection by changing the below list # Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ["javascript"] language: ['javascript']
# Learn more... # Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3.6.0 uses: actions/checkout@v3.5.2
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.
fetch-depth: 2 fetch-depth: 2
# If this run was triggered by a pull request event, then checkout # If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit. # the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2 - run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }} if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v2 uses: github/codeql-action/init@v2
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below) # If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v2 uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell. # Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl # 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project # and modify them (or add more) to build your code if your project
# uses a compiled language # uses a compiled language
#- run: | #- run: |
# make bootstrap # make bootstrap
# make release # make release
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2 uses: github/codeql-action/analyze@v2

View File

@@ -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.6.0 uses: actions/checkout@v3.5.2
with: with:
ref: dev ref: dev
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3.8.1 uses: actions/setup-node@v3.6.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: yarn cache: yarn
@@ -58,12 +58,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.6.0 uses: actions/checkout@v3.5.2
with: with:
ref: master ref: master
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3.8.1 uses: actions/setup-node@v3.6.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: yarn cache: yarn

View File

@@ -16,10 +16,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.6.0 uses: actions/checkout@v3.5.2
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3.8.1 uses: actions/setup-node@v3.6.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: yarn cache: yarn

View File

@@ -21,10 +21,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.6.0 uses: actions/checkout@v3.5.2
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3.8.1 uses: actions/setup-node@v3.6.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: yarn cache: yarn

View File

@@ -1,15 +0,0 @@
name: "Pull Request Labeler"
on: pull_request_target
jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Apply labels
uses: actions/labeler@v4.3.0
with:
sync-labels: true

View File

@@ -9,7 +9,7 @@ jobs:
lock: lock:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: dessant/lock-threads@v4.0.1 - uses: dessant/lock-threads@v4.0.0
with: with:
github-token: ${{ github.token }} github-token: ${{ github.token }}
issue-lock-inactive-days: "30" issue-lock-inactive-days: "30"

View File

@@ -6,7 +6,7 @@ on:
- cron: "0 1 * * *" - cron: "0 1 * * *"
env: env:
PYTHON_VERSION: "3.11" PYTHON_VERSION: "3.10"
NODE_OPTIONS: --max_old_space_size=6144 NODE_OPTIONS: --max_old_space_size=6144
permissions: permissions:
@@ -20,7 +20,7 @@ jobs:
contents: write contents: write
steps: steps:
- name: Checkout the repository - name: Checkout the repository
uses: actions/checkout@v3.6.0 uses: actions/checkout@v3.5.2
- name: Set up Python ${{ env.PYTHON_VERSION }} - name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4 uses: actions/setup-python@v4
@@ -28,7 +28,7 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }} python-version: ${{ env.PYTHON_VERSION }}
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3.8.1 uses: actions/setup-node@v3.6.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: yarn cache: yarn

View File

@@ -5,17 +5,8 @@ on:
branches: branches:
- dev - dev
permissions:
contents: read
jobs: jobs:
update_release_draft: update_release_draft:
permissions:
# write permission for contents is required to create a github release
contents: write
# write permission for pull-requests is required for autolabeler
# otherwise, read permission is required at least
pull-requests: read
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: release-drafter/release-drafter@v5 - uses: release-drafter/release-drafter@v5

View File

@@ -6,7 +6,7 @@ on:
- published - published
env: env:
PYTHON_VERSION: "3.11" PYTHON_VERSION: "3.10"
NODE_OPTIONS: --max_old_space_size=6144 NODE_OPTIONS: --max_old_space_size=6144
# Set default workflow permissions # Set default workflow permissions
@@ -23,7 +23,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.6.0 uses: actions/checkout@v3.5.2
- name: Verify version - name: Verify version
uses: home-assistant/actions/helpers/verify-version@master uses: home-assistant/actions/helpers/verify-version@master
@@ -34,7 +34,7 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }} python-version: ${{ env.PYTHON_VERSION }}
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3.8.1 uses: actions/setup-node@v3.6.0
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: yarn cache: yarn
@@ -76,7 +76,7 @@ jobs:
- name: Build wheels - name: Build wheels
uses: home-assistant/wheels@2023.04.0 uses: home-assistant/wheels@2023.04.0
with: with:
abi: cp311 abi: cp310
tag: musllinux_1_2 tag: musllinux_1_2
arch: amd64 arch: amd64
wheels-key: ${{ secrets.WHEELS_KEY }} wheels-key: ${{ secrets.WHEELS_KEY }}

View File

@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout the repository - name: Checkout the repository
uses: actions/checkout@v3.6.0 uses: actions/checkout@v3.5.2
- name: Upload Translations - name: Upload Translations
run: | run: |

View File

@@ -1,3 +1,9 @@
CLA.md build
CODE_OF_CONDUCT.md translations/*
LICENSE.md node_modules/*
hass_frontend/*
pip-selfcheck.json
# vscode
.vscode/*
!.vscode/extensions.json

6
.vscode/launch.json vendored
View File

@@ -9,7 +9,9 @@
"webRoot": "${workspaceFolder}/hass_frontend", "webRoot": "${workspaceFolder}/hass_frontend",
"disableNetworkCache": true, "disableNetworkCache": true,
"preLaunchTask": "Develop Frontend", "preLaunchTask": "Develop Frontend",
"outFiles": ["${workspaceFolder}/hass_frontend/frontend_latest/*.js"] "outFiles": [
"${workspaceFolder}/hass_frontend/frontend_latest/*.js"
]
}, },
{ {
"name": "Debug Gallery", "name": "Debug Gallery",
@@ -37,6 +39,6 @@
"webRoot": "${workspaceFolder}/cast/dist", "webRoot": "${workspaceFolder}/cast/dist",
"disableNetworkCache": true, "disableNetworkCache": true,
"preLaunchTask": "Develop Cast" "preLaunchTask": "Develop Cast"
} },
] ]
} }

2
.vscode/tasks.json vendored
View File

@@ -197,7 +197,7 @@
"type": "gulp", "type": "gulp",
"task": "setup-and-fetch-nightly-translations", "task": "setup-and-fetch-nightly-translations",
"problemMatcher": [] "problemMatcher": []
} }
], ],
"inputs": [ "inputs": [
{ {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -8,4 +8,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.6.3.cjs yarnPath: .yarn/releases/yarn-3.6.0.cjs

View File

@@ -8,7 +8,7 @@ module.exports.sourceMapURL = () => {
const ref = env.version().endsWith("dev") const ref = env.version().endsWith("dev")
? process.env.GITHUB_SHA || "dev" ? process.env.GITHUB_SHA || "dev"
: env.version(); : env.version();
return `https://raw.githubusercontent.com/home-assistant/frontend/${ref}/`; return `https://raw.githubusercontent.com/home-assistant/frontend/${ref}`;
}; };
// Files from NPM Packages that should not be imported // Files from NPM Packages that should not be imported
@@ -77,7 +77,6 @@ module.exports.htmlMinifierOptions = {
module.exports.terserOptions = ({ latestBuild, isTestBuild }) => ({ module.exports.terserOptions = ({ latestBuild, isTestBuild }) => ({
safari10: !latestBuild, safari10: !latestBuild,
ecma: latestBuild ? 2015 : 5, ecma: latestBuild ? 2015 : 5,
module: latestBuild,
format: { comments: false }, format: { comments: false },
sourceMap: !isTestBuild, sourceMap: !isTestBuild,
}); });
@@ -98,7 +97,7 @@ module.exports.babelOptions = ({ latestBuild, isProdBuild, isTestBuild }) => ({
"@babel/preset-env", "@babel/preset-env",
{ {
useBuiltIns: latestBuild ? false : "entry", useBuiltIns: latestBuild ? false : "entry",
corejs: latestBuild ? false : { version: "3.32", proposals: true }, corejs: latestBuild ? false : { version: "3.30", proposals: true },
bugfixes: true, bugfixes: true,
}, },
], ],

View File

@@ -2,15 +2,44 @@
import gulp from "gulp"; import gulp from "gulp";
import zopfli from "gulp-zopfli-green"; import zopfli from "gulp-zopfli-green";
import merge from "merge-stream";
import path from "path";
import paths from "../paths.cjs"; import paths from "../paths.cjs";
const zopfliOptions = { threshold: 150 }; const zopfliOptions = { threshold: 150 };
const compressDist = (rootDir) => gulp.task("compress-app", function compressApp() {
gulp const jsLatest = gulp
.src([`${rootDir}/**/*.{js,json,css,svg}`]) .src(path.resolve(paths.app_output_latest, "**/*.js"))
.pipe(zopfli(zopfliOptions)) .pipe(zopfli(zopfliOptions))
.pipe(gulp.dest(rootDir)); .pipe(gulp.dest(paths.app_output_latest));
gulp.task("compress-app", () => compressDist(paths.app_output_root)); const jsEs5 = gulp
gulp.task("compress-hassio", () => compressDist(paths.hassio_output_root)); .src(path.resolve(paths.app_output_es5, "**/*.js"))
.pipe(zopfli(zopfliOptions))
.pipe(gulp.dest(paths.app_output_es5));
const polyfills = gulp
.src(path.resolve(paths.app_output_static, "polyfills/*.js"))
.pipe(zopfli(zopfliOptions))
.pipe(gulp.dest(path.resolve(paths.app_output_static, "polyfills")));
const translations = gulp
.src(path.resolve(paths.app_output_static, "translations/**/*.json"))
.pipe(zopfli(zopfliOptions))
.pipe(gulp.dest(path.resolve(paths.app_output_static, "translations")));
const icons = gulp
.src(path.resolve(paths.app_output_static, "mdi/*.json"))
.pipe(zopfli(zopfliOptions))
.pipe(gulp.dest(path.resolve(paths.app_output_static, "mdi")));
return merge(jsLatest, jsEs5, polyfills, translations, icons);
});
gulp.task("compress-hassio", function compressApp() {
return gulp
.src(path.resolve(paths.hassio_output_root, "**/*.js"))
.pipe(zopfli(zopfliOptions))
.pipe(gulp.dest(paths.hassio_output_root));
});

View File

@@ -1,7 +1,6 @@
import fs from "fs/promises"; import fs from "fs/promises";
import gulp from "gulp"; import gulp from "gulp";
import mapStream from "map-stream"; import mapStream from "map-stream";
import transform from "gulp-json-transform";
const inDirFrontend = "translations/frontend"; const inDirFrontend = "translations/frontend";
const inDirBackend = "translations/backend"; const inDirBackend = "translations/backend";
@@ -42,33 +41,8 @@ function checkHtml() {
}); });
} }
function convertBackendTranslations(data, _file) { // Backend translations do not currently pass HTML check so are excluded here for now
const output = { component: {} };
if (!data.component) {
return output;
}
Object.keys(data.component).forEach((domain) => {
if (!("entity_component" in data.component[domain])) {
return;
}
output.component[domain] = { entity_component: {} };
Object.keys(data.component[domain].entity_component).forEach((key) => {
output.component[domain].entity_component[key] =
data.component[domain].entity_component[key];
});
});
return output;
}
gulp.task("convert-backend-translations", function () {
return gulp
.src([`${inDirBackend}/*.json`])
.pipe(transform((data, file) => convertBackendTranslations(data, file)))
.pipe(gulp.dest(inDirBackend));
});
gulp.task("check-translations-html", function () { gulp.task("check-translations-html", function () {
// We exclude backend translations because they are not compliant with the HTML rule for now
return gulp.src([`${inDirFrontend}/*.json`]).pipe(checkHtml()); return gulp.src([`${inDirFrontend}/*.json`]).pipe(checkHtml());
}); });

View File

@@ -1,73 +1,71 @@
import { deleteSync } from "del"; import { deleteSync } from "del";
import { mkdir, readFile, writeFile } from "fs/promises"; import fs from "fs";
import gulp from "gulp"; import gulp from "gulp";
import path from "path"; import path from "path";
import paths from "../paths.cjs"; import paths from "../paths.cjs";
const outDir = path.join(paths.build_dir, "locale-data"); const outDir = "build/locale-data";
const INTL_PACKAGES = { gulp.task("clean-locale-data", async () => deleteSync([outDir]));
gulp.task("ensure-locale-data-build-dir", async () => {
fs.mkdirSync(outDir, { recursive: true });
});
const modules = {
"intl-relativetimeformat": "RelativeTimeFormat", "intl-relativetimeformat": "RelativeTimeFormat",
"intl-datetimeformat": "DateTimeFormat", "intl-datetimeformat": "DateTimeFormat",
"intl-numberformat": "NumberFormat", "intl-numberformat": "NumberFormat",
"intl-displaynames": "DisplayNames", "intl-displaynames": "DisplayNames",
"intl-listformat": "ListFormat",
}; };
const convertToJSON = async (pkg, lang) => { gulp.task("create-locale-data", (done) => {
let localeData;
try {
localeData = await readFile(
path.resolve(
paths.polymer_dir,
`node_modules/@formatjs/${pkg}/locale-data/${lang}.js`
),
"utf-8"
);
} catch (e) {
// Ignore if language is missing (i.e. not supported by @formatjs)
if (e.code === "ENOENT") {
return;
} else {
throw e;
}
}
// Convert to JSON
const className = INTL_PACKAGES[pkg];
localeData = localeData
.replace(
new RegExp(
`\\/\\*\\s*@generated\\s*\\*\\/\\s*\\/\\/\\s*prettier-ignore\\s*if\\s*\\(Intl\\.${className}\\s*&&\\s*typeof\\s*Intl\\.${className}\\.__addLocaleData\\s*===\\s*'function'\\)\\s*{\\s*Intl\\.${className}\\.__addLocaleData\\(`,
"im"
),
""
)
.replace(/\)\s*}/im, "");
// Parse to validate JSON, then stringify to minify
localeData = JSON.stringify(JSON.parse(localeData));
await writeFile(path.join(outDir, `${pkg}/${lang}.json`), localeData);
};
gulp.task("clean-locale-data", async () => deleteSync([outDir]));
gulp.task("create-locale-data", async () => {
const translationMeta = JSON.parse( const translationMeta = JSON.parse(
await readFile( fs.readFileSync(
path.resolve(paths.translations_src, "translationMetadata.json"), path.join(paths.translations_src, "translationMetadata.json")
"utf-8"
) )
); );
const conversions = []; Object.entries(modules).forEach(([module, className]) => {
for (const pkg of Object.keys(INTL_PACKAGES)) { Object.keys(translationMeta).forEach((lang) => {
await mkdir(path.join(outDir, pkg), { recursive: true }); try {
for (const lang of Object.keys(translationMeta)) { const localeData = fs
conversions.push(convertToJSON(pkg, lang)); .readFileSync(
} path.resolve(
} paths.polymer_dir,
await Promise.all(conversions); `node_modules/@formatjs/${module}/locale-data/${lang}.js`
),
"utf-8"
)
.replace(
new RegExp(
`\\/\\*\\s*@generated\\s*\\*\\/\\s*\\/\\/\\s*prettier-ignore\\s*if\\s*\\(Intl\\.${className}\\s*&&\\s*typeof\\s*Intl\\.${className}\\.__addLocaleData\\s*===\\s*'function'\\)\\s*{\\s*Intl\\.${className}\\.__addLocaleData\\(`,
"im"
),
""
)
.replace(/\)\s*}/im, "");
// make sure we have valid JSON
JSON.parse(localeData);
fs.mkdirSync(path.join(outDir, module), { recursive: true });
fs.writeFileSync(
path.join(outDir, `${module}/${lang}.json`),
localeData
);
} catch (e) {
if (e.code !== "ENOENT") {
throw e;
}
}
});
done();
});
}); });
gulp.task( gulp.task(
"build-locale-data", "build-locale-data",
gulp.series("clean-locale-data", "create-locale-data") gulp.series(
"clean-locale-data",
"ensure-locale-data-build-dir",
"create-locale-data"
)
); );

View File

@@ -415,7 +415,7 @@ gulp.task("build-translation-write-metadata", () =>
gulp.task( gulp.task(
"create-translations", "create-translations",
gulp.series( gulp.series(
...(env.isProdBuild() ? [] : ["create-test-translation"]), env.isProdBuild() ? (done) => done() : "create-test-translation",
"build-master-translation", "build-master-translation",
"build-merged-translations", "build-merged-translations",
gulp.parallel(...splitTasks), gulp.parallel(...splitTasks),

View File

@@ -1,9 +1,9 @@
// Tasks to run webpack. // Tasks to run webpack.
import fs from "fs";
import path from "path";
import log from "fancy-log"; import log from "fancy-log";
import fs from "fs";
import gulp from "gulp"; import gulp from "gulp";
import path from "path";
import webpack from "webpack"; import webpack from "webpack";
import WebpackDevServer from "webpack-dev-server"; import WebpackDevServer from "webpack-dev-server";
import env from "../env.cjs"; import env from "../env.cjs";
@@ -44,7 +44,6 @@ const runDevServer = async ({
}) => { }) => {
const server = new WebpackDevServer( const server = new WebpackDevServer(
{ {
hot: false,
open: true, open: true,
host: listenHost, host: listenHost,
port, port,

View File

@@ -142,5 +142,4 @@ module.exports = {
createCastConfig, createCastConfig,
createHassioConfig, createHassioConfig,
createGalleryConfig, createGalleryConfig,
createRollupConfig,
}; };

View File

@@ -1,6 +1,5 @@
const { existsSync } = require("fs");
const path = require("path");
const webpack = require("webpack"); const webpack = require("webpack");
const path = require("path");
const TerserPlugin = require("terser-webpack-plugin"); const TerserPlugin = require("terser-webpack-plugin");
const { WebpackManifestPlugin } = require("webpack-manifest-plugin"); const { WebpackManifestPlugin } = require("webpack-manifest-plugin");
const log = require("fancy-log"); const log = require("fancy-log");
@@ -42,7 +41,7 @@ const createWebpackConfig = ({
return { return {
name, name,
mode: isProdBuild ? "production" : "development", mode: isProdBuild ? "production" : "development",
target: `browserslist:${latestBuild ? "modern" : "legacy"}`, target: ["web", latestBuild ? "es2017" : "es5"],
// For tests/CI, source maps are skipped to gain build speed // For tests/CI, source maps are skipped to gain build speed
// For production, generate source maps for accurate stack traces without source code // For production, generate source maps for accurate stack traces without source code
// For development, generate "cheap" versions that can map to original line numbers // For development, generate "cheap" versions that can map to original line numbers
@@ -85,13 +84,6 @@ const createWebpackConfig = ({
], ],
moduleIds: isProdBuild && !isStatsBuild ? "deterministic" : "named", moduleIds: isProdBuild && !isStatsBuild ? "deterministic" : "named",
chunkIds: isProdBuild && !isStatsBuild ? "deterministic" : "named", chunkIds: isProdBuild && !isStatsBuild ? "deterministic" : "named",
splitChunks: {
// Disable splitting for web workers with ESM output
// Imports of external chunks are broken
chunks: latestBuild
? (chunk) => !chunk.canBeInitial() && !/^.+-worker$/.test(chunk.name)
: undefined,
},
}, },
plugins: [ plugins: [
!isStatsBuild && new WebpackBar({ fancy: !isProdBuild }), !isStatsBuild && new WebpackBar({ fancy: !isProdBuild }),
@@ -168,12 +160,9 @@ const createWebpackConfig = ({
"lit/polyfill-support$": "lit/polyfill-support.js", "lit/polyfill-support$": "lit/polyfill-support.js",
"@lit-labs/virtualizer/layouts/grid": "@lit-labs/virtualizer/layouts/grid":
"@lit-labs/virtualizer/layouts/grid.js", "@lit-labs/virtualizer/layouts/grid.js",
"@lit-labs/virtualizer/polyfills/resize-observer-polyfill/ResizeObserver":
"@lit-labs/virtualizer/polyfills/resize-observer-polyfill/ResizeObserver.js",
}, },
}, },
output: { output: {
module: latestBuild,
filename: ({ chunk }) => filename: ({ chunk }) =>
!isProdBuild || isStatsBuild || dontHash.has(chunk.name) !isProdBuild || isStatsBuild || dontHash.has(chunk.name)
? "[name].js" ? "[name].js"
@@ -192,29 +181,22 @@ const createWebpackConfig = ({
// Since production source maps don't include sources, we need to point to them elsewhere // Since production source maps don't include sources, we need to point to them elsewhere
// For dependencies, just provide the path (no source in browser) // For dependencies, just provide the path (no source in browser)
// Otherwise, point to the raw code on GitHub for browser to load // Otherwise, point to the raw code on GitHub for browser to load
...Object.fromEntries( devtoolModuleFilenameTemplate:
["", "Fallback"].map((v) => [ !isTestBuild && isProdBuild
`devtool${v}ModuleFilenameTemplate`, ? (info) => {
!isTestBuild && isProdBuild const sourcePath = info.resourcePath.replace(/^\.\//, "");
? (info) => { if (
if ( sourcePath.startsWith("node_modules") ||
!path.isAbsolute(info.absoluteResourcePath) || sourcePath.startsWith("webpack")
!existsSync(info.resourcePath) || ) {
info.resourcePath.startsWith("./node_modules") return `no-source/${sourcePath}`;
) {
// Source URLs are unknown for dependencies, so we use a relative URL with a
// non - existent top directory. This results in a clean source tree in browser
// dev tools, and they stay happy getting 404s with valid requests.
return `/unknown${path.resolve("/", info.resourcePath)}`;
}
return new URL(info.resourcePath, bundle.sourceMapURL()).href;
} }
: undefined, return `${bundle.sourceMapURL()}/${sourcePath}`;
]) }
), : undefined,
}, },
experiments: { experiments: {
outputModule: true, topLevelAwait: true,
}, },
}; };
}; };
@@ -261,5 +243,4 @@ module.exports = {
createCastConfig, createCastConfig,
createHassioConfig, createHassioConfig,
createGalleryConfig, createGalleryConfig,
createWebpackConfig,
}; };

View File

@@ -1,3 +1,3 @@
self.addEventListener("fetch", (event) => { self.addEventListener("fetch", function(event) {
event.respondWith(fetch(event.request)); event.respondWith(fetch(event.request));
}); });

View File

@@ -1,21 +1,21 @@
import { framework } from "../receiver/cast_framework"; import { cast } from "chromecast-caf-receiver";
const castContext = framework.CastReceiverContext.getInstance(); const castContext = cast.framework.CastReceiverContext.getInstance();
const playerManager = castContext.getPlayerManager(); const playerManager = castContext.getPlayerManager();
playerManager.setMessageInterceptor( playerManager.setMessageInterceptor(
framework.messages.MessageType.LOAD, cast.framework.messages.MessageType.LOAD,
(loadRequestData) => { (loadRequestData) => {
const media = loadRequestData.media; const media = loadRequestData.media;
// Special handling if it came from Google Assistant // Special handling if it came from Google Assistant
if (media.entity) { if (media.entity) {
media.contentId = media.entity; media.contentId = media.entity;
media.streamType = framework.messages.StreamType.LIVE; media.streamType = cast.framework.messages.StreamType.LIVE;
media.contentType = "application/vnd.apple.mpegurl"; media.contentType = "application/vnd.apple.mpegurl";
// @ts-ignore // @ts-ignore
media.hlsVideoSegmentFormat = media.hlsVideoSegmentFormat =
framework.messages.HlsVideoSegmentFormat.FMP4; cast.framework.messages.HlsVideoSegmentFormat.FMP4;
} }
return loadRequestData; return loadRequestData;
} }

View File

@@ -1,3 +1,3 @@
import { framework } from "./cast_framework"; import { cast } from "chromecast-caf-receiver";
export const castContext = framework.CastReceiverContext.getInstance(); export const castContext = cast.framework.CastReceiverContext.getInstance();

View File

@@ -1,3 +0,0 @@
import type { cast as ReceiverCast } from "chromecast-caf-receiver";
export const framework = (cast as unknown as typeof ReceiverCast).framework;

View File

@@ -1,4 +1,4 @@
import { framework } from "./cast_framework"; import { cast } from "chromecast-caf-receiver";
import { CAST_NS } from "../../../src/cast/const"; import { CAST_NS } from "../../../src/cast/const";
import { HassMessage } from "../../../src/cast/receiver_messages"; import { HassMessage } from "../../../src/cast/receiver_messages";
import "../../../src/resources/custom-card-support"; import "../../../src/resources/custom-card-support";
@@ -34,14 +34,14 @@ const setTouchControlsVisibility = (visible: boolean) => {
let timeOut: number | undefined; let timeOut: number | undefined;
const playDummyMedia = (viewTitle?: string) => { const playDummyMedia = (viewTitle?: string) => {
const loadRequestData = new framework.messages.LoadRequestData(); const loadRequestData = new cast.framework.messages.LoadRequestData();
loadRequestData.autoplay = true; loadRequestData.autoplay = true;
loadRequestData.media = new framework.messages.MediaInformation(); loadRequestData.media = new cast.framework.messages.MediaInformation();
loadRequestData.media.contentId = loadRequestData.media.contentId =
"https://cast.home-assistant.io/images/google-nest-hub.png"; "https://cast.home-assistant.io/images/google-nest-hub.png";
loadRequestData.media.contentType = "image/jpeg"; loadRequestData.media.contentType = "image/jpeg";
loadRequestData.media.streamType = framework.messages.StreamType.NONE; loadRequestData.media.streamType = cast.framework.messages.StreamType.NONE;
const metadata = new framework.messages.GenericMediaMetadata(); const metadata = new cast.framework.messages.GenericMediaMetadata();
metadata.title = viewTitle; metadata.title = viewTitle;
loadRequestData.media.metadata = metadata; loadRequestData.media.metadata = metadata;
@@ -86,10 +86,10 @@ const showMediaPlayer = () => {
} }
}; };
const options = new framework.CastReceiverOptions(); const options = new cast.framework.CastReceiverOptions();
options.disableIdleTimeout = true; options.disableIdleTimeout = true;
options.customNamespaces = { options.customNamespaces = {
[CAST_NS]: framework.system.MessageType.JSON, [CAST_NS]: cast.framework.system.MessageType.JSON,
}; };
castContext.addCustomMessageListener( castContext.addCustomMessageListener(
@@ -98,7 +98,8 @@ castContext.addCustomMessageListener(
(ev: ReceivedMessage<HassMessage>) => { (ev: ReceivedMessage<HassMessage>) => {
// We received a show Lovelace command, stop media from playing, hide media player and show Lovelace controller // We received a show Lovelace command, stop media from playing, hide media player and show Lovelace controller
if ( if (
playerManager.getPlayerState() !== framework.messages.PlayerState.IDLE playerManager.getPlayerState() !==
cast.framework.messages.PlayerState.IDLE
) { ) {
playerManager.stop(); playerManager.stop();
} else { } else {
@@ -113,7 +114,7 @@ castContext.addCustomMessageListener(
const playerManager = castContext.getPlayerManager(); const playerManager = castContext.getPlayerManager();
playerManager.setMessageInterceptor( playerManager.setMessageInterceptor(
framework.messages.MessageType.LOAD, cast.framework.messages.MessageType.LOAD,
(loadRequestData) => { (loadRequestData) => {
if ( if (
loadRequestData.media.contentId === loadRequestData.media.contentId ===
@@ -127,24 +128,25 @@ playerManager.setMessageInterceptor(
// Special handling if it came from Google Assistant // Special handling if it came from Google Assistant
if (media.entity) { if (media.entity) {
media.contentId = media.entity; media.contentId = media.entity;
media.streamType = framework.messages.StreamType.LIVE; media.streamType = cast.framework.messages.StreamType.LIVE;
media.contentType = "application/vnd.apple.mpegurl"; media.contentType = "application/vnd.apple.mpegurl";
// @ts-ignore // @ts-ignore
media.hlsVideoSegmentFormat = media.hlsVideoSegmentFormat =
framework.messages.HlsVideoSegmentFormat.FMP4; cast.framework.messages.HlsVideoSegmentFormat.FMP4;
} }
return loadRequestData; return loadRequestData;
} }
); );
playerManager.addEventListener( playerManager.addEventListener(
framework.events.EventType.MEDIA_STATUS, cast.framework.events.EventType.MEDIA_STATUS,
(event) => { (event) => {
if ( if (
event.mediaStatus?.playerState === framework.messages.PlayerState.IDLE && event.mediaStatus?.playerState ===
cast.framework.messages.PlayerState.IDLE &&
event.mediaStatus?.idleReason && event.mediaStatus?.idleReason &&
event.mediaStatus?.idleReason !== event.mediaStatus?.idleReason !==
framework.messages.IdleReason.INTERRUPTED cast.framework.messages.IdleReason.INTERRUPTED
) { ) {
// media finished or stopped, return to default Lovelace // media finished or stopped, return to default Lovelace
showLovelaceController(); showLovelaceController();

View File

@@ -1,3 +1,3 @@
self.addEventListener("fetch", (event) => { self.addEventListener("fetch", function(event) {
event.respondWith(fetch(event.request)); event.respondWith(fetch(event.request));
}); });

View File

@@ -1,18 +1,20 @@
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass"; import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
export const mockConfigEntries = (hass: MockHomeAssistant) => { export const mockConfigEntries = (hass: MockHomeAssistant) => {
hass.mockWS("config_entries/get", () => ({ hass.mockWS("config_entries/get_matching", () => [
entry_id: "co2signal", {
domain: "co2signal", entry_id: "co2signal",
title: "Electricity Maps", domain: "co2signal",
source: "user", title: "CO2 Signal",
state: "loaded", source: "user",
supports_options: false, state: "loaded",
supports_remove_device: false, supports_options: false,
supports_unload: true, supports_remove_device: false,
pref_disable_new_entities: false, supports_unload: true,
pref_disable_polling: false, pref_disable_new_entities: false,
disabled_by: null, pref_disable_polling: false,
reason: null, disabled_by: null,
})); reason: null,
},
]);
}; };

View File

@@ -1,20 +1,16 @@
import { PersistentNotificationMessage } from "../../../src/data/persistent_notification"; import { PersistentNotification } from "../../../src/data/persistent_notification";
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass"; import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
export const mockPersistentNotification = (hass: MockHomeAssistant) => { export const mockPersistentNotification = (hass: MockHomeAssistant) => {
hass.mockWS("persistent_notification/subscribe", (_msg, _hass, onChange) => { hass.mockWS("persistent_notification/get", () =>
onChange!({ Promise.resolve([
type: "added", {
notifications: { created_at: new Date().toISOString(),
"demo-1": { message: "There was motion detected in the backyard.",
created_at: new Date().toISOString(), notification_id: "demo-1",
message: "There was motion detected in the backyard.", title: "Motion Detected!",
notification_id: "demo-1", status: "unread",
title: "Motion Detected!",
status: "unread",
},
}, },
} as PersistentNotificationMessage); ] as PersistentNotification[])
return () => {}; );
});
}; };

View File

@@ -72,7 +72,6 @@ const generateSumStatistics = (
min: null, min: null,
max: null, max: null,
last_reset: 0, last_reset: 0,
change: add,
state: initValue + sum, state: initValue + sum,
sum, sum,
}); });
@@ -104,8 +103,8 @@ const generateCurvedStatistics = (
let half = false; let half = false;
const now = new Date(); const now = new Date();
while (end > currentDate && currentDate < now) { while (end > currentDate && currentDate < now) {
const add = i * (Math.random() * maxDiff); const add = Math.random() * maxDiff;
sum += add; sum += i * add;
statistics.push({ statistics.push({
start: currentDate.getTime(), start: currentDate.getTime(),
end: currentDate.getTime(), end: currentDate.getTime(),
@@ -113,7 +112,6 @@ const generateCurvedStatistics = (
min: null, min: null,
max: null, max: null,
last_reset: 0, last_reset: 0,
change: add,
state: initValue + sum, state: initValue + sum,
sum: metered ? sum : null, sum: metered ? sum : null,
}); });

View File

@@ -1,3 +1,4 @@
import "@polymer/app-layout/app-toolbar/app-toolbar";
import { html, css, LitElement } from "lit"; import { html, css, LitElement } from "lit";
import { customElement, property, query, state } from "lit/decorators"; import { customElement, property, query, state } from "lit/decorators";
import { applyThemesOnElement } from "../../../src/common/dom/apply_themes_on_element"; import { applyThemesOnElement } from "../../../src/common/dom/apply_themes_on_element";
@@ -6,7 +7,6 @@ import "../../../src/components/ha-switch";
import { HomeAssistant } from "../../../src/types"; import { HomeAssistant } from "../../../src/types";
import "./demo-card"; import "./demo-card";
import type { DemoCardConfig } from "./demo-card"; import type { DemoCardConfig } from "./demo-card";
import "../ha-demo-options";
@customElement("demo-cards") @customElement("demo-cards")
class DemoCards extends LitElement { class DemoCards extends LitElement {
@@ -20,14 +20,20 @@ class DemoCards extends LitElement {
render() { render() {
return html` return html`
<ha-demo-options> <app-toolbar>
<ha-formfield label="Show config"> <div class="filters">
<ha-switch @change=${this._showConfigToggled}> </ha-switch> <ha-formfield label="Show config">
</ha-formfield> <ha-switch
<ha-formfield label="Dark theme"> .checked=${this._showConfig}
<ha-switch @change=${this._darkThemeToggled}> </ha-switch> @change=${this._showConfigToggled}
</ha-formfield> >
</ha-demo-options> </ha-switch>
</ha-formfield>
<ha-formfield label="Dark theme">
<ha-switch @change=${this._darkThemeToggled}> </ha-switch>
</ha-formfield>
</div>
</app-toolbar>
<div id="container"> <div id="container">
<div class="cards"> <div class="cards">
${this.configs.map( ${this.configs.map(
@@ -63,6 +69,12 @@ class DemoCards extends LitElement {
demo-card { demo-card {
margin: 16px 16px 32px; margin: 16px 16px 32px;
} }
app-toolbar {
background-color: var(--light-primary-color);
}
.filters {
margin-left: 60px;
}
ha-formfield { ha-formfield {
margin-right: 16px; margin-right: 16px;
} }

View File

@@ -0,0 +1,93 @@
import { html } from "@polymer/polymer/lib/utils/html-tag";
/* eslint-plugin-disable lit */
import { PolymerElement } from "@polymer/polymer/polymer-element";
import "../../../src/components/ha-card";
import "../../../src/dialogs/more-info/more-info-content";
import "../../../src/state-summary/state-card-content";
class DemoMoreInfo extends PolymerElement {
static get template() {
return html`
<style>
.root {
display: flex;
}
#card {
max-width: 400px;
width: 100vw;
}
ha-card {
width: 352px;
padding: 20px 24px;
}
state-card-content {
display: block;
margin-bottom: 16px;
}
pre {
width: 400px;
margin: 0 16px;
overflow: auto;
color: var(--primary-text-color);
}
@media only screen and (max-width: 800px) {
.root {
flex-direction: column;
}
pre {
margin: 16px 0;
}
}
</style>
<div class="root">
<div id="card">
<ha-card>
<state-card-content
state-obj="[[_stateObj]]"
hass="[[hass]]"
in-dialog
></state-card-content>
<more-info-content
hass="[[hass]]"
state-obj="[[_stateObj]]"
></more-info-content>
</ha-card>
</div>
<template is="dom-if" if="[[showConfig]]">
<pre>[[_jsonEntity(_stateObj)]]</pre>
</template>
</div>
`;
}
static get properties() {
return {
hass: Object,
entityId: String,
showConfig: Boolean,
_stateObj: {
type: Object,
computed: "_getState(entityId, hass.states)",
},
};
}
_getState(entityId, states) {
return states[entityId];
}
_jsonEntity(stateObj) {
// We are caching some things on stateObj
// (it sucks, we will remove in the future)
const tmp = {};
Object.keys(stateObj).forEach((key) => {
if (key[0] !== "_") {
tmp[key] = stateObj[key];
}
});
return JSON.stringify(tmp, null, 2);
}
}
customElements.define("demo-more-info", DemoMoreInfo);

View File

@@ -1,93 +0,0 @@
import { LitElement, css, html } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../src/components/ha-card";
import "../../../src/dialogs/more-info/more-info-content";
import "../../../src/state-summary/state-card-content";
import "../ha-demo-options";
import { HomeAssistant } from "../../../src/types";
@customElement("demo-more-info")
class DemoMoreInfo extends LitElement {
@property() public hass!: HomeAssistant;
@property() public entityId!: string;
@property() public showConfig!: boolean;
render() {
const state = this._getState(this.entityId, this.hass.states);
return html`
<div class="root">
<div id="card">
<ha-card>
<state-card-content
.stateObj=${state}
.hass=${this.hass}
in-dialog
></state-card-content>
<more-info-content
.hass=${this.hass}
.stateObj=${state}
></more-info-content>
</ha-card>
</div>
${this.showConfig ? html`<pre>${this._jsonEntity(state)}</pre>` : ""}
</div>
`;
}
private _getState(entityId, states) {
return states[entityId];
}
private _jsonEntity(stateObj) {
// We are caching some things on stateObj
// (it sucks, we will remove in the future)
const tmp = {};
Object.keys(stateObj).forEach((key) => {
if (key[0] !== "_") {
tmp[key] = stateObj[key];
}
});
return JSON.stringify(tmp, null, 2);
}
static styles = css`
.root {
display: flex;
}
#card {
max-width: 400px;
width: 100vw;
}
ha-card {
width: 352px;
padding: 20px 24px;
}
state-card-content {
display: block;
margin-bottom: 16px;
}
pre {
width: 400px;
margin: 0 16px;
overflow: auto;
color: var(--primary-text-color);
}
@media only screen and (max-width: 800px) {
.root {
flex-direction: column;
}
pre {
margin: 16px 0;
}
}
`;
}
declare global {
interface HTMLElementTagNameMap {
"demo-more-info": DemoMoreInfo;
}
}

View File

@@ -0,0 +1,83 @@
import "@polymer/app-layout/app-toolbar/app-toolbar";
import { html } from "@polymer/polymer/lib/utils/html-tag";
/* eslint-plugin-disable lit */
import { PolymerElement } from "@polymer/polymer/polymer-element";
import { applyThemesOnElement } from "../../../src/common/dom/apply_themes_on_element";
import "../../../src/components/ha-formfield";
import "../../../src/components/ha-switch";
import "./demo-more-info";
class DemoMoreInfos extends PolymerElement {
static get template() {
return html`
<style>
#container {
min-height: calc(100vh - 128px);
background: var(--primary-background-color);
}
.cards {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
demo-more-info {
margin: 16px 16px 32px;
}
app-toolbar {
background-color: var(--light-primary-color);
}
.filters {
margin-left: 60px;
}
ha-formfield {
margin-right: 16px;
}
</style>
<app-toolbar>
<div class="filters">
<ha-formfield label="Show entities">
<ha-switch checked="[[_showConfig]]" on-change="_showConfigToggled">
</ha-switch>
</ha-formfield>
<ha-formfield label="Dark theme">
<ha-switch on-change="_darkThemeToggled"> </ha-switch>
</ha-formfield>
</div>
</app-toolbar>
<div id="container">
<div class="cards">
<template is="dom-repeat" items="[[entities]]">
<demo-more-info
entity-id="[[item]]"
show-config="[[_showConfig]]"
hass="[[hass]]"
></demo-more-info>
</template>
</div>
</div>
`;
}
static get properties() {
return {
entities: Array,
hass: Object,
_showConfig: {
type: Boolean,
value: false,
},
};
}
_showConfigToggled(ev) {
this._showConfig = ev.target.checked;
}
_darkThemeToggled(ev) {
applyThemesOnElement(this.$.container, { themes: {} }, "default", {
dark: ev.target.checked,
});
}
}
customElements.define("demo-more-infos", DemoMoreInfos);

View File

@@ -1,87 +0,0 @@
import { LitElement, css, html } from "lit";
import { customElement, property } from "lit/decorators";
import { applyThemesOnElement } from "../../../src/common/dom/apply_themes_on_element";
import "../../../src/components/ha-formfield";
import "../../../src/components/ha-switch";
import "./demo-more-info";
import "../ha-demo-options";
import { HomeAssistant } from "../../../src/types";
@customElement("demo-more-infos")
class DemoMoreInfos extends LitElement {
@property() public hass!: HomeAssistant;
@property() public entities!: [];
@property({ attribute: false }) _showConfig: boolean = false;
render() {
return html`
<ha-demo-options>
<ha-formfield label="Show config">
<ha-switch @change=${this._showConfigToggled}> </ha-switch>
</ha-formfield>
<ha-formfield label="Dark theme">
<ha-switch @change=${this._darkThemeToggled}> </ha-switch>
</ha-formfield>
</ha-demo-options>
<div id="container">
<div class="cards">
${this.entities.map(
(item) =>
html`<demo-more-info
.entityId=${item}
.showConfig=${this._showConfig}
.hass=${this.hass}
></demo-more-info>`
)}
</div>
</div>
`;
}
static styles = css`
#container {
min-height: calc(100vh - 128px);
background: var(--primary-background-color);
}
.cards {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
demo-more-info {
margin: 16px 16px 32px;
}
ha-formfield {
margin-right: 16px;
}
`;
_showConfigToggled(ev) {
this._showConfig = ev.target.checked;
}
_darkThemeToggled(ev) {
applyThemesOnElement(
this.shadowRoot!.querySelector("#container"),
{
default_theme: "default",
default_dark_theme: "default",
themes: {},
darkMode: false,
theme: "default",
},
"default",
{
dark: ev.target.checked,
}
);
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-more-infos": DemoMoreInfos;
}
}

View File

@@ -1,24 +0,0 @@
import type { ControlSelectOption } from "../../../src/components/ha-control-select";
export const timeOptions: ControlSelectOption[] = [
{
value: "now",
label: "Now",
},
{
value: "00:15:30",
label: "12:15:30 AM",
},
{
value: "06:15:30",
label: "06:15:30 AM",
},
{
value: "12:15:30",
label: "12:15:30 PM",
},
{
value: "18:15:30",
label: "06:15:30 PM",
},
];

View File

@@ -1,47 +0,0 @@
import "@material/mwc-drawer";
import "@material/mwc-top-app-bar-fixed";
import { html, css, LitElement } from "lit";
import { customElement } from "lit/decorators";
import "../../src/components/ha-icon-button";
import "../../src/managers/notification-manager";
import { haStyle } from "../../src/resources/styles";
import "./components/page-description";
@customElement("ha-demo-options")
class HaDemoOptions extends LitElement {
render() {
return html`<slot></slot>`;
}
static styles = [
haStyle,
css`
:host {
display: block;
background-color: var(--light-primary-color);
margin-left: 60px
margin-right: 60px;
display: var(--layout-horizontal_-_display);
-ms-flex-direction: var(--layout-horizontal_-_-ms-flex-direction);
-webkit-flex-direction: var(
--layout-horizontal_-_-webkit-flex-direction
);
flex-direction: var(--layout-horizontal_-_flex-direction);
-ms-flex-align: var(--layout-center_-_-ms-flex-align);
-webkit-align-items: var(--layout-center_-_-webkit-align-items);
align-items: var(--layout-center_-_align-items);
position: relative;
height: 64px;
padding: 0 16px;
pointer-events: none;
font-size: 20px;
}
`,
];
}
declare global {
interface HTMLElementTagNameMap {
"ha-demo-options": HaDemoOptions;
}
}

View File

@@ -4,63 +4,53 @@ subtitle: The difference between remove/delete and add/create.
--- ---
# Remove vs Delete # Remove vs Delete
Remove and Delete are quite similar, but can be frustrating if used inconsistently. Remove and Delete are quite similar, but can be frustrating if used inconsistently.
## Remove ## Remove
Take away and set aside, but kept in existence. Take away and set aside, but kept in existence.
For example: For example:
* Removing a user's permission
- Removing a user's permission * Removing a user from a group
- Removing a user from a group * Removing links between items
- Removing links between items * Removing a widget
- Removing a widget * Removing a link
- Removing a link * Removing an item from a cart
- Removing an item from a cart
## Delete ## Delete
Erase, rendered nonexistent or nonrecoverable. Erase, rendered nonexistent or nonrecoverable.
For example: For example:
* Deleting a field
- Deleting a field * Deleting a value in a field
- Deleting a value in a field * Deleting a task
- Deleting a task * Deleting a group
- Deleting a group * Deleting a permission
- Deleting a permission * Deleting a calendar event
- Deleting a calendar event
# Add vs Create # Add vs Create
In most cases, Create can be paired with Delete, and Add can be paired with Remove. In most cases, Create can be paired with Delete, and Add can be paired with Remove.
## Add ## Add
An already-exisiting item. An already-exisiting item.
For example: For example:
* Adding a permission to a user
- Adding a permission to a user * Adding a user to a group
- Adding a user to a group * Adding links between items
- Adding links between items * Adding a widget
- Adding a widget * Adding a link
- Adding a link * Adding an item to a cart
- Adding an item to a cart
## Create ## Create
Something made from scratch. Something made from scratch.
For example: For example:
* Creating a new field
- Creating a new field * Creating a new value in a field
- Creating a new value in a field * Creating a new task
- Creating a new task * Creating a new group
- Creating a new group * Creating a new permission
- Creating a new permission * Creating a new calendar event
- Creating a new calendar event
Based on this is [UX magazine article](https://uxmag.com/articles/ui-copy-remove-vs-delete2-banner). Based on this is [UX magazine article](https://uxmag.com/articles/ui-copy-remove-vs-delete2-banner).

View File

@@ -162,7 +162,6 @@ export class DemoAutomationDescribeAction extends LitElement {
super.firstUpdated(changedProps); super.firstUpdated(changedProps);
const hass = provideHass(this); const hass = provideHass(this);
hass.updateTranslations(null, "en"); hass.updateTranslations(null, "en");
hass.updateTranslations("config", "en");
hass.addEntities(ENTITIES); hass.addEntities(ENTITIES);
} }

View File

@@ -89,7 +89,6 @@ export class DemoAutomationDescribeCondition extends LitElement {
super.firstUpdated(changedProps); super.firstUpdated(changedProps);
const hass = provideHass(this); const hass = provideHass(this);
hass.updateTranslations(null, "en"); hass.updateTranslations(null, "en");
hass.updateTranslations("config", "en");
hass.addEntities(ENTITIES); hass.addEntities(ENTITIES);
} }

View File

@@ -40,9 +40,7 @@ const triggers = [
}, },
{ platform: "sun", event: "sunset" }, { platform: "sun", event: "sunset" },
{ platform: "time_pattern" }, { platform: "time_pattern" },
{ platform: "time_pattern", hours: "*", minutes: "/5", seconds: "10" },
{ platform: "webhook" }, { platform: "webhook" },
{ platform: "persistent_notification" },
{ {
platform: "zone", platform: "zone",
entity_id: "person.person", entity_id: "person.person",
@@ -52,11 +50,6 @@ const triggers = [
{ platform: "tag" }, { platform: "tag" },
{ platform: "time", at: "15:32" }, { platform: "time", at: "15:32" },
{ platform: "template" }, { platform: "template" },
{ platform: "conversation", command: "Turn on the lights" },
{
platform: "conversation",
command: ["Turn on the lights", "Turn the lights on"],
},
{ platform: "event", event_type: "homeassistant_started" }, { platform: "event", event_type: "homeassistant_started" },
]; ];
@@ -106,7 +99,6 @@ export class DemoAutomationDescribeTrigger extends LitElement {
super.firstUpdated(changedProps); super.firstUpdated(changedProps);
const hass = provideHass(this); const hass = provideHass(this);
hass.updateTranslations(null, "en"); hass.updateTranslations(null, "en");
hass.updateTranslations("config", "en");
hass.addEntities(ENTITIES); hass.addEntities(ENTITIES);
} }

View File

@@ -85,16 +85,17 @@ class DemoHaAutomationEditorAction extends LitElement {
.value=${this.data[sampleIdx]} .value=${this.data[sampleIdx]}
> >
${["light", "dark"].map( ${["light", "dark"].map(
(slot) => html` (slot) =>
<ha-automation-action html`
slot=${slot} <ha-automation-action
.hass=${this.hass} slot=${slot}
.actions=${this.data[sampleIdx]} .hass=${this.hass}
.sampleIdx=${sampleIdx} .actions=${this.data[sampleIdx]}
.disabled=${this._disabled} .sampleIdx=${sampleIdx}
@value-changed=${valueChanged} .disabled=${this._disabled}
></ha-automation-action> @value-changed=${valueChanged}
` ></ha-automation-action>
`
)} )}
</demo-black-white-row> </demo-black-white-row>
` `

View File

@@ -121,16 +121,17 @@ class DemoHaAutomationEditorCondition extends LitElement {
.value=${this.data[sampleIdx]} .value=${this.data[sampleIdx]}
> >
${["light", "dark"].map( ${["light", "dark"].map(
(slot) => html` (slot) =>
<ha-automation-condition html`
slot=${slot} <ha-automation-condition
.hass=${this.hass} slot=${slot}
.conditions=${this.data[sampleIdx]} .hass=${this.hass}
.sampleIdx=${sampleIdx} .conditions=${this.data[sampleIdx]}
.disabled=${this._disabled} .sampleIdx=${sampleIdx}
@value-changed=${valueChanged} .disabled=${this._disabled}
></ha-automation-condition> @value-changed=${valueChanged}
` ></ha-automation-condition>
`
)} )}
</demo-black-white-row> </demo-black-white-row>
` `

View File

@@ -19,13 +19,11 @@ import { HaTemplateTrigger } from "../../../../src/panels/config/automation/trig
import { HaTimeTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-time"; import { HaTimeTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-time";
import { HaTimePatternTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-time_pattern"; import { HaTimePatternTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-time_pattern";
import { HaWebhookTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-webhook"; import { HaWebhookTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-webhook";
import { HaPersistentNotificationTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-persistent_notification";
import { HaZoneTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-zone"; import { HaZoneTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-zone";
import { HaDeviceTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-device"; import { HaDeviceTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-device";
import { HaStateTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-state"; import { HaStateTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-state";
import { HaMQTTTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-mqtt"; import { HaMQTTTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-mqtt";
import "../../../../src/panels/config/automation/trigger/ha-automation-trigger"; import "../../../../src/panels/config/automation/trigger/ha-automation-trigger";
import { HaConversationTrigger } from "../../../../src/panels/config/automation/trigger/types/ha-automation-trigger-conversation";
const SCHEMAS: { name: string; triggers: Trigger[] }[] = [ const SCHEMAS: { name: string; triggers: Trigger[] }[] = [
{ {
@@ -74,16 +72,6 @@ const SCHEMAS: { name: string; triggers: Trigger[] }[] = [
triggers: [{ platform: "webhook", ...HaWebhookTrigger.defaultConfig }], triggers: [{ platform: "webhook", ...HaWebhookTrigger.defaultConfig }],
}, },
{
name: "Persistent Notification",
triggers: [
{
platform: "persistent_notification",
...HaPersistentNotificationTrigger.defaultConfig,
},
],
},
{ {
name: "Zone", name: "Zone",
triggers: [{ platform: "zone", ...HaZoneTrigger.defaultConfig }], triggers: [{ platform: "zone", ...HaZoneTrigger.defaultConfig }],
@@ -113,16 +101,6 @@ const SCHEMAS: { name: string; triggers: Trigger[] }[] = [
name: "Device Trigger", name: "Device Trigger",
triggers: [{ platform: "device", ...HaDeviceTrigger.defaultConfig }], triggers: [{ platform: "device", ...HaDeviceTrigger.defaultConfig }],
}, },
{
name: "Sentence",
triggers: [
{ platform: "conversation", ...HaConversationTrigger.defaultConfig },
{
platform: "conversation",
command: ["Turn on the lights", "Turn the lights on"],
},
],
},
]; ];
@customElement("demo-automation-editor-trigger") @customElement("demo-automation-editor-trigger")
@@ -167,16 +145,17 @@ class DemoHaAutomationEditorTrigger extends LitElement {
.value=${this.data[sampleIdx]} .value=${this.data[sampleIdx]}
> >
${["light", "dark"].map( ${["light", "dark"].map(
(slot) => html` (slot) =>
<ha-automation-trigger html`
slot=${slot} <ha-automation-trigger
.hass=${this.hass} slot=${slot}
.triggers=${this.data[sampleIdx]} .hass=${this.hass}
.sampleIdx=${sampleIdx} .triggers=${this.data[sampleIdx]}
.disabled=${this._disabled} .sampleIdx=${sampleIdx}
@value-changed=${valueChanged} .disabled=${this._disabled}
></ha-automation-trigger> @value-changed=${valueChanged}
` ></ha-automation-trigger>
`
)} )}
</demo-black-white-row> </demo-black-white-row>
` `

View File

@@ -10,6 +10,7 @@ As a community, we are proud of our logo. Follow these guidelines to ensure it a
![Logo](/images/logo.png) ![Logo](/images/logo.png)
## Using the icon ## Using the icon
Our icon is a shorter and most used version of our logo. The icon can exist without the wordmark, the wordmark should never exist without the icon. Our icon is a shorter and most used version of our logo. The icon can exist without the wordmark, the wordmark should never exist without the icon.
@@ -20,7 +21,7 @@ Our icon is a shorter and most used version of our logo. The icon can exist with
The pretty blue logo with a background shadow, pictured top left, is our primary logo. It should only be used with black, white, and non-duotone photography. The pretty blue logo with a background shadow, pictured top left, is our primary logo. It should only be used with black, white, and non-duotone photography.
When needed you can use our logo without a shadow, as seen as the second variant. When needed you can use our logo without a shadow, as seen as the second variant.
The outlined logo should only be used on packaging. The outlined logo should only be used on packaging.

View File

@@ -11,7 +11,6 @@ subtitle: An alert displays a short, important message in a way that attracts th
</style> </style>
# Alert `<ha-alert>` # Alert `<ha-alert>`
The alert offers four severity levels that set a distinctive icon and color. The alert offers four severity levels that set a distinctive icon and color.
<ha-alert alert-type="error"> <ha-alert alert-type="error">
@@ -36,46 +35,38 @@ The alert offers four severity levels that set a distinctive icon and color.
2. [Implementation](#implementation) 2. [Implementation](#implementation)
### Resources ### Resources
| Type | Link | Status |
| Type | Link | Status | |----------------|----------------------------------|-----------|
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
| Design | <a href="https://www.figma.com/community/file/967153512097289521/Home-Assistant-DesignKit" rel="noopener noreferrer" target="_blank">Home Assistant DesignKit</a> (Figma) | Available | | Design | <a href="https://www.figma.com/community/file/967153512097289521/Home-Assistant-DesignKit" rel="noopener noreferrer" target="_blank">Home Assistant DesignKit</a> (Figma) | Available |
| Implementation | <a href="https://github.com/home-assistant/frontend/blob/dev/src/components/ha-alert.ts" rel="noopener noreferrer" target="_blank">Web Component</a> (GitHub) | Available | | Implementation | <a href="https://github.com/home-assistant/frontend/blob/dev/src/components/ha-alert.ts" rel="noopener noreferrer" target="_blank">Web Component</a> (GitHub) | Available |
## Guidelines ## Guidelines
### Usage ### Usage
An alert displays a short, important message in a way that attracts the user's attention without interrupting the user's task. An alert displays a short, important message in a way that attracts the user's attention without interrupting the user's task.
### Anatomy ### Anatomy
*Documentation coming soon*
_Documentation coming soon_
### Error alert ### Error alert
Error alerts Error alerts
_Real world example coming soon_ *Real world example coming soon*
### Warning alert ### Warning alert
Warning alerts Warning alerts
_Real world example coming soon_ *Real world example coming soon*
### Info alert ### Info alert
Info alerts Info alerts
_Real world example coming soon_ *Real world example coming soon*
### Success alert ### Success alert
Success alerts Success alerts
_Real world example coming soon_ *Real world example coming soon*
### Placement ### Placement
### Accessibility
### Accessibility
(WAI-ARIA: [https://www.w3.org/TR/wai-aria-practices/#alert](https://www.w3.org/TR/wai-aria-practices/#alert)) (WAI-ARIA: [https://www.w3.org/TR/wai-aria-practices/#alert](https://www.w3.org/TR/wai-aria-practices/#alert))
When the component is dynamically displayed, the content is automatically announced by most screen readers. At this time, screen readers do not inform users of alerts that are present when the page loads. When the component is dynamically displayed, the content is automatically announced by most screen readers. At this time, screen readers do not inform users of alerts that are present when the page loads.
@@ -87,7 +78,6 @@ Actions must have a tab index of 0 so that they can be reached by keyboard-only
## Implementation ## Implementation
### Example Usage ### Example Usage
**Alert type** **Alert type**
<ha-alert alert-type="error"> <ha-alert alert-type="error">
@@ -106,12 +96,17 @@ Actions must have a tab index of 0 so that they can be reached by keyboard-only
This is an success alert — check it out! This is an success alert — check it out!
</ha-alert> </ha-alert>
```html ```html
<ha-alert alert-type="error"> This is an error alert — check it out! </ha-alert> <ha-alert alert-type="error">
This is an error alert — check it out!
</ha-alert>
<ha-alert alert-type="warning"> <ha-alert alert-type="warning">
This is a warning alert — check it out! This is a warning alert — check it out!
</ha-alert> </ha-alert>
<ha-alert alert-type="info"> This is an info alert — check it out! </ha-alert> <ha-alert alert-type="info">
This is an info alert — check it out!
</ha-alert>
<ha-alert alert-type="success"> <ha-alert alert-type="success">
This is a success alert — check it out! This is a success alert — check it out!
</ha-alert> </ha-alert>
@@ -159,14 +154,13 @@ The `title ` option should not be used without a description.
**Slotted icon** **Slotted icon**
_Documentation coming soon_ *Documentation coming soon*
### API ### API
**Properties/Attributes** **Properties/Attributes**
| Name | Type | Default | Description | | Name | Type | Default | Description |
| ----------- | ------- | ------- | ----------------------------------------------------- | |-------------|---------|---------|-------------------------------------------------------|
| title | string | `` | Title to display. | | title | string | `` | Title to display. |
| alertType | string | `info` | Severity level that set a distinctive icon and color. | | alertType | string | `info` | Severity level that set a distinctive icon and color. |
| dismissable | boolean | `false` | Gives the option to close the alert. | | dismissable | boolean | `false` | Gives the option to close the alert. |
@@ -176,8 +170,8 @@ _Documentation coming soon_
**Events** **Events**
_Documentation coming soon_ *Documentation coming soon*
**CSS Custom Properties** **CSS Custom Properties**
_Documentation coming soon_ *Documentation coming soon*

View File

@@ -1,3 +0,0 @@
---
title: Control Circular Slider
---

View File

@@ -1,174 +0,0 @@
import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-control-circular-slider";
import "../../../../src/components/ha-slider";
@customElement("demo-components-ha-control-circular-slider")
export class DemoHaCircularSlider extends LitElement {
@state()
private current = 22;
@state()
private low = 19;
@state()
private high = 25;
@state()
private changingLow?: number;
@state()
private changingHigh?: number;
private _lowChanged(ev) {
this.low = ev.detail.value;
}
private _lowChanging(ev) {
this.changingLow = ev.detail.value;
}
private _highChanged(ev) {
this.high = ev.detail.value;
}
private _highChanging(ev) {
this.changingHigh = ev.detail.value;
}
private _currentChanged(ev) {
this.current = ev.currentTarget.value;
}
protected render(): TemplateResult {
return html`
<ha-card>
<div class="card-content">
<p class="title"><b>Config</b></p>
<div class="field">
<p>Current</p>
<ha-slider
min="10"
max="30"
.value=${this.current}
@change=${this._currentChanged}
pin
></ha-slider>
<p>${this.current} °C</p>
</div>
</div>
</ha-card>
<ha-card>
<div class="card-content">
<p class="title"><b>Single</b></p>
<ha-control-circular-slider
@value-changed=${this._lowChanged}
@value-changing=${this._lowChanging}
.value=${this.low}
.current=${this.current}
step="1"
min="10"
max="30"
></ha-control-circular-slider>
<div>
Low: ${this.low} °C
<br />
Changing:
${this.changingLow != null ? `${this.changingLow} °C` : "-"}
</div>
</div>
</ha-card>
<ha-card>
<div class="card-content">
<p class="title"><b>Inverted</b></p>
<ha-control-circular-slider
inverted
@value-changed=${this._highChanged}
@value-changing=${this._highChanging}
.value=${this.high}
.current=${this.current}
step="1"
min="10"
max="30"
></ha-control-circular-slider>
<div>
High: ${this.high} °C
<br />
Changing:
${this.changingHigh != null ? `${this.changingHigh} °C` : "-"}
</div>
</div>
</ha-card>
<ha-card>
<div class="card-content">
<p class="title"><b>Dual</b></p>
<ha-control-circular-slider
dual
@low-changed=${this._lowChanged}
@low-changing=${this._lowChanging}
@high-changed=${this._highChanged}
@high-changing=${this._highChanging}
.low=${this.low}
.high=${this.high}
.current=${this.current}
step="1"
min="10"
max="30"
></ha-control-circular-slider>
<div>
Low value: ${this.low} °C
<br />
Low changing:
${this.changingLow != null ? `${this.changingLow} °C` : "-"}
<br />
High value: ${this.high} °C
<br />
High changing:
${this.changingHigh != null ? `${this.changingHigh} °C` : "-"}
</div>
</div>
</ha-card>
`;
}
static get styles() {
return css`
ha-card {
max-width: 600px;
margin: 24px auto;
}
pre {
margin-top: 0;
margin-bottom: 8px;
}
p {
margin: 0;
}
p.title {
margin-bottom: 12px;
}
ha-control-circular-slider {
--control-circular-slider-color: #ff9800;
}
ha-control-circular-slider[inverted] {
--control-circular-slider-color: #2196f3;
}
ha-control-circular-slider[dual] {
--control-circular-slider-high-color: #2196f3;
--control-circular-slider-low-color: #ff9800;
}
.field {
display: flex;
flex-direction: row;
align-items: center;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-components-ha-control-circular-slider": DemoHaCircularSlider;
}
}

View File

@@ -1,3 +0,0 @@
---
title: Control Number Buttons
---

View File

@@ -1,100 +0,0 @@
import { LitElement, TemplateResult, css, html } from "lit";
import { customElement, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-control-number-buttons";
import { repeat } from "lit/directives/repeat";
import { ifDefined } from "lit/directives/if-defined";
const buttons: {
id: string;
label: string;
min?: number;
max?: number;
step?: number;
class?: string;
}[] = [
{
id: "basic",
label: "Basic",
},
{
id: "min_max_step",
label: "With min/max and step",
min: 5,
max: 25,
step: 0.5,
},
{
id: "custom",
label: "Custom",
class: "custom",
},
];
@customElement("demo-components-ha-control-number-buttons")
export class DemoHarControlNumberButtons extends LitElement {
@state() value = 5;
private _valueChanged(ev) {
this.value = ev.detail.value;
}
protected render(): TemplateResult {
return html`
${repeat(buttons, (button) => {
const { id, label, ...config } = button;
return html`
<ha-card>
<div class="card-content">
<label id=${id}>${label}</label>
<pre>Config: ${JSON.stringify(config)}</pre>
<ha-control-number-buttons
.value=${this.value}
.min=${config.min}
.max=${config.max}
.step=${config.step}
class=${ifDefined(config.class)}
@value-changed=${this._valueChanged}
.label=${label}
>
</ha-control-number-buttons>
</div>
</ha-card>
`;
})}
`;
}
static get styles() {
return css`
ha-card {
max-width: 600px;
margin: 24px auto;
}
pre {
margin-top: 0;
margin-bottom: 8px;
}
p {
margin: 0;
}
label {
font-weight: 600;
}
.custom {
color: #2196f3;
--control-number-buttons-color: #2196f3;
--control-number-buttons-background-color: #2196f3;
--control-number-buttons-background-opacity: 0.1;
--control-number-buttons-thickness: 100px;
--control-number-buttons-border-radius: 24px;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-components-ha-control-number-buttons": DemoHarControlNumberButtons;
}
}

View File

@@ -1,3 +0,0 @@
---
title: Control Select Menu
---

View File

@@ -1,146 +0,0 @@
import { mdiFan, mdiFanSpeed1, mdiFanSpeed2, mdiFanSpeed3 } from "@mdi/js";
import { LitElement, TemplateResult, css, html, nothing } from "lit";
import { customElement } from "lit/decorators";
import { repeat } from "lit/directives/repeat";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-control-select-menu";
import "../../../../src/components/ha-list-item";
import "../../../../src/components/ha-svg-icon";
type SelectMenuOptions = {
label: string;
value: string;
icon?: string;
};
type SelectMenu = {
label: string;
icon: string;
class?: string;
disabled?: boolean;
options: SelectMenuOptions[];
};
const selects: SelectMenu[] = [
{
label: "Basic select",
icon: mdiFan,
options: [
{
value: "low",
label: "Low",
},
{
value: "medium",
label: "Medium",
},
{
value: "high",
label: "High",
},
],
},
{
label: "Select with icons",
icon: mdiFan,
options: [
{
value: "low",
label: "Low",
icon: mdiFanSpeed1,
},
{
value: "medium",
label: "Medium",
icon: mdiFanSpeed2,
},
{
value: "high",
label: "High",
icon: mdiFanSpeed3,
},
],
},
{
label: "Disabled select",
icon: mdiFan,
options: [],
disabled: true,
},
];
@customElement("demo-components-ha-control-select-menu")
export class DemoHaControlSelectMenu extends LitElement {
protected render(): TemplateResult {
return html`
<ha-card>
${repeat(
selects,
(select) => html`
<div class="card-content">
<ha-control-select-menu
.label=${select.label}
?disabled=${select.disabled}
fixedMenuPosition
naturalMenuWidth
>
<ha-svg-icon slot="icon" .path=${select.icon}></ha-svg-icon>
${select.options.map(
(option) => html`
<ha-list-item
.value=${option.value}
.graphic=${option.icon ? "icon" : undefined}
>
${option.icon
? html`
<ha-svg-icon
slot="graphic"
.path=${option.icon}
></ha-svg-icon>
`
: nothing}
${option.label ?? option.value}
</ha-list-item>
`
)}
</ha-control-select-menu>
</div>
`
)}
</ha-card>
`;
}
static get styles() {
return css`
ha-card {
max-width: 600px;
margin: 24px auto;
}
pre {
margin-top: 0;
margin-bottom: 8px;
}
p {
margin: 0;
}
label {
font-weight: 600;
}
.custom {
--control-button-icon-color: var(--primary-color);
--control-button-background-color: var(--primary-color);
--control-button-background-opacity: 0.2;
--control-button-border-radius: 18px;
height: 100px;
width: 100px;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-components-ha-control-select-menu": DemoHaControlSelectMenu;
}
}

View File

@@ -5,32 +5,28 @@ subtitle: Dialogs provide important prompts in a user flow.
# Material Design 3 # Material Design 3
Our dialogs are based on the latest version of Material Design. Specs and guidelines can be found on its [website](https://m3.material.io/components/dialogs/overview). Our dialogs are based on the latest version of Material Design. Specs and guidelines can be found on its [website](https://m3.material.io/components/dialogs/overview).
# Highlighted guidelines # Highlighted guidelines
## Content ## Content
* A best practice is to always use a title, even if it is optional by Material guidelines.
- A best practice is to always use a title, even if it is optional by Material guidelines. * People mainly read the title and a button. Put the most important information in those two.
- People mainly read the title and a button. Put the most important information in those two. * Try to avoid user generated content in the title, this could make the title unreadable long.
- Try to avoid user generated content in the title, this could make the title unreadable long. * If users become unsure, they read the description. Make sure this explains what will happen.
- If users become unsure, they read the description. Make sure this explains what will happen. * Strive for minimalism.
- Strive for minimalism.
## Buttons and X-icon ## Buttons and X-icon
* Keep the labels short, for example `Save`, `Delete`, `Enable`.
- Keep the labels short, for example `Save`, `Delete`, `Enable`. * Dialog with actions must always have a discard button. On desktop a `Cancel` button and X-icon, on mobile only the X-icon.
- Dialog with actions must always have a discard button. On desktop a `Cancel` button and X-icon, on mobile only the X-icon. * Destructive actions should be a red warning button.
- Destructive actions should be a red warning button. * Alert or confirmation dialogs only have buttons and no X-icon.
- Alert or confirmation dialogs only have buttons and no X-icon. * Try to avoid three buttons in one dialog. Especially when you leave the dialog task unfinished.
- Try to avoid three buttons in one dialog. Especially when you leave the dialog task unfinished.
## Example ## Example
### Confirmation dialog ### Confirmation dialog
> **Delete dashboard?** > **Delete dashboard?**
> >
> Dashboard [dashboard name] will be permanently deleted from Home Assistant. > Dashboard [dashboard name] will be permanently deleted from Home Assistant.
> >
> Cancel / Delete > Cancel / Delete

View File

@@ -32,6 +32,7 @@ Error color gauge
Gauge with background color Gauge with background color
<ha-gauge value="75" style="--gauge-color: var(--info-color); --primary-background-color: lightgray"></ha-gauge> <ha-gauge value="75" style="--gauge-color: var(--info-color); --primary-background-color: lightgray"></ha-gauge>
## CSS variables ## CSS variables
### Gauge ### Gauge

View File

@@ -497,23 +497,24 @@ class DemoHaSelector extends LitElement implements ProvideHassElement {
<demo-black-white-row .title=${info.name} .value=${this.data[idx]}> <demo-black-white-row .title=${info.name} .value=${this.data[idx]}>
${["light", "dark"].map((slot) => ${["light", "dark"].map((slot) =>
Object.entries(info.input).map( Object.entries(info.input).map(
([key, value]) => html` ([key, value]) =>
<ha-settings-row narrow slot=${slot}> html`
<span slot="heading">${value?.name || key}</span> <ha-settings-row narrow slot=${slot}>
<span slot="description">${value?.description}</span> <span slot="heading">${value?.name || key}</span>
<ha-selector <span slot="description">${value?.description}</span>
.hass=${this.hass} <ha-selector
.selector=${value!.selector} .hass=${this.hass}
.key=${key} .selector=${value!.selector}
.label=${this._label ? value!.name : undefined} .key=${key}
.value=${data[key] ?? value!.default} .label=${this._label ? value!.name : undefined}
.disabled=${this._disabled} .value=${data[key] ?? value!.default}
.required=${this._required} .disabled=${this._disabled}
@value-changed=${valueChanged} .required=${this._required}
.helper=${this._helper ? "Helper text" : undefined} @value-changed=${valueChanged}
></ha-selector> .helper=${this._helper ? "Helper text" : undefined}
</ha-settings-row> ></ha-selector>
` </ha-settings-row>
`
) )
)} )}
</demo-black-white-row> </demo-black-white-row>

View File

@@ -30,7 +30,7 @@ For the switch / toggle there are always two variables, one for the on / checked
The track element (background rounded rectangle that the round circular handle travels on) is set to being half transparent, so the final color will also be impacted by the color behind the track. The track element (background rounded rectangle that the round circular handle travels on) is set to being half transparent, so the final color will also be impacted by the color behind the track.
`switch-checked-color` / `switch-unchecked-color` `switch-checked-color` / `switch-unchecked-color`
Set both the color of the round handle and the track behind it. If you want to control them separately, use the variables below instead. Set both the color of the round handle and the track behind it. If you want to control them separately, use the variables below instead.
`switch-checked-button-color` / `switch-unchecked-button-color` `switch-checked-button-color` / `switch-unchecked-button-color`
Color of the round handle Color of the round handle

View File

@@ -20,8 +20,9 @@ export class DemoHaTip extends LitElement {
<ha-card header="ha-tip ${mode} demo"> <ha-card header="ha-tip ${mode} demo">
<div class="card-content"> <div class="card-content">
${tips.map( ${tips.map(
(tip) => (tip) => html`<ha-tip .hass=${provideHass(this)}
html`<ha-tip .hass=${provideHass(this)}>${tip}</ha-tip>` >${tip}</ha-tip
>`
)} )}
</div> </div>
</ha-card> </ha-card>

View File

@@ -7,21 +7,18 @@ title: Home
This portal aims to aid designers and developers on improving the Home Assistant interface. It consists of working code, resources and guidelines. This portal aims to aid designers and developers on improving the Home Assistant interface. It consists of working code, resources and guidelines.
## Home Assistant interface ## Home Assistant interface
The Home Assistant frontend allows users to browse and control the state of their home, manage their automations and configure integrations. The frontend is designed as a mobile-first experience. It is a progressive web application and offers an app-like experience to our users. The Home Assistant frontend needs to be fast. But it also needs to work on a wide range of old devices. The Home Assistant frontend allows users to browse and control the state of their home, manage their automations and configure integrations. The frontend is designed as a mobile-first experience. It is a progressive web application and offers an app-like experience to our users. The Home Assistant frontend needs to be fast. But it also needs to work on a wide range of old devices.
### Material Design ### Material Design
The Home Assistant interface is based on Material Design. It's a design system created by Google to quickly build high-quality digital experiences. Components and guidelines that are custom made for Home Assistant are documented on this portal. For all other components check <a href="https://material.io" rel="noopener noreferrer" target="_blank">material.io</a>. The Home Assistant interface is based on Material Design. It's a design system created by Google to quickly build high-quality digital experiences. Components and guidelines that are custom made for Home Assistant are documented on this portal. For all other components check <a href="https://material.io" rel="noopener noreferrer" target="_blank">material.io</a>.
## Designers ## Designers
We want to make it as easy for designers to contribute as it is for developers. Theres a lot a designer can contribute to: We want to make it as easy for designers to contribute as it is for developers. Theres a lot a designer can contribute to:
- Meet us at <a href="https://discord.gg/BPBc8rZ9" rel="noopener noreferrer" target="_blank">devs_ux Discord</a>. Feel free to share your designs, user test or strategic ideas. - Meet us at <a href="https://discord.gg/BPBc8rZ9" rel="noopener noreferrer" target="_blank">devs_ux Discord</a>. Feel free to share your designs, user test or strategic ideas.
- Start designing with our <a href="https://www.figma.com/community/file/967153512097289521/Home-Assistant-DesignKit" rel="noopener noreferrer" target="_blank">Figma DesignKit</a>. - Start designing with our <a href="https://www.figma.com/community/file/967153512097289521/Home-Assistant-DesignKit" rel="noopener noreferrer" target="_blank">Figma DesignKit</a>.
- Find the latest UX <a href="https://github.com/home-assistant/frontend/discussions?discussions_q=label%3Aux" rel="noopener noreferrer" target="_blank">discussions</a> and <a href="https://github.com/home-assistant/frontend/labels/ux" rel="noopener noreferrer" target="_blank">issues</a> on GitHub. Everyone can start a new issue or discussion! - Find the lates UX <a href="https://github.com/home-assistant/frontend/discussions?discussions_q=label%3Aux" rel="noopener noreferrer" target="_blank">discussions</a> and <a href="https://github.com/home-assistant/frontend/labels/ux" rel="noopener noreferrer" target="_blank">issues</a> on GitHub. Everyone can start a new issue or discussion!
## Developers ## Developers
Everything you need to get started developing can be found in our <a href="https://developers.home-assistant.io" rel="noopener noreferrer" target="_blank">Home Assistant Developer Docs</a>. Everything you need to get started developing can be found in our <a href="https://developers.home-assistant.io" rel="noopener noreferrer" target="_blank">Home Assistant Developer Docs</a>.

View File

@@ -1,7 +0,0 @@
---
title: Date-Time Format (Numeric)
---
This pages lists all supported languages with their available date-time formats.
Formatting function: `const formatDateTimeNumeric: (dateObj: Date, locale: FrontendLocaleData) => string`

View File

@@ -1,136 +0,0 @@
import { html, css, LitElement } from "lit";
import { customElement, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-control-select";
import { translationMetadata } from "../../../../src/resources/translations-metadata";
import { formatDateTimeNumeric } from "../../../../src/common/datetime/format_date_time";
import { timeOptions } from "../../data/date-options";
import { demoConfig } from "../../../../src/fake_data/demo_config";
import {
FrontendLocaleData,
NumberFormat,
TimeFormat,
DateFormat,
FirstWeekday,
TimeZone,
} from "../../../../src/data/translation";
@customElement("demo-date-time-date-time-numeric")
export class DemoDateTimeDateTimeNumeric extends LitElement {
@state() private selection?: string = "now";
@state() private date: Date = new Date();
handleValueChanged(e: CustomEvent) {
this.selection = e.detail.value as string;
this.date = new Date();
if (this.selection !== "now") {
const [hours, minutes, seconds] = this.selection.split(":").map(Number);
this.date.setHours(hours);
this.date.setMinutes(minutes);
this.date.setSeconds(seconds);
}
}
protected render() {
const defaultLocale: FrontendLocaleData = {
language: "en",
number_format: NumberFormat.language,
time_format: TimeFormat.language,
date_format: DateFormat.language,
first_weekday: FirstWeekday.language,
time_zone: TimeZone.local,
};
return html`
<ha-control-select
.value=${this.selection}
.options=${timeOptions}
@value-changed=${this.handleValueChanged}
>
</ha-control-select>
<mwc-list>
<div class="container header">
<div>Language</div>
<div class="center">Default (lang)</div>
<div class="center">12 Hours</div>
<div class="center">24 Hours</div>
</div>
${Object.entries(translationMetadata.translations)
.filter(([key, _]) => key !== "test")
.map(
([key, value]) => html`
<div class="container">
<div>${value.nativeName}</div>
<div class="center">
${formatDateTimeNumeric(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.language,
},
demoConfig
)}
</div>
<div class="center">
${formatDateTimeNumeric(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.am_pm,
},
demoConfig
)}
</div>
<div class="center">
${formatDateTimeNumeric(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.twenty_four,
},
demoConfig
)}
</div>
</div>
`
)}
</mwc-list>
`;
}
static get styles() {
return css`
ha-control-select {
max-width: 800px;
margin: 12px auto;
}
.header {
font-weight: bold;
}
.center {
text-align: center;
}
.container {
max-width: 900px;
margin: 12px auto;
display: flex;
align-items: center;
justify-content: space-evenly;
}
.container > div {
flex-grow: 1;
width: 20%;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-date-time-date-time-numeric": DemoDateTimeDateTimeNumeric;
}
}

View File

@@ -1,7 +0,0 @@
---
title: Date-Time Format (Seconds)
---
This pages lists all supported languages with their available date-time formats.
Formatting function: `const formatDateTimeWithSeconds: (dateObj: Date, locale: FrontendLocaleData) => string`

View File

@@ -1,136 +0,0 @@
import { html, css, LitElement } from "lit";
import { customElement, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-control-select";
import { translationMetadata } from "../../../../src/resources/translations-metadata";
import { formatDateTimeWithSeconds } from "../../../../src/common/datetime/format_date_time";
import { timeOptions } from "../../data/date-options";
import { demoConfig } from "../../../../src/fake_data/demo_config";
import {
FrontendLocaleData,
NumberFormat,
TimeFormat,
DateFormat,
FirstWeekday,
TimeZone,
} from "../../../../src/data/translation";
@customElement("demo-date-time-date-time-seconds")
export class DemoDateTimeDateTimeSeconds extends LitElement {
@state() private selection?: string = "now";
@state() private date: Date = new Date();
handleValueChanged(e: CustomEvent) {
this.selection = e.detail.value as string;
this.date = new Date();
if (this.selection !== "now") {
const [hours, minutes, seconds] = this.selection.split(":").map(Number);
this.date.setHours(hours);
this.date.setMinutes(minutes);
this.date.setSeconds(seconds);
}
}
protected render() {
const defaultLocale: FrontendLocaleData = {
language: "en",
number_format: NumberFormat.language,
time_format: TimeFormat.language,
date_format: DateFormat.language,
first_weekday: FirstWeekday.language,
time_zone: TimeZone.local,
};
return html`
<ha-control-select
.value=${this.selection}
.options=${timeOptions}
@value-changed=${this.handleValueChanged}
>
</ha-control-select>
<mwc-list>
<div class="container header">
<div>Language</div>
<div class="center">Default (lang)</div>
<div class="center">12 Hours</div>
<div class="center">24 Hours</div>
</div>
${Object.entries(translationMetadata.translations)
.filter(([key, _]) => key !== "test")
.map(
([key, value]) => html`
<div class="container">
<div>${value.nativeName}</div>
<div class="center">
${formatDateTimeWithSeconds(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.language,
},
demoConfig
)}
</div>
<div class="center">
${formatDateTimeWithSeconds(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.am_pm,
},
demoConfig
)}
</div>
<div class="center">
${formatDateTimeWithSeconds(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.twenty_four,
},
demoConfig
)}
</div>
</div>
`
)}
</mwc-list>
`;
}
static get styles() {
return css`
ha-control-select {
max-width: 800px;
margin: 12px auto;
}
.header {
font-weight: bold;
}
.center {
text-align: center;
}
.container {
max-width: 900px;
margin: 12px auto;
display: flex;
align-items: center;
justify-content: space-evenly;
}
.container > div {
flex-grow: 1;
width: 20%;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-date-time-date-time-seconds": DemoDateTimeDateTimeSeconds;
}
}

View File

@@ -1,7 +0,0 @@
---
title: Date-Time Format (Short w/ Year)
---
This pages lists all supported languages with their available date-time formats.
Formatting function: `const formatShortDateTimeWithYear: (dateObj: Date, locale: FrontendLocaleData) => string`

View File

@@ -1,136 +0,0 @@
import { html, css, LitElement } from "lit";
import { customElement, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-control-select";
import { translationMetadata } from "../../../../src/resources/translations-metadata";
import { formatShortDateTimeWithYear } from "../../../../src/common/datetime/format_date_time";
import { timeOptions } from "../../data/date-options";
import { demoConfig } from "../../../../src/fake_data/demo_config";
import {
FrontendLocaleData,
NumberFormat,
TimeFormat,
DateFormat,
FirstWeekday,
TimeZone,
} from "../../../../src/data/translation";
@customElement("demo-date-time-date-time-short-year")
export class DemoDateTimeDateTimeShortYear extends LitElement {
@state() private selection?: string = "now";
@state() private date: Date = new Date();
handleValueChanged(e: CustomEvent) {
this.selection = e.detail.value as string;
this.date = new Date();
if (this.selection !== "now") {
const [hours, minutes, seconds] = this.selection.split(":").map(Number);
this.date.setHours(hours);
this.date.setMinutes(minutes);
this.date.setSeconds(seconds);
}
}
protected render() {
const defaultLocale: FrontendLocaleData = {
language: "en",
number_format: NumberFormat.language,
time_format: TimeFormat.language,
date_format: DateFormat.language,
first_weekday: FirstWeekday.language,
time_zone: TimeZone.local,
};
return html`
<ha-control-select
.value=${this.selection}
.options=${timeOptions}
@value-changed=${this.handleValueChanged}
>
</ha-control-select>
<mwc-list>
<div class="container header">
<div>Language</div>
<div class="center">Default (lang)</div>
<div class="center">12 Hours</div>
<div class="center">24 Hours</div>
</div>
${Object.entries(translationMetadata.translations)
.filter(([key, _]) => key !== "test")
.map(
([key, value]) => html`
<div class="container">
<div>${value.nativeName}</div>
<div class="center">
${formatShortDateTimeWithYear(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.language,
},
demoConfig
)}
</div>
<div class="center">
${formatShortDateTimeWithYear(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.am_pm,
},
demoConfig
)}
</div>
<div class="center">
${formatShortDateTimeWithYear(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.twenty_four,
},
demoConfig
)}
</div>
</div>
`
)}
</mwc-list>
`;
}
static get styles() {
return css`
ha-control-select {
max-width: 800px;
margin: 12px auto;
}
.header {
font-weight: bold;
}
.center {
text-align: center;
}
.container {
max-width: 900px;
margin: 12px auto;
display: flex;
align-items: center;
justify-content: space-evenly;
}
.container > div {
flex-grow: 1;
width: 20%;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-date-time-date-time-short-year": DemoDateTimeDateTimeShortYear;
}
}

View File

@@ -1,7 +0,0 @@
---
title: Date-Time Format (Short)
---
This pages lists all supported languages with their available date-time formats.
Formatting function: `const formatShortDateTime: (dateObj: Date, locale: FrontendLocaleData) => string`

View File

@@ -1,136 +0,0 @@
import { html, css, LitElement } from "lit";
import { customElement, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-control-select";
import { translationMetadata } from "../../../../src/resources/translations-metadata";
import { formatShortDateTime } from "../../../../src/common/datetime/format_date_time";
import { timeOptions } from "../../data/date-options";
import { demoConfig } from "../../../../src/fake_data/demo_config";
import {
FrontendLocaleData,
NumberFormat,
TimeFormat,
DateFormat,
FirstWeekday,
TimeZone,
} from "../../../../src/data/translation";
@customElement("demo-date-time-date-time-short")
export class DemoDateTimeDateTimeShort extends LitElement {
@state() private selection?: string = "now";
@state() private date: Date = new Date();
handleValueChanged(e: CustomEvent) {
this.selection = e.detail.value as string;
this.date = new Date();
if (this.selection !== "now") {
const [hours, minutes, seconds] = this.selection.split(":").map(Number);
this.date.setHours(hours);
this.date.setMinutes(minutes);
this.date.setSeconds(seconds);
}
}
protected render() {
const defaultLocale: FrontendLocaleData = {
language: "en",
number_format: NumberFormat.language,
time_format: TimeFormat.language,
date_format: DateFormat.language,
first_weekday: FirstWeekday.language,
time_zone: TimeZone.local,
};
return html`
<ha-control-select
.value=${this.selection}
.options=${timeOptions}
@value-changed=${this.handleValueChanged}
>
</ha-control-select>
<mwc-list>
<div class="container header">
<div>Language</div>
<div class="center">Default (lang)</div>
<div class="center">12 Hours</div>
<div class="center">24 Hours</div>
</div>
${Object.entries(translationMetadata.translations)
.filter(([key, _]) => key !== "test")
.map(
([key, value]) => html`
<div class="container">
<div>${value.nativeName}</div>
<div class="center">
${formatShortDateTime(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.language,
},
demoConfig
)}
</div>
<div class="center">
${formatShortDateTime(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.am_pm,
},
demoConfig
)}
</div>
<div class="center">
${formatShortDateTime(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.twenty_four,
},
demoConfig
)}
</div>
</div>
`
)}
</mwc-list>
`;
}
static get styles() {
return css`
ha-control-select {
max-width: 800px;
margin: 12px auto;
}
.header {
font-weight: bold;
}
.center {
text-align: center;
}
.container {
max-width: 900px;
margin: 12px auto;
display: flex;
align-items: center;
justify-content: space-evenly;
}
.container > div {
flex-grow: 1;
width: 20%;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-date-time-date-time-short": DemoDateTimeDateTimeShort;
}
}

View File

@@ -1,7 +0,0 @@
---
title: Date-Time Format
---
This pages lists all supported languages with their available date-time formats.
Formatting function: `const formatDateTime: (dateObj: Date, locale: FrontendLocaleData) => string`

View File

@@ -1,136 +0,0 @@
import { html, css, LitElement } from "lit";
import { customElement, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-control-select";
import { translationMetadata } from "../../../../src/resources/translations-metadata";
import { formatDateTime } from "../../../../src/common/datetime/format_date_time";
import { timeOptions } from "../../data/date-options";
import { demoConfig } from "../../../../src/fake_data/demo_config";
import {
FrontendLocaleData,
NumberFormat,
TimeFormat,
DateFormat,
FirstWeekday,
TimeZone,
} from "../../../../src/data/translation";
@customElement("demo-date-time-date-time")
export class DemoDateTimeDateTime extends LitElement {
@state() private selection?: string = "now";
@state() private date: Date = new Date();
handleValueChanged(e: CustomEvent) {
this.selection = e.detail.value as string;
this.date = new Date();
if (this.selection !== "now") {
const [hours, minutes, seconds] = this.selection.split(":").map(Number);
this.date.setHours(hours);
this.date.setMinutes(minutes);
this.date.setSeconds(seconds);
}
}
protected render() {
const defaultLocale: FrontendLocaleData = {
language: "en",
number_format: NumberFormat.language,
time_format: TimeFormat.language,
date_format: DateFormat.language,
first_weekday: FirstWeekday.language,
time_zone: TimeZone.local,
};
return html`
<ha-control-select
.value=${this.selection}
.options=${timeOptions}
@value-changed=${this.handleValueChanged}
>
</ha-control-select>
<mwc-list>
<div class="container header">
<div>Language</div>
<div class="center">Default (lang)</div>
<div class="center">12 Hours</div>
<div class="center">24 Hours</div>
</div>
${Object.entries(translationMetadata.translations)
.filter(([key, _]) => key !== "test")
.map(
([key, value]) => html`
<div class="container">
<div>${value.nativeName}</div>
<div class="center">
${formatDateTime(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.language,
},
demoConfig
)}
</div>
<div class="center">
${formatDateTime(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.am_pm,
},
demoConfig
)}
</div>
<div class="center">
${formatDateTime(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.twenty_four,
},
demoConfig
)}
</div>
</div>
`
)}
</mwc-list>
`;
}
static get styles() {
return css`
ha-control-select {
max-width: 800px;
margin: 12px auto;
}
.header {
font-weight: bold;
}
.center {
text-align: center;
}
.container {
max-width: 900px;
margin: 12px auto;
display: flex;
align-items: center;
justify-content: space-evenly;
}
.container > div {
flex-grow: 1;
width: 20%;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-date-time-date-time": DemoDateTimeDateTime;
}
}

View File

@@ -1,7 +1,7 @@
--- ---
title: Date Format (Numeric) title: (Numeric) Date Formatting
--- ---
This pages lists all supported languages with their available (numeric) date formats. This pages lists all supported languages with their available (numeric) date formats.
Formatting function: `const formatDateNumeric: (dateObj: Date, locale: FrontendLocaleData) => string` Formatting function: `const formatDateNumeric: (dateObj: Date, locale: FrontendLocaleData) => string`

View File

@@ -1,28 +1,27 @@
import "@material/mwc-list/mwc-list"; import { html, css, LitElement } from "lit";
import { css, html, LitElement } from "lit"; import { customElement, property } from "lit/decorators";
import { customElement } from "lit/decorators";
import { formatDateNumeric } from "../../../../src/common/datetime/format_date";
import "../../../../src/components/ha-card"; import "../../../../src/components/ha-card";
import { HomeAssistant } from "../../../../src/types";
import { translationMetadata } from "../../../../src/resources/translations-metadata";
import { formatDateNumeric } from "../../../../src/common/datetime/format_date";
import { import {
DateFormat,
FirstWeekday,
FrontendLocaleData, FrontendLocaleData,
NumberFormat, NumberFormat,
TimeFormat, TimeFormat,
TimeZone, DateFormat,
FirstWeekday,
} from "../../../../src/data/translation"; } from "../../../../src/data/translation";
import { demoConfig } from "../../../../src/fake_data/demo_config";
import { translationMetadata } from "../../../../src/resources/translations-metadata";
@customElement("demo-date-time-date") @customElement("demo-date-time-date")
export class DemoDateTimeDate extends LitElement { export class DemoDateTimeDate extends LitElement {
@property({ attribute: false }) hass!: HomeAssistant;
protected render() { protected render() {
const defaultLocale: FrontendLocaleData = { const defaultLocale: FrontendLocaleData = {
language: "en", language: "en",
number_format: NumberFormat.language, number_format: NumberFormat.language,
time_format: TimeFormat.language, time_format: TimeFormat.language,
date_format: DateFormat.language, date_format: DateFormat.language,
time_zone: TimeZone.local,
first_weekday: FirstWeekday.language, first_weekday: FirstWeekday.language,
}; };
const date = new Date(); const date = new Date();
@@ -42,48 +41,32 @@ export class DemoDateTimeDate extends LitElement {
<div class="container"> <div class="container">
<div>${value.nativeName}</div> <div>${value.nativeName}</div>
<div class="center"> <div class="center">
${formatDateNumeric( ${formatDateNumeric(date, {
date, ...defaultLocale,
{ language: key,
...defaultLocale, date_format: DateFormat.language,
language: key, })}
date_format: DateFormat.language,
},
demoConfig
)}
</div> </div>
<div class="center"> <div class="center">
${formatDateNumeric( ${formatDateNumeric(date, {
date, ...defaultLocale,
{ language: key,
...defaultLocale, date_format: DateFormat.DMY,
language: key, })}
date_format: DateFormat.DMY,
},
demoConfig
)}
</div> </div>
<div class="center"> <div class="center">
${formatDateNumeric( ${formatDateNumeric(date, {
date, ...defaultLocale,
{ language: key,
...defaultLocale, date_format: DateFormat.MDY,
language: key, })}
date_format: DateFormat.MDY,
},
demoConfig
)}
</div> </div>
<div class="center"> <div class="center">
${formatDateNumeric( ${formatDateNumeric(date, {
date, ...defaultLocale,
{ language: key,
...defaultLocale, date_format: DateFormat.YMD,
language: key, })}
date_format: DateFormat.YMD,
},
demoConfig
)}
</div> </div>
</div> </div>
` `

View File

@@ -1,7 +0,0 @@
---
title: Time Format (Seconds)
---
This pages lists all supported languages with their available time formats.
Formatting function: `const formatTimeWithSeconds: (dateObj: Date, locale: FrontendLocaleData) => string`

View File

@@ -1,135 +0,0 @@
import { html, css, LitElement } from "lit";
import { customElement, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import { translationMetadata } from "../../../../src/resources/translations-metadata";
import { formatTimeWithSeconds } from "../../../../src/common/datetime/format_time";
import { timeOptions } from "../../data/date-options";
import { demoConfig } from "../../../../src/fake_data/demo_config";
import {
FrontendLocaleData,
NumberFormat,
TimeFormat,
DateFormat,
FirstWeekday,
TimeZone,
} from "../../../../src/data/translation";
@customElement("demo-date-time-time-seconds")
export class DemoDateTimeTimeSeconds extends LitElement {
@state() private selection?: string = "now";
@state() private date: Date = new Date();
handleValueChanged(e: CustomEvent) {
this.selection = e.detail.value as string;
this.date = new Date();
if (this.selection !== "now") {
const [hours, minutes, seconds] = this.selection.split(":").map(Number);
this.date.setHours(hours);
this.date.setMinutes(minutes);
this.date.setSeconds(seconds);
}
}
protected render() {
const defaultLocale: FrontendLocaleData = {
language: "en",
number_format: NumberFormat.language,
time_format: TimeFormat.language,
date_format: DateFormat.language,
first_weekday: FirstWeekday.language,
time_zone: TimeZone.local,
};
return html`
<ha-control-select
.value=${this.selection}
.options=${timeOptions}
@value-changed=${this.handleValueChanged}
>
</ha-control-select>
<mwc-list>
<div class="container header">
<div>Language</div>
<div class="center">Default (lang)</div>
<div class="center">12 Hours</div>
<div class="center">24 Hours</div>
</div>
${Object.entries(translationMetadata.translations)
.filter(([key, _]) => key !== "test")
.map(
([key, value]) => html`
<div class="container">
<div>${value.nativeName}</div>
<div class="center">
${formatTimeWithSeconds(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.language,
},
demoConfig
)}
</div>
<div class="center">
${formatTimeWithSeconds(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.am_pm,
},
demoConfig
)}
</div>
<div class="center">
${formatTimeWithSeconds(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.twenty_four,
},
demoConfig
)}
</div>
</div>
`
)}
</mwc-list>
`;
}
static get styles() {
return css`
ha-control-select {
max-width: 800px;
margin: 12px auto;
}
.header {
font-weight: bold;
}
.center {
text-align: center;
}
.container {
max-width: 600px;
margin: 12px auto;
display: flex;
align-items: center;
justify-content: space-evenly;
}
.container > div {
flex-grow: 1;
width: 20%;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-date-time-time-seconds": DemoDateTimeTimeSeconds;
}
}

View File

@@ -1,7 +0,0 @@
---
title: Time Format (Weekday)
---
This pages lists all supported languages with their available time formats.
Formatting function: `const formatTimeWeekday: (dateObj: Date, locale: FrontendLocaleData) => string`

View File

@@ -1,135 +0,0 @@
import { html, css, LitElement } from "lit";
import { customElement, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import { translationMetadata } from "../../../../src/resources/translations-metadata";
import { formatTimeWeekday } from "../../../../src/common/datetime/format_time";
import { timeOptions } from "../../data/date-options";
import { demoConfig } from "../../../../src/fake_data/demo_config";
import {
FrontendLocaleData,
NumberFormat,
TimeFormat,
DateFormat,
FirstWeekday,
TimeZone,
} from "../../../../src/data/translation";
@customElement("demo-date-time-time-weekday")
export class DemoDateTimeTimeWeekday extends LitElement {
@state() private selection?: string = "now";
@state() private date: Date = new Date();
handleValueChanged(e: CustomEvent) {
this.selection = e.detail.value as string;
this.date = new Date();
if (this.selection !== "now") {
const [hours, minutes, seconds] = this.selection.split(":").map(Number);
this.date.setHours(hours);
this.date.setMinutes(minutes);
this.date.setSeconds(seconds);
}
}
protected render() {
const defaultLocale: FrontendLocaleData = {
language: "en",
number_format: NumberFormat.language,
time_format: TimeFormat.language,
date_format: DateFormat.language,
first_weekday: FirstWeekday.language,
time_zone: TimeZone.local,
};
return html`
<ha-control-select
.value=${this.selection}
.options=${timeOptions}
@value-changed=${this.handleValueChanged}
>
</ha-control-select>
<mwc-list>
<div class="container header">
<div>Language</div>
<div class="center">Default (lang)</div>
<div class="center">12 Hours</div>
<div class="center">24 Hours</div>
</div>
${Object.entries(translationMetadata.translations)
.filter(([key, _]) => key !== "test")
.map(
([key, value]) => html`
<div class="container">
<div>${value.nativeName}</div>
<div class="center">
${formatTimeWeekday(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.language,
},
demoConfig
)}
</div>
<div class="center">
${formatTimeWeekday(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.am_pm,
},
demoConfig
)}
</div>
<div class="center">
${formatTimeWeekday(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.twenty_four,
},
demoConfig
)}
</div>
</div>
`
)}
</mwc-list>
`;
}
static get styles() {
return css`
ha-control-select {
max-width: 800px;
margin: 12px auto;
}
.header {
font-weight: bold;
}
.center {
text-align: center;
}
.container {
max-width: 800px;
margin: 12px auto;
display: flex;
align-items: center;
justify-content: space-evenly;
}
.container > div {
flex-grow: 1;
width: 20%;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-date-time-time-weekday": DemoDateTimeTimeWeekday;
}
}

View File

@@ -1,7 +0,0 @@
---
title: Time Format
---
This pages lists all supported languages with their available time formats.
Formatting function: `const formatTime: (dateObj: Date, locale: FrontendLocaleData) => string`

View File

@@ -1,136 +0,0 @@
import { html, css, LitElement } from "lit";
import { customElement, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-control-select";
import { translationMetadata } from "../../../../src/resources/translations-metadata";
import { formatTime } from "../../../../src/common/datetime/format_time";
import { timeOptions } from "../../data/date-options";
import { demoConfig } from "../../../../src/fake_data/demo_config";
import {
FrontendLocaleData,
NumberFormat,
TimeFormat,
DateFormat,
FirstWeekday,
TimeZone,
} from "../../../../src/data/translation";
@customElement("demo-date-time-time")
export class DemoDateTimeTime extends LitElement {
@state() private selection?: string = "now";
@state() private date: Date = new Date();
handleValueChanged(e: CustomEvent) {
this.selection = e.detail.value as string;
this.date = new Date();
if (this.selection !== "now") {
const [hours, minutes, seconds] = this.selection.split(":").map(Number);
this.date.setHours(hours);
this.date.setMinutes(minutes);
this.date.setSeconds(seconds);
}
}
protected render() {
const defaultLocale: FrontendLocaleData = {
language: "en",
number_format: NumberFormat.language,
time_format: TimeFormat.language,
date_format: DateFormat.language,
first_weekday: FirstWeekday.language,
time_zone: TimeZone.local,
};
return html`
<ha-control-select
.value=${this.selection}
.options=${timeOptions}
@value-changed=${this.handleValueChanged}
>
</ha-control-select>
<mwc-list>
<div class="container header">
<div>Language</div>
<div class="center">Default (lang)</div>
<div class="center">12 Hours</div>
<div class="center">24 Hours</div>
</div>
${Object.entries(translationMetadata.translations)
.filter(([key, _]) => key !== "test")
.map(
([key, value]) => html`
<div class="container">
<div>${value.nativeName}</div>
<div class="center">
${formatTime(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.language,
},
demoConfig
)}
</div>
<div class="center">
${formatTime(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.am_pm,
},
demoConfig
)}
</div>
<div class="center">
${formatTime(
this.date,
{
...defaultLocale,
language: key,
time_format: TimeFormat.twenty_four,
},
demoConfig
)}
</div>
</div>
`
)}
</mwc-list>
`;
}
static get styles() {
return css`
ha-control-select {
max-width: 800px;
margin: 12px auto;
}
.header {
font-weight: bold;
}
.center {
text-align: center;
}
.container {
max-width: 600px;
margin: 12px auto;
display: flex;
align-items: center;
justify-content: space-evenly;
}
.container > div {
flex-grow: 1;
width: 20%;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-date-time-time": DemoDateTimeTime;
}
}

View File

@@ -135,14 +135,6 @@ const ENTITIES = [
getEntity("text", "unavailable", "unavailable", { getEntity("text", "unavailable", "unavailable", {
friendly_name: "Message", friendly_name: "Message",
}), }),
getEntity("event", "unavailable", "unavailable", {
friendly_name: "Empty remote",
}),
getEntity("event", "doorbell", "2023-07-17T21:26:11.615+00:00", {
friendly_name: "Doorbell",
device_class: "doorbell",
event_type: "Ding-Dong",
}),
]; ];
const CONFIGS = [ const CONFIGS = [
@@ -162,7 +154,6 @@ const CONFIGS = [
- input_number.number - input_number.number
- sensor.humidity - sensor.humidity
- text.message - text.message
- event.doorbell
`, `,
}, },
{ {
@@ -255,7 +246,6 @@ const CONFIGS = [
- input_number.unavailable - input_number.unavailable
- input_select.unavailable - input_select.unavailable
- text.unavailable - text.unavailable
- event.unavailable
`, `,
}, },
{ {

View File

@@ -1,7 +1,6 @@
--- ---
title: Introduction title: Introduction
--- ---
Dashboards have many different cards. Each card allows the user to tell Dashboards have many different cards. Each card allows the user to tell
a different story about what is going on in their house. These cards a different story about what is going on in their house. These cards
are very customizable, as no household is the same. are very customizable, as no household is the same.

View File

@@ -9,7 +9,7 @@ const CONFIGS = [
heading: "markdown-it demo", heading: "markdown-it demo",
config: ` config: `
- type: markdown - type: markdown
content: | content: >-
# h1 Heading 8-) # h1 Heading 8-)
## h2 Heading ## h2 Heading
@@ -65,15 +65,6 @@ const CONFIGS = [
>> ...by using additional greater-than signs right next to each other... >> ...by using additional greater-than signs right next to each other...
> > > ...or with spaces between arrows. > > > ...or with spaces between arrows.
> **Warning** Hey there
> This is a warning with a title
> **Note**
> This is a note
> **Note**
> This is a multiline note
> Lorem ipsum...
## Lists ## Lists

View File

@@ -14,7 +14,7 @@ const ENTITIES = [
}), }),
getEntity("light", "bed_light", "on", { getEntity("light", "bed_light", "on", {
friendly_name: "Bed Light", friendly_name: "Bed Light",
supported_color_modes: [LightColorMode.HS, LightColorMode.COLOR_TEMP], supported_color_modes: [LightColorMode.HS],
}), }),
getEntity("light", "unavailable", "unavailable", { getEntity("light", "unavailable", "unavailable", {
friendly_name: "Unavailable entity", friendly_name: "Unavailable entity",
@@ -116,15 +116,6 @@ const CONFIGS = [
- type: "light-brightness" - type: "light-brightness"
`, `,
}, },
{
heading: "Light color temperature feature",
config: `
- type: tile
entity: light.bed_light
features:
- type: "color-temp"
`,
},
{ {
heading: "Vacuum commands feature", heading: "Vacuum commands feature",
config: ` config: `

View File

@@ -35,7 +35,6 @@ const SENSOR_DEVICE_CLASSES = [
"nitrogen_monoxide", "nitrogen_monoxide",
"nitrous_oxide", "nitrous_oxide",
"ozone", "ozone",
"ph",
"pm1", "pm1",
"pm10", "pm10",
"pm25", "pm25",
@@ -136,9 +135,6 @@ const ENTITIES: HassEntity[] = [
createEntity("climate.fan_only", "fan_only"), createEntity("climate.fan_only", "fan_only"),
createEntity("climate.auto_idle", "auto", undefined, { hvac_action: "idle" }), createEntity("climate.auto_idle", "auto", undefined, { hvac_action: "idle" }),
createEntity("climate.auto_off", "auto", undefined, { hvac_action: "off" }), createEntity("climate.auto_off", "auto", undefined, { hvac_action: "off" }),
createEntity("climate.auto_preheating", "auto", undefined, {
hvac_action: "preheating",
}),
createEntity("climate.auto_heating", "auto", undefined, { createEntity("climate.auto_heating", "auto", undefined, {
hvac_action: "heating", hvac_action: "heating",
}), }),
@@ -284,13 +280,6 @@ const ENTITIES: HassEntity[] = [
installed_version: "1.0.0", installed_version: "1.0.0",
latest_version: "2.0.0", latest_version: "2.0.0",
}), }),
createEntity("water_heater.off", "off"),
createEntity("water_heater.eco", "eco"),
createEntity("water_heater.electric", "electric"),
createEntity("water_heater.performance", "performance"),
createEntity("water_heater.high_demand", "high_demand"),
createEntity("water_heater.heat_pump", "heat_pump"),
createEntity("water_heater.gas", "gas"),
]; ];
function createEntity( function createEntity(
@@ -365,7 +354,6 @@ export class DemoEntityState extends LitElement {
hass.localize, hass.localize,
entry.stateObj, entry.stateObj,
hass.locale, hass.locale,
hass.config,
hass.entities hass.entities
)}`, )}`,
}, },

View File

@@ -265,8 +265,6 @@ export class DemoIntegrationCard extends LitElement {
></ha-config-flow-card> ></ha-config-flow-card>
` `
)} )}
</div>
<div class="container">
${configEntries.map( ${configEntries.map(
(info) => html` (info) => html`
<ha-integration-card <ha-integration-card
@@ -340,10 +338,10 @@ export class DemoIntegrationCard extends LitElement {
return css` return css`
.container { .container {
display: grid; display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
grid-gap: 8px 8px; grid-gap: 16px 16px;
padding: 8px 16px 16px; padding: 8px 16px 16px;
margin-bottom: 16px; margin-bottom: 64px;
} }
.container > * { .container > * {

View File

@@ -1,3 +0,0 @@
---
title: Climate
---

View File

@@ -1,105 +0,0 @@
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { customElement, property, query } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/dialogs/more-info/more-info-content";
import { getEntity } from "../../../../src/fake_data/entity";
import {
MockHomeAssistant,
provideHass,
} from "../../../../src/fake_data/provide_hass";
import "../../components/demo-more-infos";
import { ClimateEntityFeature } from "../../../../src/data/climate";
const ENTITIES = [
getEntity("climate", "thermostat", "heat", {
friendly_name: "Basic heater",
hvac_modes: ["heat", "off"],
hvac_mode: "heat",
current_temperature: 18,
temperature: 20,
min_temp: 10,
max_temp: 30,
supported_features: ClimateEntityFeature.TARGET_TEMPERATURE,
}),
getEntity("climate", "ac", "cool", {
friendly_name: "Basic air conditioning",
hvac_modes: ["cool", "off"],
hvac_mode: "cool",
current_temperature: 18,
temperature: 20,
min_temp: 10,
max_temp: 30,
supported_features: ClimateEntityFeature.TARGET_TEMPERATURE,
}),
getEntity("climate", "hvac", "auto", {
friendly_name: "Basic hvac",
hvac_modes: ["auto", "off"],
hvac_mode: "auto",
current_temperature: 18,
min_temp: 10,
max_temp: 30,
target_temp_step: 1,
supported_features: ClimateEntityFeature.TARGET_TEMPERATURE_RANGE,
target_temp_low: 20,
target_temp_high: 25,
}),
getEntity("climate", "advanced", "auto", {
friendly_name: "Advanced hvac",
supported_features:
// eslint-disable-next-line no-bitwise
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE |
ClimateEntityFeature.TARGET_HUMIDITY |
ClimateEntityFeature.PRESET_MODE,
hvac_modes: ["auto", "off"],
hvac_mode: "auto",
preset_modes: ["eco", "comfort", "boost"],
preset_mode: "eco",
current_temperature: 18,
min_temp: 10,
max_temp: 30,
target_temp_step: 1,
target_temp_low: 20,
target_temp_high: 25,
current_humidity: 40,
min_humidity: 0,
max_humidity: 100,
humidity: 50,
}),
getEntity("climate", "unavailable", "unavailable", {
friendly_name: "Unavailable heater",
hvac_modes: ["heat", "off"],
hvac_mode: "heat",
min_temp: 10,
max_temp: 30,
supported_features: ClimateEntityFeature.TARGET_TEMPERATURE,
}),
];
@customElement("demo-more-info-climate")
class DemoMoreInfoClimate extends LitElement {
@property() public hass!: MockHomeAssistant;
@query("demo-more-infos") private _demoRoot!: HTMLElement;
protected render(): TemplateResult {
return html`
<demo-more-infos
.hass=${this.hass}
.entities=${ENTITIES.map((ent) => ent.entityId)}
></demo-more-infos>
`;
}
protected firstUpdated(changedProperties: PropertyValues) {
super.firstUpdated(changedProperties);
const hass = provideHass(this._demoRoot);
hass.updateTranslations(null, "en");
hass.addEntities(ENTITIES);
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-more-info-climate": DemoMoreInfoClimate;
}
}

View File

@@ -1,3 +0,0 @@
---
title: Humidifier
---

View File

@@ -1,57 +0,0 @@
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { customElement, property, query } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/dialogs/more-info/more-info-content";
import { getEntity } from "../../../../src/fake_data/entity";
import {
MockHomeAssistant,
provideHass,
} from "../../../../src/fake_data/provide_hass";
import "../../components/demo-more-infos";
const ENTITIES = [
getEntity("humidifier", "humidifier", "on", {
friendly_name: "Humidifier",
device_class: "humidifier",
current_humidity: 50,
humidity: 30,
}),
getEntity("humidifier", "dehumidifier", "on", {
friendly_name: "Dehumidifier",
device_class: "dehumidifier",
current_humidity: 50,
humidity: 30,
}),
getEntity("humidifier", "unavailable", "unavailable", {
friendly_name: "Unavailable humidifier",
}),
];
@customElement("demo-more-info-humidifier")
class DemoMoreInfoHumidifier extends LitElement {
@property() public hass!: MockHomeAssistant;
@query("demo-more-infos") private _demoRoot!: HTMLElement;
protected render(): TemplateResult {
return html`
<demo-more-infos
.hass=${this.hass}
.entities=${ENTITIES.map((ent) => ent.entityId)}
></demo-more-infos>
`;
}
protected firstUpdated(changedProperties: PropertyValues) {
super.firstUpdated(changedProperties);
const hass = provideHass(this._demoRoot);
hass.updateTranslations(null, "en");
hass.addEntities(ENTITIES);
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-more-info-humidifier": DemoMoreInfoHumidifier;
}
}

View File

@@ -1,3 +0,0 @@
---
title: Water Heater
---

View File

@@ -1,70 +0,0 @@
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { customElement, property, query } from "lit/decorators";
import "../../../../src/components/ha-card";
import { WaterHeaterEntityFeature } from "../../../../src/data/water_heater";
import "../../../../src/dialogs/more-info/more-info-content";
import { getEntity } from "../../../../src/fake_data/entity";
import {
MockHomeAssistant,
provideHass,
} from "../../../../src/fake_data/provide_hass";
import "../../components/demo-more-infos";
const ENTITIES = [
getEntity("water_heater", "basic", "eco", {
friendly_name: "Basic heater",
operation_list: ["heat_pump", "eco", "performance", "off"],
operation_mode: "eco",
away_mode: "off",
target_temp_step: 1,
current_temperature: 55,
temperature: 60,
min_temp: 20,
max_temp: 70,
supported_features:
// eslint-disable-next-line no-bitwise
WaterHeaterEntityFeature.TARGET_TEMPERATURE |
WaterHeaterEntityFeature.OPERATION_MODE |
WaterHeaterEntityFeature.AWAY_MODE,
}),
getEntity("water_heater", "unavailable", "unavailable", {
friendly_name: "Unavailable heater",
operation_list: ["heat_pump", "eco", "performance", "off"],
operation_mode: "off",
min_temp: 20,
max_temp: 70,
supported_features:
// eslint-disable-next-line no-bitwise
WaterHeaterEntityFeature.TARGET_TEMPERATURE |
WaterHeaterEntityFeature.OPERATION_MODE,
}),
];
@customElement("demo-more-info-water-heater")
class DemoMoreInfoWaterHeater extends LitElement {
@property() public hass!: MockHomeAssistant;
@query("demo-more-infos") private _demoRoot!: HTMLElement;
protected render(): TemplateResult {
return html`
<demo-more-infos
.hass=${this.hass}
.entities=${ENTITIES.map((ent) => ent.entityId)}
></demo-more-infos>
`;
}
protected firstUpdated(changedProperties: PropertyValues) {
super.firstUpdated(changedProperties);
const hass = provideHass(this._demoRoot);
hass.updateTranslations(null, "en");
hass.addEntities(ENTITIES);
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-more-info-water-heater": DemoMoreInfoWaterHeater;
}
}

View File

@@ -6,217 +6,197 @@ title: "User Test: Configuration menu"
At the end of last year, we created one Configuration menu by merging Supervisor. In the next iteration, we want to organize our menu by creating logical grouping and combining duplicated features. We are conducting this test to see if we are on the right track. At the end of last year, we created one Configuration menu by merging Supervisor. In the next iteration, we want to organize our menu by creating logical grouping and combining duplicated features. We are conducting this test to see if we are on the right track.
- Anyone could join * Anyone could join
- Respondents recruited on Twitter, Reddit and Home Assistant Forum * Respondents recruited on Twitter, Reddit and Home Assistant Forum
- This test is open for 10 days * This test is open for 10 days
- UsabilityHub for user test * UsabilityHub for user test
- Figma for prototype * Figma for prototype
- 6 questions * 6 questions
- 3 tasks * 3 tasks
- Due to some limitations by UsabilityHub, it only worked on desktop * Due to some limitations by UsabilityHub, it only worked on desktop
# Results # Results
915 respondents took part in this test and they gave 407 comments. In general there isnt a significant difference between: 915 respondents took part in this test and they gave 407 comments. In general there isnt a significant difference between:
- How long a respondent has been using Home Assistant * How long a respondent has been using Home Assistant
- Installation method * Installation method
- How many visits to its Home Assistant in the past 3 months * How many visits to its Home Assistant in the past 3 months
- Home Assistant expertise * Home Assistant expertise
## Overall menu change ## Overall menu change
This prototype organized our menu by creating logical grouping and combining duplicated features. What do people think of this change? This prototype organized our menu by creating logical grouping and combining duplicated features. What do people think of this change?
### Stats ### Stats
* 2% (21) Like extremely
* 30% (276) Like very much
* 53% (481) Neutral
* 12% (108) Dislike very much
* 3% (26) Dislike extremely
- 2% (21) Like extremely *3 respondents passed*
- 30% (276) Like very much
- 53% (481) Neutral
- 12% (108) Dislike very much
- 3% (26) Dislike extremely
_3 respondents passed_
### Comments summary ### Comments summary
**Like** **Like**
- Clean and decluttered * Clean and decluttered
- Style looks better * Style looks better
- Faster to use * Faster to use
- Merging Supervisor into different pages * Merging Supervisor into different pages
- Moving Developer tools to Settings * Moving Developer tools to Settings
**Dislike** **Dislike**
- Moving Developer tools to Settings * Moving Developer tools to Settings
- More clicks for scripts and helpers * More clicks for scripts and helpers
- Too many changes at once causes a high learning curve * Too many changes at once causes a high learning curve
- Removing the word `Integrations` makes it harder to find them * Removing the word `Integrations` makes it harder to find them
- Difference between `Addons` and `Services` is a bit subtle * Difference between `Addons` and `Services` is a bit subtle
- No clear distinction between `Developer` and `System` * No clear distinction between `Developer` and `System`
- Material Design got the Google image * Material Design got the Google image
**Suggestions** **Suggestions**
- More top level menu items for example logs. * More top level menu items for example logs.
- What are settings and what not? Maybe better to name it `Configuration` * What are settings and what not? Maybe better to name it `Configuration`
- Devices are a first-class citizen in the domain of Home Assistant, and so shouldn't be tucked away in "Settings" * Devices are a first-class citizen in the domain of Home Assistant, and so shouldn't be tucked away in "Settings"
- Rename Developer tools (or make it only for Home Assistant developers) * Rename Developer tools (or make it only for Home Assistant developers)
- Separate administration (for instance creating users / adding lights etc) from development activities (creating automations and scripts) * Separate administration (for instance creating users / adding lights etc) from development activities (creating automations and scripts)
- Search Bar in Settings * Search Bar in Settings
- Feature to put menu items in sidebar * Feature to put menu items in sidebar
- Unification of add-ons and integrations * Unification of add-ons and integrations
- Adding New hints to show what changed * Adding New hints to show what changed
- Give `About` a less prominent size * Give `About` a less prominent size
- Accordion view option which puts every tab below * Accordion view option which puts every tab below
- Dev mode and a Prod Mode * Dev mode and a Prod Mode
- Always show config menu (on bigger screens) * Always show config menu (on bigger screens)
### Conclusion ### Conclusion
We should keep our focus on organizing our menu by creating logical grouping and combining duplicated features. With these changes we make more people happy: We should keep our focus on organizing our menu by creating logical grouping and combining duplicated features. With these changes we make more people happy:
- Reconsider putting `Logs` as a top-level menu item * Reconsider putting `Logs` as a top-level menu item
- Add a search bar * Add a search bar
- Use the word `Integrations` with `Devices & Services` * Use the word `Integrations` with `Devices & Services`
- Moving `Developer tools` to `Settings` is a good idea * Moving `Developer tools` to `Settings` is a good idea
- Rename `Developer tools` to for example `Tools` * Rename `Developer tools` to for example `Tools`
- Add `New` explanation popups to what has changed * Add `New` explanation popups to what has changed
- We could rename `Configuration` to `Settings` * We could rename `Configuration` to `Settings`
- Give `About` a less prominent size * Give `About` a less prominent size
## Helpers ## Helpers
In Home Assistant you can create toggles, text fields, number sliders, timers and counters. Also known as `Helpers`. Where should they be placed? In Home Assistant you can create toggles, text fields, number sliders, timers and counters. Also known as `Helpers`. Where should they be placed?
### Stats ### Stats
* 78% (709) respondents are using helpers. They use it for:
- 78% (709) respondents are using helpers. They use it for: * 92% (645) automations and scenes
- 92% (645) automations and scenes * 62% (422) dashboards
- 62% (422) dashboards * 43% (296) virtual devices
- 43% (296) virtual devices
### Comments summary ### Comments summary
Some respondents commented that they think `Helpers` shouldnt be listed under `Automations & Services`. Although almost all respondents use it for that specific purpose. Some respondents commented that they think `Helpers` shouldnt be listed under `Automations & Services`. Although almost all respondents use it for that specific purpose.
### Conclusion ### Conclusion
Helpers is, in addition to `Automations & Services`, also partly seen as virtual devices and dashboard entities.
Helpers is, in addition to `Automations & Services`, also partly seen as virtual devices and dashboard entities. * We might consider promoting them in their own top-level menu item
* Rename `Helpers` to something with `controls`
- We might consider promoting them in their own top-level menu item
- Rename `Helpers` to something with `controls`
## Add person ## Add person
The first task in this user test was to add a person. Since this has not changed in the current menu structure, this should be an easy assignment. How do people experience the navigation to this feature? The first task in this user test was to add a person. Since this has not changed in the current menu structure, this should be an easy assignment. How do people experience the navigation to this feature?
### Stats ### Stats
95% reached the goal screen and 98% marked the task as completed. There were 18 common paths. 95% reached the goal screen and 98% marked the task as completed. There were 18 common paths.
After the task we asked how easy it was to add a person. After the task we asked how easy it was to add a person.
- 41% (378) Extremely easy * 41% (378) Extremely easy
- 48% (440) Fairly easy * 48% (440) Fairly easy
- 7% (67) Neutral * 7% (67) Neutral
- 2% (19) Somewhat difficult * 2% (19) Somewhat difficult
- 1% (11) Very difficult * 1% (11) Very difficult
### Comments summary ### Comments summary
*No mentionable comments *
_No mentionable comments _
### Conclusion ### Conclusion
This test showed that the current navigation design works. This test showed that the current navigation design works.
## YAML ## YAML
In Home Assistant you can make configuration changes in YAML files. To make these changes take effect you have to reload your YAML in the UI or do a restart. How are people doing this and can they find it in this new design? In Home Assistant you can make configuration changes in YAML files. To make these changes take effect you have to reload your YAML in the UI or do a restart. How are people doing this and can they find it in this new design?
### Stats ### Stats
83% reached the goal screen and 87% marked the task as completed. There were 59 common paths. 83% reached the goal screen and 87% marked the task as completed. There were 59 common paths.
After the task we asked how easy it was to reload the YAML changes. After the task we asked how easy it was to reload the YAML changes.
- 4% (40) Extremely easy * 4% (40) Extremely easy
- 22% (204) Fairly easy * 22% (204) Fairly easy
- 20% (179) Neutral * 20% (179) Neutral
- 37% (336) Somewhat difficult * 37% (336) Somewhat difficult
- 17% (156) Very difficult * 17% (156) Very difficult
And we asked if they have seen that we've moved some functionality from current `Server Controls` to `Developer Tools`. And we asked if they have seen that we've moved some functionality from current `Server Controls` to `Developer Tools`.
- 57% (517) Yes * 57% (517) Yes
- 43% (398) No * 43% (398) No
### Comments summary ### Comments summary
**Like** **Like**
- YAML in Developer tools * YAML in Developer tools
**Dislike** **Dislike**
- Hidden restart and reload * Hidden restart and reload
- YAML in Developer Tools * YAML in Developer Tools
- Combining `Developer tools` with `Server management` * Combining `Developer tools` with `Server management`
- Reload Home Assistant button isn't clear what it does * Reload Home Assistant button isn't clear what it does
- Reload/restart Home Assistant in Developer Tools * Reload/restart Home Assistant in Developer Tools
**Suggestions** **Suggestions**
- Reload all YAML button * Reload all YAML button
- Dev mode and a Prod Mode * Dev mode and a Prod Mode
- Show restart/reload as buttons in System instead of overflow menu * Show restart/reload as buttons in System instead of overflow menu
- Explain that you can reload YAML when you want to restart your system * Explain that you can reload YAML when you want to restart your system
- YAML reloading under System * YAML reloading under System
### Conclusion ### Conclusion
This test showed two different kinds of user groups: UI and YAML users.
This test showed two different kinds of user groups: UI and YAML users. * Moving `Developer tools` to `Settings` is a good idea
* YAML users want reload YAML and Home Assistant restart in `System`
- Moving `Developer tools` to `Settings` is a good idea * Move the restart and reload button to the `System` page from the overflow menu
- YAML users want reload YAML and Home Assistant restart in `System` * Add suggestion to reload YAML when a user wants to restart
- Move the restart and reload button to the `System` page from the overflow menu * Add reload all YAML button
- Add suggestion to reload YAML when a user wants to restart
- Add reload all YAML button
## Logs ## Logs
### Stats ### Stats
70% reached the goal screen and 77% marked the task as completed. There were 48 common paths. 70% reached the goal screen and 77% marked the task as completed. There were 48 common paths.
After the task we asked to find out why your Elgato light isn't working. After the task we asked to find out why your Elgato light isn't working.
- 6% (57) Extremely easy * 6% (57) Extremely easy
- 28% (254) Fairly easy * 28% (254) Fairly easy
- 21% (188) Neutral * 21% (188) Neutral
- 21% (196) Somewhat difficult * 21% (196) Somewhat difficult
- 24% (220) Very difficult * 24% (220) Very difficult
### Comments summary ### Comments summary
**Suggestions** **Suggestions**
- Log errors on the integration page * Log errors on the integration page
- Problem solving center * Problem solving center
### Conclusion ### Conclusion
Although this test shows that a large number of respondents manage to complete the task, they find it difficult to find out the light isnt working. Although this test shows that a large number of respondents manage to complete the task, they find it difficult to find out the light isnt working.
- Add logs errors/warnings to the integration page * Add logs errors/warnings to the integration page
- Reconsider putting `Logs` as a top-level menu item * Reconsider putting `Logs` as a top-level menu item
## Learnings for next user test ## Learnings for next user test
* Explain that topic is closed for comments so that you can do this test without any influence
* Mobile test should work on mobile
* Testing on an iPad got some bugs
* People like doing these kind of test and we should do them more often
- Explain that topic is closed for comments so that you can do this test without any influence
- Mobile test should work on mobile
- Testing on an iPad got some bugs
- People like doing these kind of test and we should do them more often

View File

@@ -2,7 +2,7 @@
title: "User types" title: "User types"
--- ---
We have defined three user types for Home Assistant. They are a lean segmentation of users that helps us make decisions throughout the product. User types differ from traditional personas in that the segmentation criteria arent demographic and dont personify a group into a single character with a fictitious background story. We have defined three user types for Home Assistant. They are a lean segmentation of users that helps us make decisions throughout the product. User types differ from traditional personas in that the segmentation criteria arent demographic and dont personify a group into a single character with a fictitious background story.
# Outgrowers # Outgrowers

Some files were not shown because too many files have changed in this diff Show More