mirror of
https://github.com/home-assistant/frontend.git
synced 2025-09-30 23:39:53 +00:00
Compare commits
113 Commits
20240429.0
...
card_featu
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0dd290cd85 | ||
![]() |
fb499f09fb | ||
![]() |
d3c83e0157 | ||
![]() |
60c7a0e545 | ||
![]() |
d0f3eed49e | ||
![]() |
c2d4873ac3 | ||
![]() |
c3507bac0b | ||
![]() |
1dbb70b964 | ||
![]() |
1eecc5c0e2 | ||
![]() |
81c0bcff0b | ||
![]() |
6ccbeb8a75 | ||
![]() |
f59ed0a72b | ||
![]() |
a9f00ded0f | ||
![]() |
74730ba201 | ||
![]() |
95b2f7d821 | ||
![]() |
661b14da54 | ||
![]() |
41e34c0d61 | ||
![]() |
5d044a06eb | ||
![]() |
f617426808 | ||
![]() |
3c3d54243c | ||
![]() |
afc624bf4b | ||
![]() |
0991628843 | ||
![]() |
34b9c7b9d1 | ||
![]() |
d52641b495 | ||
![]() |
80c7fd2bf2 | ||
![]() |
e0062cf190 | ||
![]() |
7d2cee650d | ||
![]() |
66560b1f1c | ||
![]() |
a500b582e3 | ||
![]() |
19f94ff8cc | ||
![]() |
0b6994d402 | ||
![]() |
9fe8f507ec | ||
![]() |
2113cf5280 | ||
![]() |
ae9e1b724f | ||
![]() |
9b28c7cf69 | ||
![]() |
d9bac06806 | ||
![]() |
b1e37cb1e1 | ||
![]() |
a2a89502d8 | ||
![]() |
4cc5d2d04b | ||
![]() |
79abcca3b3 | ||
![]() |
043f383a35 | ||
![]() |
d4dd767941 | ||
![]() |
174f1991b1 | ||
![]() |
e15495a626 | ||
![]() |
a8a9a797cb | ||
![]() |
914dbc1e28 | ||
![]() |
111816f08a | ||
![]() |
1b4534890c | ||
![]() |
ed6542469d | ||
![]() |
3774a3d6ba | ||
![]() |
bfa293ae3a | ||
![]() |
9264adb799 | ||
![]() |
829ea4a9e4 | ||
![]() |
be26f8bc24 | ||
![]() |
c864b34a9a | ||
![]() |
099ea61a94 | ||
![]() |
3ebe6027be | ||
![]() |
f5f2a5ad5b | ||
![]() |
d046700d06 | ||
![]() |
2ad84b2832 | ||
![]() |
f9ccb9fc72 | ||
![]() |
6d3940db1e | ||
![]() |
20d174431d | ||
![]() |
1900710e06 | ||
![]() |
ed86a48e1c | ||
![]() |
d2bdb52926 | ||
![]() |
9c57c9f151 | ||
![]() |
9e9cb15a42 | ||
![]() |
6421a9443d | ||
![]() |
f2b43ddad8 | ||
![]() |
e55b59d9b7 | ||
![]() |
4a77359a06 | ||
![]() |
505d7b6ddb | ||
![]() |
79cdc43699 | ||
![]() |
8ff9823cd7 | ||
![]() |
3488c60818 | ||
![]() |
43a422cdca | ||
![]() |
11f2bef05c | ||
![]() |
ff9f331287 | ||
![]() |
cdf64ccdaa | ||
![]() |
8b220acca2 | ||
![]() |
8fdb7fa1d5 | ||
![]() |
008c842431 | ||
![]() |
bc41de0d9c | ||
![]() |
7310c9cf6d | ||
![]() |
84b436c08e | ||
![]() |
1925a47bdc | ||
![]() |
438a426458 | ||
![]() |
f923deb71d | ||
![]() |
e79bc71ab7 | ||
![]() |
11b0990d2b | ||
![]() |
870cb0c65f | ||
![]() |
deda2009f8 | ||
![]() |
b2797ab8da | ||
![]() |
644dcb0381 | ||
![]() |
c65f4f7a6e | ||
![]() |
68a79490dc | ||
![]() |
6febe8552e | ||
![]() |
f611f23f6f | ||
![]() |
627e06663b | ||
![]() |
ab01633069 | ||
![]() |
17dcc90638 | ||
![]() |
d0df029ff1 | ||
![]() |
86a7e69812 | ||
![]() |
af9417f2a6 | ||
![]() |
7120ad99b9 | ||
![]() |
334c245b65 | ||
![]() |
bcb72d83b8 | ||
![]() |
c99e0e846b | ||
![]() |
ec3f63e8a3 | ||
![]() |
1bc33a30ec | ||
![]() |
8cca233b7c | ||
![]() |
a78608bfb4 |
@@ -115,6 +115,7 @@
|
||||
}
|
||||
],
|
||||
"unused-imports/no-unused-imports": "error",
|
||||
"lit/attribute-names": "warn",
|
||||
"lit/attribute-value-entities": "off",
|
||||
"lit/no-template-map": "off",
|
||||
"lit/no-native-attributes": "warn",
|
||||
|
4
.github/workflows/cast_deployment.yaml
vendored
4
.github/workflows/cast_deployment.yaml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
||||
steps:
|
||||
- name: Check out files from GitHub
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
ref: dev
|
||||
|
||||
@@ -57,7 +57,7 @@ jobs:
|
||||
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
||||
steps:
|
||||
- name: Check out files from GitHub
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
ref: master
|
||||
|
||||
|
8
.github/workflows/ci.yaml
vendored
8
.github/workflows/ci.yaml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out files from GitHub
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4.0.2
|
||||
with:
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out files from GitHub
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4.0.2
|
||||
with:
|
||||
@@ -76,7 +76,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out files from GitHub
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4.0.2
|
||||
with:
|
||||
@@ -100,7 +100,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out files from GitHub
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4.0.2
|
||||
with:
|
||||
|
2
.github/workflows/codeql-analysis.yml
vendored
2
.github/workflows/codeql-analysis.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
|
4
.github/workflows/demo_deployment.yaml
vendored
4
.github/workflows/demo_deployment.yaml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
||||
steps:
|
||||
- name: Check out files from GitHub
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
ref: dev
|
||||
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
||||
steps:
|
||||
- name: Check out files from GitHub
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
with:
|
||||
ref: master
|
||||
|
||||
|
2
.github/workflows/design_deployment.yaml
vendored
2
.github/workflows/design_deployment.yaml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
|
||||
steps:
|
||||
- name: Check out files from GitHub
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4.0.2
|
||||
|
2
.github/workflows/design_preview.yaml
vendored
2
.github/workflows/design_preview.yaml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
if: github.repository == 'home-assistant/frontend' && contains(github.event.pull_request.labels.*.name, 'needs design preview')
|
||||
steps:
|
||||
- name: Check out files from GitHub
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4.0.2
|
||||
|
2
.github/workflows/nightly.yaml
vendored
2
.github/workflows/nightly.yaml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
||||
uses: actions/setup-python@v5
|
||||
|
4
.github/workflows/release.yaml
vendored
4
.github/workflows/release.yaml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
contents: write # Required to upload release assets
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Verify version
|
||||
uses: home-assistant/actions/helpers/verify-version@master
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
script/release
|
||||
|
||||
- name: Upload release assets
|
||||
uses: softprops/action-gh-release@v2.0.4
|
||||
uses: softprops/action-gh-release@v2.0.5
|
||||
with:
|
||||
files: |
|
||||
dist/*.whl
|
||||
|
2
.github/workflows/translations.yaml
vendored
2
.github/workflows/translations.yaml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout the repository
|
||||
uses: actions/checkout@v4.1.4
|
||||
uses: actions/checkout@v4.1.6
|
||||
|
||||
- name: Upload Translations
|
||||
run: |
|
||||
|
File diff suppressed because one or more lines are too long
@@ -6,4 +6,4 @@ enableGlobalCache: false
|
||||
|
||||
nodeLinker: node-modules
|
||||
|
||||
yarnPath: .yarn/releases/yarn-4.1.1.cjs
|
||||
yarnPath: .yarn/releases/yarn-4.2.2.cjs
|
||||
|
@@ -1,7 +1,23 @@
|
||||
import defineProvider from "@babel/helper-define-polyfill-provider";
|
||||
import { join } from "node:path";
|
||||
import paths from "../paths.cjs";
|
||||
|
||||
const POLYFILL_DIR = join(paths.polymer_dir, "src/resources/polyfills");
|
||||
|
||||
// List of polyfill keys with supported browser targets for the functionality
|
||||
const PolyfillSupport = {
|
||||
// Note states and shadowRoot properties should be supported.
|
||||
"element-internals": {
|
||||
android: 90,
|
||||
chrome: 90,
|
||||
edge: 90,
|
||||
firefox: 126,
|
||||
ios: 17.4,
|
||||
opera: 76,
|
||||
opera_mobile: 64,
|
||||
safari: 17.4,
|
||||
samsung: 15.0,
|
||||
},
|
||||
fetch: {
|
||||
android: 42,
|
||||
chrome: 42,
|
||||
@@ -24,16 +40,36 @@ const PolyfillSupport = {
|
||||
safari: 10.0,
|
||||
samsung: 5.0,
|
||||
},
|
||||
"resize-observer": {
|
||||
android: 64,
|
||||
chrome: 64,
|
||||
edge: 79,
|
||||
firefox: 69,
|
||||
ios: 13.4,
|
||||
opera: 51,
|
||||
opera_mobile: 47,
|
||||
safari: 13.1,
|
||||
samsung: 9.0,
|
||||
},
|
||||
};
|
||||
|
||||
// Map of global variables and/or instance and static properties to the
|
||||
// corresponding polyfill key and actual module to import
|
||||
const polyfillMap = {
|
||||
global: {
|
||||
Proxy: { key: "proxy", module: "proxy-polyfill" },
|
||||
fetch: { key: "fetch", module: "unfetch/polyfill" },
|
||||
Proxy: { key: "proxy", module: "proxy-polyfill" },
|
||||
ResizeObserver: {
|
||||
key: "resize-observer",
|
||||
module: join(POLYFILL_DIR, "resize-observer.ts"),
|
||||
},
|
||||
},
|
||||
instance: {
|
||||
attachInternals: {
|
||||
key: "element-internals",
|
||||
module: "element-internals-polyfill",
|
||||
},
|
||||
},
|
||||
instance: {},
|
||||
static: {},
|
||||
};
|
||||
|
||||
@@ -49,7 +85,9 @@ export default defineProvider(
|
||||
if (polyfill && shouldInjectPolyfill(polyfill.desc.key)) {
|
||||
debug(polyfill.desc.key);
|
||||
utils.injectGlobalImport(polyfill.desc.module);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@ const env = require("./env.cjs");
|
||||
const paths = require("./paths.cjs");
|
||||
const { dependencies } = require("../package.json");
|
||||
|
||||
const BABEL_PLUGINS = path.join(__dirname, "babel-plugins");
|
||||
|
||||
// GitHub base URL to use for production source maps
|
||||
// Nightly builds use the commit SHA, otherwise assumes there is a tag that matches the version
|
||||
module.exports.sourceMapURL = () => {
|
||||
@@ -100,22 +102,12 @@ module.exports.babelOptions = ({ latestBuild, isProdBuild, isTestBuild }) => ({
|
||||
],
|
||||
plugins: [
|
||||
[
|
||||
path.resolve(
|
||||
paths.polymer_dir,
|
||||
"build-scripts/babel-plugins/inline-constants-plugin.cjs"
|
||||
),
|
||||
path.join(BABEL_PLUGINS, "inline-constants-plugin.cjs"),
|
||||
{
|
||||
modules: ["@mdi/js"],
|
||||
ignoreModuleNotFound: true,
|
||||
},
|
||||
],
|
||||
[
|
||||
path.resolve(
|
||||
paths.polymer_dir,
|
||||
"build-scripts/babel-plugins/custom-polyfill-plugin.js"
|
||||
),
|
||||
{ method: "usage-global" },
|
||||
],
|
||||
// Minify template literals for production
|
||||
isProdBuild && [
|
||||
"template-html-minifier",
|
||||
@@ -153,6 +145,26 @@ module.exports.babelOptions = ({ latestBuild, isProdBuild, isTestBuild }) => ({
|
||||
],
|
||||
sourceMaps: !isTestBuild,
|
||||
overrides: [
|
||||
{
|
||||
// Add plugin to inject various polyfills, excluding the polyfills
|
||||
// themselves to prevent self-injection.
|
||||
plugins: [
|
||||
[
|
||||
path.join(BABEL_PLUGINS, "custom-polyfill-plugin.js"),
|
||||
{ method: "usage-global" },
|
||||
],
|
||||
],
|
||||
exclude: [
|
||||
path.join(paths.polymer_dir, "src/resources/polyfills"),
|
||||
...[
|
||||
"@lit-labs/virtualizer/polyfills",
|
||||
"@webcomponents/scoped-custom-element-registry",
|
||||
"element-internals-polyfill",
|
||||
"proxy-polyfill",
|
||||
"unfetch",
|
||||
].map((p) => new RegExp(`/node_modules/${p}/`)),
|
||||
],
|
||||
},
|
||||
{
|
||||
// Use unambiguous for dependencies so that require() is correctly injected into CommonJS files
|
||||
// Exclusions are needed in some cases where ES modules have no static imports or exports, such as polyfills
|
||||
|
@@ -1,12 +1,14 @@
|
||||
/* eslint-disable max-classes-per-file */
|
||||
|
||||
import { deleteAsync } from "del";
|
||||
import { glob } from "glob";
|
||||
import gulp from "gulp";
|
||||
import merge from "gulp-merge-json";
|
||||
import rename from "gulp-rename";
|
||||
import merge from "lodash.merge";
|
||||
import { createHash } from "node:crypto";
|
||||
import { mkdir, readFile } from "node:fs/promises";
|
||||
import { basename, join } from "node:path";
|
||||
import { Transform } from "node:stream";
|
||||
import { PassThrough, Transform } from "node:stream";
|
||||
import { finished } from "node:stream/promises";
|
||||
import env from "../env.cjs";
|
||||
import paths from "../paths.cjs";
|
||||
@@ -54,6 +56,39 @@ class CustomJSON extends Transform {
|
||||
}
|
||||
}
|
||||
|
||||
// Transform stream to merge Vinyl JSON files (buffer mode only).
|
||||
class MergeJSON extends Transform {
|
||||
_objects = [];
|
||||
|
||||
constructor(stem, startObj = {}, reviver = null) {
|
||||
super({ objectMode: true, allowHalfOpen: false });
|
||||
this._stem = stem;
|
||||
this._startObj = structuredClone(startObj);
|
||||
this._reviver = reviver;
|
||||
}
|
||||
|
||||
async _transform(file, _, callback) {
|
||||
try {
|
||||
this._objects.push(JSON.parse(file.contents.toString(), this._reviver));
|
||||
if (!this._outFile) this._outFile = file.clone({ contents: false });
|
||||
callback(null);
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
}
|
||||
|
||||
async _flush(callback) {
|
||||
try {
|
||||
const mergedObj = merge(this._startObj, ...this._objects);
|
||||
this._outFile.contents = Buffer.from(JSON.stringify(mergedObj));
|
||||
this._outFile.stem = this._stem;
|
||||
callback(null, this._outFile);
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Utility to flatten object keys to single level using separator
|
||||
const flatten = (data, prefix = "", sep = ".") => {
|
||||
const output = {};
|
||||
@@ -131,12 +166,7 @@ const createMasterTranslation = () =>
|
||||
gulp
|
||||
.src([EN_SRC, ...(mergeBackend ? [`${inBackendDir}/en.json`] : [])])
|
||||
.pipe(new CustomJSON(lokaliseTransform))
|
||||
.pipe(
|
||||
merge({
|
||||
fileName: "en.json",
|
||||
jsonSpace: undefined,
|
||||
})
|
||||
)
|
||||
.pipe(new MergeJSON("en"))
|
||||
.pipe(gulp.dest(workDir));
|
||||
|
||||
const FRAGMENTS = ["base"];
|
||||
@@ -213,7 +243,10 @@ const createTranslations = async () => {
|
||||
// TODO: This is a naive interpretation of BCP47 that should be improved.
|
||||
// Will be OK for now as long as we don't have anything more complicated
|
||||
// than a base translation + region.
|
||||
gulp.src(`${workDir}/en.json`).pipe(hashStream, { end: false });
|
||||
gulp
|
||||
.src(`${workDir}/en.json`)
|
||||
.pipe(new PassThrough({ objectMode: true }))
|
||||
.pipe(hashStream, { end: false });
|
||||
const mergesFinished = [];
|
||||
for (const translationFile of translationFiles) {
|
||||
const locale = basename(translationFile, ".json");
|
||||
@@ -230,14 +263,9 @@ const createTranslations = async () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
const mergeStream = gulp.src(mergeFiles, { allowEmpty: true }).pipe(
|
||||
merge({
|
||||
fileName: `${locale}.json`,
|
||||
startObj: enMaster,
|
||||
jsonReviver: emptyReviver,
|
||||
jsonSpace: undefined,
|
||||
})
|
||||
);
|
||||
const mergeStream = gulp
|
||||
.src(mergeFiles, { allowEmpty: true })
|
||||
.pipe(new MergeJSON(locale, enMaster, emptyReviver));
|
||||
mergesFinished.push(finished(mergeStream));
|
||||
mergeStream.pipe(hashStream, { end: false });
|
||||
}
|
||||
|
@@ -64,6 +64,12 @@ const ACTIONS = [
|
||||
entity_id: "input_boolean.toggle_4",
|
||||
},
|
||||
},
|
||||
{
|
||||
sequence: [
|
||||
{ scene: "scene.kitchen_morning" },
|
||||
{ service: "light.turn_off", target: { entity_id: "light.kitchen" } },
|
||||
],
|
||||
},
|
||||
{
|
||||
parallel: [
|
||||
{ scene: "scene.kitchen_morning" },
|
||||
|
@@ -20,6 +20,7 @@ import { HaWaitForTriggerAction } from "../../../../src/panels/config/automation
|
||||
import { HaWaitAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-wait_template";
|
||||
import { Action } from "../../../../src/data/script";
|
||||
import { HaConditionAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-condition";
|
||||
import { HaSequenceAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-sequence";
|
||||
import { HaParallelAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-parallel";
|
||||
import { HaIfAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-if";
|
||||
import { HaStopAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-stop";
|
||||
@@ -39,6 +40,7 @@ const SCHEMAS: { name: string; actions: Action[] }[] = [
|
||||
{ name: "If-Then", actions: [HaIfAction.defaultConfig] },
|
||||
{ name: "Choose", actions: [HaChooseAction.defaultConfig] },
|
||||
{ name: "Variables", actions: [{ variables: { hello: "1" } }] },
|
||||
{ name: "Sequence", actions: [HaSequenceAction.defaultConfig] },
|
||||
{ name: "Parallel", actions: [HaParallelAction.defaultConfig] },
|
||||
{ name: "Stop", actions: [HaStopAction.defaultConfig] },
|
||||
];
|
||||
|
@@ -368,6 +368,7 @@ export class DemoEntityState extends LitElement {
|
||||
hass.localize,
|
||||
entry.stateObj,
|
||||
hass.locale,
|
||||
[], // numericDeviceClasses
|
||||
hass.config,
|
||||
hass.entities
|
||||
)}`,
|
||||
|
@@ -1,19 +1,19 @@
|
||||
import { mdiStorePlus, mdiUpdate } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { mdiRefresh, mdiStorePlus } from "@mdi/js";
|
||||
import { CSSResultGroup, LitElement, TemplateResult, css, html } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { atLeastVersion } from "../../../src/common/config/version";
|
||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||
import "../../../src/components/ha-fab";
|
||||
import { reloadHassioAddons } from "../../../src/data/hassio/addon";
|
||||
import { extractApiErrorMessage } from "../../../src/data/hassio/common";
|
||||
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
||||
import { showAlertDialog } from "../../../src/dialogs/generic/show-dialog-box";
|
||||
import "../../../src/layouts/hass-subpage";
|
||||
import "../../../src/layouts/hass-tabs-subpage";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { HomeAssistant, Route } from "../../../src/types";
|
||||
import { supervisorTabs } from "../hassio-tabs";
|
||||
import "./hassio-addons";
|
||||
import "../../../src/layouts/hass-subpage";
|
||||
import { reloadHassioAddons } from "../../../src/data/hassio/addon";
|
||||
import { extractApiErrorMessage } from "../../../src/data/hassio/common";
|
||||
import { showAlertDialog } from "../../../src/dialogs/generic/show-dialog-box";
|
||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||
|
||||
@customElement("hassio-dashboard")
|
||||
class HassioDashboard extends LitElement {
|
||||
@@ -43,7 +43,7 @@ class HassioDashboard extends LitElement {
|
||||
<ha-icon-button
|
||||
slot="toolbar-icon"
|
||||
@click=${this._handleCheckUpdates}
|
||||
.path=${mdiUpdate}
|
||||
.path=${mdiRefresh}
|
||||
.label=${this.supervisor.localize("store.check_updates")}
|
||||
></ha-icon-button>
|
||||
<hassio-addons
|
||||
|
82
package.json
82
package.json
@@ -25,8 +25,8 @@
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "7.24.4",
|
||||
"@braintree/sanitize-url": "7.0.1",
|
||||
"@babel/runtime": "7.24.5",
|
||||
"@braintree/sanitize-url": "7.0.2",
|
||||
"@codemirror/autocomplete": "6.16.0",
|
||||
"@codemirror/commands": "6.5.0",
|
||||
"@codemirror/language": "6.10.1",
|
||||
@@ -35,20 +35,20 @@
|
||||
"@codemirror/state": "6.4.1",
|
||||
"@codemirror/view": "6.26.3",
|
||||
"@egjs/hammerjs": "2.0.17",
|
||||
"@formatjs/intl-datetimeformat": "6.12.3",
|
||||
"@formatjs/intl-displaynames": "6.6.6",
|
||||
"@formatjs/intl-datetimeformat": "6.12.5",
|
||||
"@formatjs/intl-displaynames": "6.6.8",
|
||||
"@formatjs/intl-getcanonicallocales": "2.3.0",
|
||||
"@formatjs/intl-listformat": "7.5.5",
|
||||
"@formatjs/intl-locale": "3.4.5",
|
||||
"@formatjs/intl-numberformat": "8.10.1",
|
||||
"@formatjs/intl-pluralrules": "5.2.12",
|
||||
"@formatjs/intl-relativetimeformat": "11.2.12",
|
||||
"@fullcalendar/core": "6.1.11",
|
||||
"@fullcalendar/daygrid": "6.1.11",
|
||||
"@fullcalendar/interaction": "6.1.11",
|
||||
"@fullcalendar/list": "6.1.11",
|
||||
"@fullcalendar/luxon3": "6.1.11",
|
||||
"@fullcalendar/timegrid": "6.1.11",
|
||||
"@formatjs/intl-listformat": "7.5.7",
|
||||
"@formatjs/intl-locale": "4.0.0",
|
||||
"@formatjs/intl-numberformat": "8.10.3",
|
||||
"@formatjs/intl-pluralrules": "5.2.14",
|
||||
"@formatjs/intl-relativetimeformat": "11.2.14",
|
||||
"@fullcalendar/core": "6.1.13",
|
||||
"@fullcalendar/daygrid": "6.1.13",
|
||||
"@fullcalendar/interaction": "6.1.13",
|
||||
"@fullcalendar/list": "6.1.13",
|
||||
"@fullcalendar/luxon3": "6.1.13",
|
||||
"@fullcalendar/timegrid": "6.1.13",
|
||||
"@lezer/highlight": "1.2.0",
|
||||
"@lit-labs/context": "0.4.1",
|
||||
"@lit-labs/motion": "1.0.7",
|
||||
@@ -70,7 +70,6 @@
|
||||
"@material/mwc-list": "0.27.0",
|
||||
"@material/mwc-menu": "0.27.0",
|
||||
"@material/mwc-radio": "0.27.0",
|
||||
"@material/mwc-ripple": "0.27.0",
|
||||
"@material/mwc-select": "0.27.0",
|
||||
"@material/mwc-snackbar": "0.27.0",
|
||||
"@material/mwc-switch": "0.27.0",
|
||||
@@ -89,8 +88,8 @@
|
||||
"@polymer/paper-tabs": "3.1.0",
|
||||
"@polymer/polymer": "3.5.1",
|
||||
"@thomasloven/round-slider": "0.6.0",
|
||||
"@vaadin/combo-box": "24.3.11",
|
||||
"@vaadin/vaadin-themable-mixin": "24.3.11",
|
||||
"@vaadin/combo-box": "24.3.13",
|
||||
"@vaadin/vaadin-themable-mixin": "24.3.13",
|
||||
"@vibrant/color": "3.2.1-alpha.1",
|
||||
"@vibrant/core": "3.2.1-alpha.1",
|
||||
"@vibrant/quantizer-mmcq": "3.2.1-alpha.1",
|
||||
@@ -98,10 +97,10 @@
|
||||
"@webcomponents/scoped-custom-element-registry": "0.0.9",
|
||||
"@webcomponents/webcomponentsjs": "2.8.0",
|
||||
"app-datepicker": "5.1.1",
|
||||
"chart.js": "4.4.2",
|
||||
"chart.js": "4.4.3",
|
||||
"color-name": "2.0.0",
|
||||
"comlink": "4.4.1",
|
||||
"core-js": "3.37.0",
|
||||
"core-js": "3.37.1",
|
||||
"cropperjs": "1.6.2",
|
||||
"date-fns": "3.6.0",
|
||||
"date-fns-tz": "3.1.3",
|
||||
@@ -113,7 +112,7 @@
|
||||
"hls.js": "patch:hls.js@npm%3A1.5.7#~/.yarn/patches/hls.js-npm-1.5.7-f5bbd3d060.patch",
|
||||
"home-assistant-js-websocket": "9.3.0",
|
||||
"idb-keyval": "6.2.1",
|
||||
"intl-messageformat": "10.5.11",
|
||||
"intl-messageformat": "10.5.14",
|
||||
"js-yaml": "4.1.0",
|
||||
"leaflet": "1.9.4",
|
||||
"leaflet-draw": "1.0.4",
|
||||
@@ -150,33 +149,34 @@
|
||||
"xss": "1.0.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.24.4",
|
||||
"@babel/core": "7.24.5",
|
||||
"@babel/helper-define-polyfill-provider": "0.6.2",
|
||||
"@babel/plugin-proposal-decorators": "7.24.1",
|
||||
"@babel/plugin-transform-runtime": "7.24.3",
|
||||
"@babel/preset-env": "7.24.4",
|
||||
"@babel/preset-env": "7.24.5",
|
||||
"@babel/preset-typescript": "7.24.1",
|
||||
"@bundle-stats/plugin-webpack-filter": "4.12.2",
|
||||
"@koa/cors": "5.0.0",
|
||||
"@lokalise/node-api": "12.4.1",
|
||||
"@lokalise/node-api": "12.5.0",
|
||||
"@octokit/auth-oauth-device": "7.1.1",
|
||||
"@octokit/plugin-retry": "7.1.1",
|
||||
"@octokit/rest": "20.1.0",
|
||||
"@octokit/rest": "20.1.1",
|
||||
"@open-wc/dev-server-hmr": "0.1.4",
|
||||
"@rollup/plugin-babel": "6.0.4",
|
||||
"@rollup/plugin-commonjs": "25.0.7",
|
||||
"@rollup/plugin-commonjs": "25.0.8",
|
||||
"@rollup/plugin-json": "6.1.0",
|
||||
"@rollup/plugin-node-resolve": "15.2.3",
|
||||
"@rollup/plugin-replace": "5.0.5",
|
||||
"@types/babel__plugin-transform-runtime": "7.9.5",
|
||||
"@types/chromecast-caf-receiver": "6.0.14",
|
||||
"@types/chromecast-caf-sender": "1.0.9",
|
||||
"@types/chromecast-caf-sender": "1.0.10",
|
||||
"@types/color-name": "1.1.4",
|
||||
"@types/glob": "8.1.0",
|
||||
"@types/html-minifier-terser": "7.0.2",
|
||||
"@types/js-yaml": "4.0.9",
|
||||
"@types/leaflet": "1.9.12",
|
||||
"@types/leaflet-draw": "1.0.11",
|
||||
"@types/lodash.merge": "4.6.9",
|
||||
"@types/luxon": "3.4.2",
|
||||
"@types/mocha": "10.0.6",
|
||||
"@types/qrcode": "1.5.5",
|
||||
@@ -185,13 +185,13 @@
|
||||
"@types/tar": "6.1.13",
|
||||
"@types/ua-parser-js": "0.7.39",
|
||||
"@types/webspeechapi": "0.0.29",
|
||||
"@typescript-eslint/eslint-plugin": "7.7.1",
|
||||
"@typescript-eslint/parser": "7.7.1",
|
||||
"@typescript-eslint/eslint-plugin": "7.10.0",
|
||||
"@typescript-eslint/parser": "7.10.0",
|
||||
"@web/dev-server": "0.1.38",
|
||||
"@web/dev-server-rollup": "0.4.1",
|
||||
"babel-loader": "9.1.3",
|
||||
"babel-plugin-template-html-minifier": "4.1.0",
|
||||
"chai": "5.1.0",
|
||||
"chai": "5.1.1",
|
||||
"del": "7.1.0",
|
||||
"eslint": "8.57.0",
|
||||
"eslint-config-airbnb-base": "15.0.0",
|
||||
@@ -200,24 +200,24 @@
|
||||
"eslint-import-resolver-webpack": "0.13.8",
|
||||
"eslint-plugin-disable": "2.0.3",
|
||||
"eslint-plugin-import": "2.29.1",
|
||||
"eslint-plugin-lit": "1.11.0",
|
||||
"eslint-plugin-lit": "1.13.0",
|
||||
"eslint-plugin-lit-a11y": "4.1.2",
|
||||
"eslint-plugin-unused-imports": "3.1.0",
|
||||
"eslint-plugin-unused-imports": "3.2.0",
|
||||
"eslint-plugin-wc": "2.1.0",
|
||||
"fancy-log": "2.0.0",
|
||||
"fs-extra": "11.2.0",
|
||||
"glob": "10.3.12",
|
||||
"gulp": "4.0.2",
|
||||
"glob": "10.4.1",
|
||||
"gulp": "5.0.0",
|
||||
"gulp-json-transform": "0.5.0",
|
||||
"gulp-merge-json": "2.2.1",
|
||||
"gulp-rename": "2.0.0",
|
||||
"gulp-zopfli-green": "6.0.1",
|
||||
"html-minifier-terser": "7.2.0",
|
||||
"husky": "9.0.11",
|
||||
"instant-mocha": "1.5.2",
|
||||
"jszip": "3.10.1",
|
||||
"lint-staged": "15.2.2",
|
||||
"lint-staged": "15.2.4",
|
||||
"lit-analyzer": "2.0.3",
|
||||
"lodash.merge": "4.6.2",
|
||||
"lodash.template": "4.5.0",
|
||||
"magic-string": "0.30.10",
|
||||
"map-stream": "0.0.7",
|
||||
@@ -231,12 +231,12 @@
|
||||
"rollup-plugin-terser": "7.0.2",
|
||||
"rollup-plugin-visualizer": "5.12.0",
|
||||
"serve-handler": "6.1.5",
|
||||
"sinon": "17.0.1",
|
||||
"sinon": "18.0.0",
|
||||
"source-map-url": "0.4.1",
|
||||
"systemjs": "6.14.3",
|
||||
"tar": "7.0.1",
|
||||
"systemjs": "6.15.1",
|
||||
"tar": "7.1.0",
|
||||
"terser-webpack-plugin": "5.3.10",
|
||||
"transform-async-modules-webpack-plugin": "1.1.0",
|
||||
"transform-async-modules-webpack-plugin": "1.1.1",
|
||||
"ts-lit-plugin": "2.0.2",
|
||||
"typescript": "5.4.5",
|
||||
"webpack": "5.91.0",
|
||||
@@ -257,5 +257,5 @@
|
||||
"sortablejs@1.15.2": "patch:sortablejs@npm%3A1.15.2#~/.yarn/patches/sortablejs-npm-1.15.2-73347ae85a.patch",
|
||||
"leaflet-draw@1.0.4": "patch:leaflet-draw@npm%3A1.0.4#./.yarn/patches/leaflet-draw-npm-1.0.4-0ca0ebcf65.patch"
|
||||
},
|
||||
"packageManager": "yarn@4.1.1"
|
||||
"packageManager": "yarn@4.2.2"
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "home-assistant-frontend"
|
||||
version = "20240429.0"
|
||||
version = "20240501.0"
|
||||
license = {text = "Apache-2.0"}
|
||||
description = "The Home Assistant frontend"
|
||||
readme = "README.md"
|
||||
|
@@ -1,3 +1,5 @@
|
||||
export type MediaQueriesListener = () => void;
|
||||
|
||||
/**
|
||||
* Attach a media query. Listener is called right away and when it matches.
|
||||
* @param mediaQuery media query to match.
|
||||
@@ -7,7 +9,7 @@
|
||||
export const listenMediaQuery = (
|
||||
mediaQuery: string,
|
||||
matchesChanged: (matches: boolean) => void
|
||||
) => {
|
||||
): MediaQueriesListener => {
|
||||
const mql = matchMedia(mediaQuery);
|
||||
const listener = (e) => matchesChanged(e.matches);
|
||||
mql.addListener(listener);
|
||||
|
@@ -19,28 +19,11 @@ import { blankBeforeUnit } from "../translations/blank_before_unit";
|
||||
import { LocalizeFunc } from "../translations/localize";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
|
||||
export const computeStateDisplaySingleEntity = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntity,
|
||||
locale: FrontendLocaleData,
|
||||
config: HassConfig,
|
||||
entity: EntityRegistryDisplayEntry | undefined,
|
||||
state?: string
|
||||
): string =>
|
||||
computeStateDisplayFromEntityAttributes(
|
||||
localize,
|
||||
locale,
|
||||
config,
|
||||
entity,
|
||||
stateObj.entity_id,
|
||||
stateObj.attributes,
|
||||
state !== undefined ? state : stateObj.state
|
||||
);
|
||||
|
||||
export const computeStateDisplay = (
|
||||
localize: LocalizeFunc,
|
||||
stateObj: HassEntity,
|
||||
locale: FrontendLocaleData,
|
||||
sensorNumericDeviceClasses: string[],
|
||||
config: HassConfig,
|
||||
entities: HomeAssistant["entities"],
|
||||
state?: string
|
||||
@@ -52,6 +35,7 @@ export const computeStateDisplay = (
|
||||
return computeStateDisplayFromEntityAttributes(
|
||||
localize,
|
||||
locale,
|
||||
sensorNumericDeviceClasses,
|
||||
config,
|
||||
entity,
|
||||
stateObj.entity_id,
|
||||
@@ -63,6 +47,7 @@ export const computeStateDisplay = (
|
||||
export const computeStateDisplayFromEntityAttributes = (
|
||||
localize: LocalizeFunc,
|
||||
locale: FrontendLocaleData,
|
||||
sensorNumericDeviceClasses: string[],
|
||||
config: HassConfig,
|
||||
entity: EntityRegistryDisplayEntry | undefined,
|
||||
entityId: string,
|
||||
@@ -73,8 +58,15 @@ export const computeStateDisplayFromEntityAttributes = (
|
||||
return localize(`state.default.${state}`);
|
||||
}
|
||||
|
||||
const domain = computeDomain(entityId);
|
||||
|
||||
// Entities with a `unit_of_measurement` or `state_class` are numeric values and should use `formatNumber`
|
||||
if (isNumericFromAttributes(attributes)) {
|
||||
if (
|
||||
isNumericFromAttributes(
|
||||
attributes,
|
||||
domain === "sensor" ? sensorNumericDeviceClasses : []
|
||||
)
|
||||
) {
|
||||
// state is duration
|
||||
if (
|
||||
attributes.device_class === "duration" &&
|
||||
@@ -120,8 +112,6 @@ export const computeStateDisplayFromEntityAttributes = (
|
||||
return value;
|
||||
}
|
||||
|
||||
const domain = computeDomain(entityId);
|
||||
|
||||
if (domain === "datetime") {
|
||||
const time = new Date(state);
|
||||
return formatDateTime(time, locale, config);
|
||||
|
@@ -28,7 +28,15 @@ export const FIXED_DOMAIN_STATES = {
|
||||
input_button: [],
|
||||
lawn_mower: ["error", "paused", "mowing", "docked"],
|
||||
light: ["on", "off"],
|
||||
lock: ["jammed", "locked", "locking", "unlocked", "unlocking"],
|
||||
lock: [
|
||||
"jammed",
|
||||
"locked",
|
||||
"locking",
|
||||
"unlocked",
|
||||
"unlocking",
|
||||
"opening",
|
||||
"open",
|
||||
],
|
||||
media_player: [
|
||||
"off",
|
||||
"on",
|
||||
|
@@ -14,8 +14,12 @@ export const isNumericState = (stateObj: HassEntity): boolean =>
|
||||
isNumericFromAttributes(stateObj.attributes);
|
||||
|
||||
export const isNumericFromAttributes = (
|
||||
attributes: HassEntityAttributeBase
|
||||
): boolean => !!attributes.unit_of_measurement || !!attributes.state_class;
|
||||
attributes: HassEntityAttributeBase,
|
||||
numericDeviceClasses?: string[]
|
||||
): boolean =>
|
||||
!!attributes.unit_of_measurement ||
|
||||
!!attributes.state_class ||
|
||||
(numericDeviceClasses || []).includes(attributes.device_class || "");
|
||||
|
||||
export const numberFormatToLocale = (
|
||||
localeOptions: FrontendLocaleData
|
||||
|
@@ -21,7 +21,8 @@ export const computeFormatFunctions = async (
|
||||
localize: LocalizeFunc,
|
||||
locale: FrontendLocaleData,
|
||||
config: HassConfig,
|
||||
entities: HomeAssistant["entities"]
|
||||
entities: HomeAssistant["entities"],
|
||||
sensorNumericDeviceClasses: string[]
|
||||
): Promise<{
|
||||
formatEntityState: FormatEntityStateFunc;
|
||||
formatEntityAttributeValue: FormatEntityAttributeValueFunc;
|
||||
@@ -35,7 +36,15 @@ export const computeFormatFunctions = async (
|
||||
|
||||
return {
|
||||
formatEntityState: (stateObj, state) =>
|
||||
computeStateDisplay(localize, stateObj, locale, config, entities, state),
|
||||
computeStateDisplay(
|
||||
localize,
|
||||
stateObj,
|
||||
locale,
|
||||
sensorNumericDeviceClasses,
|
||||
config,
|
||||
entities,
|
||||
state
|
||||
),
|
||||
formatEntityAttributeValue: (stateObj, attribute, value) =>
|
||||
computeAttributeValueDisplay(
|
||||
localize,
|
||||
|
@@ -313,31 +313,38 @@ export class HaChartBase extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _loading = false;
|
||||
|
||||
private async _setupChart() {
|
||||
if (this._loading) return;
|
||||
const ctx: CanvasRenderingContext2D = this.renderRoot
|
||||
.querySelector("canvas")!
|
||||
.getContext("2d")!;
|
||||
this._loading = true;
|
||||
try {
|
||||
const ChartConstructor = (await import("../../resources/chartjs")).Chart;
|
||||
|
||||
const ChartConstructor = (await import("../../resources/chartjs")).Chart;
|
||||
const computedStyles = getComputedStyle(this);
|
||||
|
||||
const computedStyles = getComputedStyle(this);
|
||||
ChartConstructor.defaults.borderColor =
|
||||
computedStyles.getPropertyValue("--divider-color");
|
||||
ChartConstructor.defaults.color = computedStyles.getPropertyValue(
|
||||
"--secondary-text-color"
|
||||
);
|
||||
ChartConstructor.defaults.font.family =
|
||||
computedStyles.getPropertyValue("--mdc-typography-body1-font-family") ||
|
||||
computedStyles.getPropertyValue("--mdc-typography-font-family") ||
|
||||
"Roboto, Noto, sans-serif";
|
||||
|
||||
ChartConstructor.defaults.borderColor =
|
||||
computedStyles.getPropertyValue("--divider-color");
|
||||
ChartConstructor.defaults.color = computedStyles.getPropertyValue(
|
||||
"--secondary-text-color"
|
||||
);
|
||||
ChartConstructor.defaults.font.family =
|
||||
computedStyles.getPropertyValue("--mdc-typography-body1-font-family") ||
|
||||
computedStyles.getPropertyValue("--mdc-typography-font-family") ||
|
||||
"Roboto, Noto, sans-serif";
|
||||
|
||||
this.chart = new ChartConstructor(ctx, {
|
||||
type: this.chartType,
|
||||
data: this.data,
|
||||
options: this._createOptions(),
|
||||
plugins: this._createPlugins(),
|
||||
});
|
||||
this.chart = new ChartConstructor(ctx, {
|
||||
type: this.chartType,
|
||||
data: this.data,
|
||||
options: this._createOptions(),
|
||||
plugins: this._createPlugins(),
|
||||
});
|
||||
} finally {
|
||||
this._loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private _createOptions() {
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import "element-internals-polyfill";
|
||||
import { MdAssistChip } from "@material/web/chips/assist-chip";
|
||||
import { css, html } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import "element-internals-polyfill";
|
||||
import { MdChipSet } from "@material/web/chips/chip-set";
|
||||
import { customElement } from "lit/decorators";
|
||||
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import "element-internals-polyfill";
|
||||
import { MdFilterChip } from "@material/web/chips/filter-chip";
|
||||
import { css, html } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import "element-internals-polyfill";
|
||||
import { MdInputChip } from "@material/web/chips/input-chip";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
@@ -20,6 +19,7 @@ export class HaInputChip extends MdInputChip {
|
||||
0.15
|
||||
);
|
||||
--ha-input-chip-selected-container-opacity: 1;
|
||||
--md-input-chip-label-text-font: Roboto, sans-serif;
|
||||
}
|
||||
/** Set the size of mdc icons **/
|
||||
::slotted([slot="icon"]) {
|
||||
|
@@ -565,36 +565,30 @@ export class HaDataTable extends LitElement {
|
||||
}, {});
|
||||
const groupedItems: DataTableRowData[] = [];
|
||||
Object.entries(sorted).forEach(([groupName, rows]) => {
|
||||
if (
|
||||
groupName !== UNDEFINED_GROUP_KEY ||
|
||||
Object.keys(sorted).length > 1
|
||||
) {
|
||||
groupedItems.push({
|
||||
append: true,
|
||||
content: html`<div
|
||||
class="mdc-data-table__cell group-header"
|
||||
role="cell"
|
||||
.group=${groupName}
|
||||
@click=${this._collapseGroup}
|
||||
groupedItems.push({
|
||||
append: true,
|
||||
content: html`<div
|
||||
class="mdc-data-table__cell group-header"
|
||||
role="cell"
|
||||
.group=${groupName}
|
||||
@click=${this._collapseGroup}
|
||||
>
|
||||
<ha-icon-button
|
||||
.path=${mdiChevronUp}
|
||||
class=${this._collapsedGroups.includes(groupName)
|
||||
? "collapsed"
|
||||
: ""}
|
||||
>
|
||||
<ha-icon-button
|
||||
.path=${mdiChevronUp}
|
||||
class=${this._collapsedGroups.includes(groupName)
|
||||
? "collapsed"
|
||||
: ""}
|
||||
>
|
||||
</ha-icon-button>
|
||||
${groupName === UNDEFINED_GROUP_KEY
|
||||
? this.hass.localize("ui.components.data-table.ungrouped")
|
||||
: groupName || ""}
|
||||
</div>`,
|
||||
});
|
||||
}
|
||||
</ha-icon-button>
|
||||
${groupName === UNDEFINED_GROUP_KEY
|
||||
? this.hass.localize("ui.components.data-table.ungrouped")
|
||||
: groupName || ""}
|
||||
</div>`,
|
||||
});
|
||||
if (!this._collapsedGroups.includes(groupName)) {
|
||||
groupedItems.push(...rows);
|
||||
}
|
||||
});
|
||||
|
||||
items = groupedItems;
|
||||
}
|
||||
|
||||
@@ -990,6 +984,7 @@ export class HaDataTable extends LitElement {
|
||||
padding-top: 12px;
|
||||
padding-left: 12px;
|
||||
padding-inline-start: 12px;
|
||||
padding-inline-end: initial;
|
||||
width: 100%;
|
||||
font-weight: 500;
|
||||
display: flex;
|
||||
|
@@ -76,6 +76,8 @@ class HaEntitiesPickerLight extends LitElement {
|
||||
@property({ attribute: false })
|
||||
public entityFilter?: HaEntityPickerEntityFilterFunc;
|
||||
|
||||
@property({ type: Array }) public createDomains?: string[];
|
||||
|
||||
protected render() {
|
||||
if (!this.hass) {
|
||||
return nothing;
|
||||
@@ -103,6 +105,7 @@ class HaEntitiesPickerLight extends LitElement {
|
||||
.value=${entityId}
|
||||
.label=${this.pickedEntityLabel}
|
||||
.disabled=${this.disabled}
|
||||
.createDomains=${this.createDomains}
|
||||
@value-changed=${this._entityChanged}
|
||||
></ha-entity-picker>
|
||||
</div>
|
||||
@@ -122,6 +125,7 @@ class HaEntitiesPickerLight extends LitElement {
|
||||
.label=${this.pickEntityLabel}
|
||||
.helper=${this.helper}
|
||||
.disabled=${this.disabled}
|
||||
.createDomains=${this.createDomains}
|
||||
.required=${this.required && !currentEntities.length}
|
||||
@value-changed=${this._addEntity}
|
||||
></ha-entity-picker>
|
||||
|
@@ -405,9 +405,9 @@ export class HaEntityPicker extends LitElement {
|
||||
this._opened = ev.detail.value;
|
||||
}
|
||||
|
||||
private _valueChanged(ev: ValueChangedEvent<string>) {
|
||||
private _valueChanged(ev: ValueChangedEvent<string | undefined>) {
|
||||
ev.stopPropagation();
|
||||
const newValue = ev.detail.value;
|
||||
const newValue = ev.detail.value?.trim();
|
||||
|
||||
if (newValue && newValue.startsWith(CREATE_ID)) {
|
||||
const domain = newValue.substring(CREATE_ID.length);
|
||||
@@ -427,13 +427,13 @@ export class HaEntityPicker extends LitElement {
|
||||
|
||||
private _filterChanged(ev: CustomEvent): void {
|
||||
const target = ev.target as HaComboBox;
|
||||
const filterString = ev.detail.value.toLowerCase();
|
||||
const filterString = ev.detail.value.trim().toLowerCase();
|
||||
target.filteredItems = filterString.length
|
||||
? fuzzyFilterSort<HassEntityWithCachedName>(filterString, this._states)
|
||||
: this._states;
|
||||
}
|
||||
|
||||
private _setValue(value: string) {
|
||||
private _setValue(value: string | undefined) {
|
||||
this.value = value;
|
||||
setTimeout(() => {
|
||||
fireEvent(this, "value-changed", { value });
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import "element-internals-polyfill";
|
||||
import { MdCircularProgress } from "@material/web/progress/circular-progress";
|
||||
import { PropertyValues, css } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
|
@@ -1,14 +1,7 @@
|
||||
import { Ripple } from "@material/mwc-ripple";
|
||||
import { RippleHandlers } from "@material/mwc-ripple/ripple-handlers";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import {
|
||||
customElement,
|
||||
eventOptions,
|
||||
property,
|
||||
queryAsync,
|
||||
state,
|
||||
} from "lit/decorators";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import "./ha-ripple";
|
||||
|
||||
@customElement("ha-control-button")
|
||||
export class HaControlButton extends LitElement {
|
||||
@@ -16,10 +9,6 @@ export class HaControlButton extends LitElement {
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
@queryAsync("mwc-ripple") private _ripple!: Promise<Ripple | null>;
|
||||
|
||||
@state() private _shouldRenderRipple = false;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<button
|
||||
@@ -28,54 +17,13 @@ export class HaControlButton extends LitElement {
|
||||
aria-label=${ifDefined(this.label)}
|
||||
title=${ifDefined(this.label)}
|
||||
.disabled=${Boolean(this.disabled)}
|
||||
@focus=${this.handleRippleFocus}
|
||||
@blur=${this.handleRippleBlur}
|
||||
@mousedown=${this.handleRippleActivate}
|
||||
@mouseup=${this.handleRippleDeactivate}
|
||||
@mouseenter=${this.handleRippleMouseEnter}
|
||||
@mouseleave=${this.handleRippleMouseLeave}
|
||||
@touchstart=${this.handleRippleActivate}
|
||||
@touchend=${this.handleRippleDeactivate}
|
||||
@touchcancel=${this.handleRippleDeactivate}
|
||||
>
|
||||
<slot></slot>
|
||||
${this._shouldRenderRipple && !this.disabled
|
||||
? html`<mwc-ripple></mwc-ripple>`
|
||||
: ""}
|
||||
<ha-ripple .disabled=${this.disabled}></ha-ripple>
|
||||
</button>
|
||||
`;
|
||||
}
|
||||
|
||||
private _rippleHandlers: RippleHandlers = new RippleHandlers(() => {
|
||||
this._shouldRenderRipple = true;
|
||||
return this._ripple;
|
||||
});
|
||||
|
||||
@eventOptions({ passive: true })
|
||||
private handleRippleActivate(evt?: Event) {
|
||||
this._rippleHandlers.startPress(evt);
|
||||
}
|
||||
|
||||
private handleRippleDeactivate() {
|
||||
this._rippleHandlers.endPress();
|
||||
}
|
||||
|
||||
private handleRippleMouseEnter() {
|
||||
this._rippleHandlers.startHover();
|
||||
}
|
||||
|
||||
private handleRippleMouseLeave() {
|
||||
this._rippleHandlers.endHover();
|
||||
}
|
||||
|
||||
private handleRippleFocus() {
|
||||
this._rippleHandlers.startFocus();
|
||||
}
|
||||
|
||||
private handleRippleBlur() {
|
||||
this._rippleHandlers.endFocus();
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return css`
|
||||
:host {
|
||||
@@ -86,6 +34,7 @@ export class HaControlButton extends LitElement {
|
||||
--control-button-border-radius: 10px;
|
||||
--control-button-padding: 8px;
|
||||
--mdc-icon-size: 20px;
|
||||
--ha-ripple-color: var(--secondary-text-color);
|
||||
color: var(--primary-text-color);
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
@@ -113,12 +62,14 @@ export class HaControlButton extends LitElement {
|
||||
outline: none;
|
||||
overflow: hidden;
|
||||
background: none;
|
||||
--mdc-ripple-color: var(--control-button-background-color);
|
||||
/* For safari border-radius overflow */
|
||||
z-index: 0;
|
||||
font-size: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
.button:focus-visible {
|
||||
--control-button-background-opacity: 0.4;
|
||||
}
|
||||
.button::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
|
@@ -1,22 +1,14 @@
|
||||
import { Ripple } from "@material/mwc-ripple";
|
||||
import { RippleHandlers } from "@material/mwc-ripple/ripple-handlers";
|
||||
import { SelectBase } from "@material/mwc-select/mwc-select-base";
|
||||
import { mdiMenuDown } from "@mdi/js";
|
||||
import { css, html, nothing } from "lit";
|
||||
import {
|
||||
customElement,
|
||||
eventOptions,
|
||||
property,
|
||||
query,
|
||||
queryAsync,
|
||||
state,
|
||||
} from "lit/decorators";
|
||||
import { customElement, property, query } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import { debounce } from "../common/util/debounce";
|
||||
import { nextRender } from "../common/util/render-status";
|
||||
import "./ha-icon";
|
||||
import type { HaIcon } from "./ha-icon";
|
||||
import "./ha-ripple";
|
||||
import "./ha-svg-icon";
|
||||
import type { HaSvgIcon } from "./ha-svg-icon";
|
||||
|
||||
@@ -32,10 +24,6 @@ export class HaControlSelectMenu extends SelectBase {
|
||||
@property({ type: Boolean, attribute: "hide-label" })
|
||||
public hideLabel = false;
|
||||
|
||||
@queryAsync("mwc-ripple") private _ripple!: Promise<Ripple | null>;
|
||||
|
||||
@state() private _shouldRenderRipple = false;
|
||||
|
||||
public override render() {
|
||||
const classes = {
|
||||
"select-disabled": this.disabled,
|
||||
@@ -69,17 +57,10 @@ export class HaControlSelectMenu extends SelectBase {
|
||||
aria-labelledby=${ifDefined(labelledby)}
|
||||
aria-label=${ifDefined(labelAttribute)}
|
||||
aria-required=${this.required}
|
||||
@click=${this.onClick}
|
||||
@focus=${this.onFocus}
|
||||
@blur=${this.onBlur}
|
||||
@click=${this.onClick}
|
||||
@keydown=${this.onKeydown}
|
||||
@mousedown=${this.handleRippleActivate}
|
||||
@mouseup=${this.handleRippleDeactivate}
|
||||
@mouseenter=${this.handleRippleMouseEnter}
|
||||
@mouseleave=${this.handleRippleMouseLeave}
|
||||
@touchstart=${this.handleRippleActivate}
|
||||
@touchend=${this.handleRippleDeactivate}
|
||||
@touchcancel=${this.handleRippleDeactivate}
|
||||
>
|
||||
${this.renderIcon()}
|
||||
<div class="content">
|
||||
@@ -91,9 +72,7 @@ export class HaControlSelectMenu extends SelectBase {
|
||||
: nothing}
|
||||
</div>
|
||||
${this.renderArrow()}
|
||||
${this._shouldRenderRipple && !this.disabled
|
||||
? html` <mwc-ripple></mwc-ripple> `
|
||||
: nothing}
|
||||
<ha-ripple .disabled=${this.disabled}></ha-ripple>
|
||||
</div>
|
||||
${this.renderMenu()}
|
||||
</div>
|
||||
@@ -104,7 +83,7 @@ export class HaControlSelectMenu extends SelectBase {
|
||||
if (!this.showArrow) return nothing;
|
||||
|
||||
return html`
|
||||
<div class="icon">
|
||||
<div class="icon arrow">
|
||||
<ha-svg-icon .path=${mdiMenuDown}></ha-svg-icon>
|
||||
</div>
|
||||
`;
|
||||
@@ -135,46 +114,6 @@ export class HaControlSelectMenu extends SelectBase {
|
||||
`;
|
||||
}
|
||||
|
||||
protected onFocus() {
|
||||
this.handleRippleFocus();
|
||||
super.onFocus();
|
||||
}
|
||||
|
||||
protected onBlur() {
|
||||
this.handleRippleBlur();
|
||||
super.onBlur();
|
||||
}
|
||||
|
||||
private _rippleHandlers: RippleHandlers = new RippleHandlers(() => {
|
||||
this._shouldRenderRipple = true;
|
||||
return this._ripple;
|
||||
});
|
||||
|
||||
@eventOptions({ passive: true })
|
||||
private handleRippleActivate(evt?: Event) {
|
||||
this._rippleHandlers.startPress(evt);
|
||||
}
|
||||
|
||||
private handleRippleDeactivate() {
|
||||
this._rippleHandlers.endPress();
|
||||
}
|
||||
|
||||
private handleRippleMouseEnter() {
|
||||
this._rippleHandlers.startHover();
|
||||
}
|
||||
|
||||
private handleRippleMouseLeave() {
|
||||
this._rippleHandlers.endHover();
|
||||
}
|
||||
|
||||
private handleRippleFocus() {
|
||||
this._rippleHandlers.startFocus();
|
||||
}
|
||||
|
||||
private handleRippleBlur() {
|
||||
this._rippleHandlers.endFocus();
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
super.connectedCallback();
|
||||
window.addEventListener("translations-updated", this._translationsUpdated);
|
||||
@@ -204,6 +143,7 @@ export class HaControlSelectMenu extends SelectBase {
|
||||
--control-select-menu-height: 48px;
|
||||
--control-select-menu-padding: 6px 10px;
|
||||
--mdc-icon-size: 20px;
|
||||
--ha-ripple-color: var(--secondary-text-color);
|
||||
font-size: 14px;
|
||||
line-height: 1.4;
|
||||
width: auto;
|
||||
@@ -224,7 +164,6 @@ export class HaControlSelectMenu extends SelectBase {
|
||||
outline: none;
|
||||
overflow: hidden;
|
||||
background: none;
|
||||
--mdc-ripple-color: var(--control-select-menu-background-color);
|
||||
/* For safari border-radius overflow */
|
||||
z-index: 0;
|
||||
transition: color 180ms ease-in-out;
|
||||
@@ -240,7 +179,8 @@ export class HaControlSelectMenu extends SelectBase {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
flex: 1;
|
||||
width: 0;
|
||||
flex-grow: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -253,6 +193,13 @@ export class HaControlSelectMenu extends SelectBase {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
margin-left: -10px;
|
||||
margin-inline-end: initial;
|
||||
margin-inline-start: -10px;
|
||||
direction: var(--direction);
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 0.85em;
|
||||
letter-spacing: 0.4px;
|
||||
@@ -264,6 +211,10 @@ export class HaControlSelectMenu extends SelectBase {
|
||||
letter-spacing: inherit;
|
||||
}
|
||||
|
||||
.select-anchor:focus-visible {
|
||||
--control-select-menu-background-opacity: 0.4;
|
||||
}
|
||||
|
||||
.select-anchor::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
|
@@ -19,6 +19,7 @@ import { HomeAssistant } from "../types";
|
||||
import "./ha-list-item";
|
||||
import "./ha-select";
|
||||
import type { HaSelect } from "./ha-select";
|
||||
import { getExtendedEntityRegistryEntry } from "../data/entity_registry";
|
||||
|
||||
const NONE = "__NONE_OPTION__";
|
||||
|
||||
@@ -107,13 +108,23 @@ export class HaConversationAgentPicker extends LitElement {
|
||||
}
|
||||
|
||||
private async _maybeFetchConfigEntry() {
|
||||
if (!this.value || this.value === "homeassistant") {
|
||||
if (!this.value || !(this.value in this.hass.entities)) {
|
||||
this._configEntry = undefined;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const regEntry = await getExtendedEntityRegistryEntry(
|
||||
this.hass,
|
||||
this.value
|
||||
);
|
||||
|
||||
if (!regEntry.config_entry_id) {
|
||||
this._configEntry = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
this._configEntry = (
|
||||
await getConfigEntry(this.hass, this.value)
|
||||
await getConfigEntry(this.hass, regEntry.config_entry_id)
|
||||
).config_entry;
|
||||
} catch (err) {
|
||||
this._configEntry = undefined;
|
||||
|
@@ -127,6 +127,10 @@ export class HaDialog extends DialogBase {
|
||||
border-radius: var(--ha-dialog-border-radius, 28px);
|
||||
-webkit-backdrop-filter: var(--ha-dialog-surface-backdrop-filter, none);
|
||||
backdrop-filter: var(--ha-dialog-surface-backdrop-filter, none);
|
||||
background: var(
|
||||
--ha-dialog-surface-background,
|
||||
var(--mdc-theme-surface, #fff)
|
||||
);
|
||||
}
|
||||
:host([flexContent]) .mdc-dialog .mdc-dialog__content {
|
||||
display: flex;
|
||||
|
@@ -87,8 +87,14 @@ export class HaFilterDomains extends LitElement {
|
||||
Object.keys(states).forEach((entityId) => {
|
||||
domains.add(computeDomain(entityId));
|
||||
});
|
||||
return Array.from(domains)
|
||||
.filter((domain) => !filter || domain.toLowerCase().includes(filter))
|
||||
|
||||
return Array.from(domains.values())
|
||||
.filter(
|
||||
(entry) =>
|
||||
!filter ||
|
||||
entry.toLowerCase().includes(filter) ||
|
||||
domainToName(this.hass.localize, entry).toLowerCase().includes(filter)
|
||||
)
|
||||
.sort((a, b) => stringCompare(a, b, this.hass.locale.language));
|
||||
});
|
||||
|
||||
@@ -163,14 +169,14 @@ export class HaFilterDomains extends LitElement {
|
||||
align-items: center;
|
||||
}
|
||||
.header ha-icon-button {
|
||||
margin-inline-start: auto;
|
||||
margin-inline-start: initial;
|
||||
margin-inline-end: 8px;
|
||||
}
|
||||
.badge {
|
||||
display: inline-block;
|
||||
margin-left: 8px;
|
||||
margin-inline-start: 8px;
|
||||
margin-inline-end: 0;
|
||||
margin-inline-end: initial;
|
||||
min-width: 16px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 50%;
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import "@material/web/ripple/ripple";
|
||||
|
||||
@customElement("ha-label")
|
||||
class HaLabel extends LitElement {
|
||||
@@ -11,7 +10,6 @@ class HaLabel extends LitElement {
|
||||
<span class="content">
|
||||
<slot name="icon"></slot>
|
||||
<slot></slot>
|
||||
<md-ripple></md-ripple>
|
||||
</span>
|
||||
`;
|
||||
}
|
||||
@@ -27,7 +25,6 @@ class HaLabel extends LitElement {
|
||||
0.15
|
||||
);
|
||||
--ha-label-background-opacity: 1;
|
||||
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
display: inline-flex;
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { customElement } from "lit/decorators";
|
||||
import "element-internals-polyfill";
|
||||
import { MdListItem } from "@material/web/list/list-item";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
|
||||
@customElement("ha-list-item-new")
|
||||
export class HaListItemNew extends MdListItem {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { customElement } from "lit/decorators";
|
||||
import "element-internals-polyfill";
|
||||
import { MdList } from "@material/web/list/list";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
|
||||
@customElement("ha-list-new")
|
||||
export class HaListNew extends MdList {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { MdMenuItem } from "@material/web/menu/menu-item";
|
||||
import "element-internals-polyfill";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
|
||||
@@ -25,6 +24,7 @@ export class HaMenuItem extends MdMenuItem {
|
||||
|
||||
--md-sys-color-on-primary-container: var(--primary-text-color);
|
||||
--md-sys-color-on-secondary-container: var(--primary-text-color);
|
||||
--md-menu-item-label-text-font: Roboto, sans-serif;
|
||||
}
|
||||
:host(.warning) {
|
||||
--md-menu-item-label-text-color: var(--error-color);
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { customElement } from "lit/decorators";
|
||||
import "element-internals-polyfill";
|
||||
import { css } from "lit";
|
||||
import { MdMenu } from "@material/web/menu/menu";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
|
||||
@customElement("ha-menu")
|
||||
export class HaMenu extends MdMenu {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { MdOutlinedButton } from "@material/web/button/outlined-button";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
import "element-internals-polyfill";
|
||||
import { MdOutlinedButton } from "@material/web/button/outlined-button";
|
||||
|
||||
@customElement("ha-outlined-button")
|
||||
export class HaOutlinedButton extends MdOutlinedButton {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { MdOutlinedField } from "@material/web/field/outlined-field";
|
||||
import "element-internals-polyfill";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
import { literal } from "lit/static-html";
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { MdOutlinedIconButton } from "@material/web/iconbutton/outlined-icon-button";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
import "element-internals-polyfill";
|
||||
import { MdOutlinedIconButton } from "@material/web/iconbutton/outlined-icon-button";
|
||||
|
||||
@customElement("ha-outlined-icon-button")
|
||||
export class HaOutlinedIconButton extends MdOutlinedIconButton {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { MdOutlinedTextField } from "@material/web/textfield/outlined-text-field";
|
||||
import "element-internals-polyfill";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
import { literal } from "lit/static-html";
|
||||
|
62
src/components/ha-ripple.ts
Normal file
62
src/components/ha-ripple.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { AttachableController } from "@material/web/internal/controller/attachable-controller";
|
||||
import { MdRipple } from "@material/web/ripple/ripple";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
|
||||
@customElement("ha-ripple")
|
||||
export class HaRipple extends MdRipple {
|
||||
private readonly attachableTouchController = new AttachableController(
|
||||
this,
|
||||
this.onTouchControlChange.bind(this)
|
||||
);
|
||||
|
||||
attach(control: HTMLElement) {
|
||||
super.attach(control);
|
||||
this.attachableTouchController.attach(control);
|
||||
}
|
||||
|
||||
detach() {
|
||||
super.detach();
|
||||
this.attachableTouchController.detach();
|
||||
}
|
||||
|
||||
private _handleTouchEnd = () => {
|
||||
if (!this.disabled) {
|
||||
// @ts-ignore
|
||||
super.endPressAnimation();
|
||||
}
|
||||
};
|
||||
|
||||
private onTouchControlChange(
|
||||
prev: HTMLElement | null,
|
||||
next: HTMLElement | null
|
||||
) {
|
||||
// Add touchend event to clean ripple on touch devices using action handler
|
||||
prev?.removeEventListener("touchend", this._handleTouchEnd);
|
||||
next?.addEventListener("touchend", this._handleTouchEnd);
|
||||
}
|
||||
|
||||
static override styles = [
|
||||
...super.styles,
|
||||
css`
|
||||
:host {
|
||||
--md-ripple-hover-opacity: var(--ha-ripple-hover-opacity, 0.08);
|
||||
--md-ripple-pressed-opacity: var(--ha-ripple-pressed-opacity, 0.12);
|
||||
--md-ripple-hover-color: var(
|
||||
--ha-ripple-hover-color,
|
||||
var(--ha-ripple-color, var(--secondary-text-color))
|
||||
);
|
||||
--md-ripple-pressed-color: var(
|
||||
--ha-ripple-pressed-color,
|
||||
var(--ha-ripple-color, var(--secondary-text-color))
|
||||
);
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"ha-ripple": HaRipple;
|
||||
}
|
||||
}
|
@@ -8,7 +8,10 @@ import {
|
||||
fetchEntitySourcesWithCache,
|
||||
} from "../../data/entity_sources";
|
||||
import type { EntitySelector } from "../../data/selector";
|
||||
import { filterSelectorEntities } from "../../data/selector";
|
||||
import {
|
||||
filterSelectorEntities,
|
||||
computeCreateDomains,
|
||||
} from "../../data/selector";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "../entity/ha-entities-picker";
|
||||
import "../entity/ha-entity-picker";
|
||||
@@ -31,6 +34,8 @@ export class HaEntitySelector extends LitElement {
|
||||
|
||||
@property({ type: Boolean }) public required = true;
|
||||
|
||||
@state() private _createDomains: string[] | undefined;
|
||||
|
||||
private _hasIntegration(selector: EntitySelector) {
|
||||
return (
|
||||
selector.entity?.filter &&
|
||||
@@ -64,6 +69,7 @@ export class HaEntitySelector extends LitElement {
|
||||
.includeEntities=${this.selector.entity?.include_entities}
|
||||
.excludeEntities=${this.selector.entity?.exclude_entities}
|
||||
.entityFilter=${this._filterEntities}
|
||||
.createDomains=${this._createDomains}
|
||||
.disabled=${this.disabled}
|
||||
.required=${this.required}
|
||||
allow-custom-entity
|
||||
@@ -79,6 +85,7 @@ export class HaEntitySelector extends LitElement {
|
||||
.includeEntities=${this.selector.entity.include_entities}
|
||||
.excludeEntities=${this.selector.entity.exclude_entities}
|
||||
.entityFilter=${this._filterEntities}
|
||||
.createDomains=${this._createDomains}
|
||||
.disabled=${this.disabled}
|
||||
.required=${this.required}
|
||||
></ha-entities-picker>
|
||||
@@ -96,6 +103,9 @@ export class HaEntitySelector extends LitElement {
|
||||
this._entitySources = sources;
|
||||
});
|
||||
}
|
||||
if (changedProps.has("selector")) {
|
||||
this._createDomains = computeCreateDomains(this.selector);
|
||||
}
|
||||
}
|
||||
|
||||
private _filterEntities = (entity: HassEntity): boolean => {
|
||||
|
@@ -278,6 +278,14 @@ export class HaSelectSelector extends LitElement {
|
||||
|
||||
private _valueChanged(ev) {
|
||||
ev.stopPropagation();
|
||||
|
||||
if (ev.detail?.index === -1 && this.value !== undefined) {
|
||||
fireEvent(this, "value-changed", {
|
||||
value: undefined,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const value = ev.detail?.value || ev.target.value;
|
||||
if (this.disabled || value === undefined || value === (this.value ?? "")) {
|
||||
return;
|
||||
|
@@ -22,6 +22,7 @@ import {
|
||||
filterSelectorDevices,
|
||||
filterSelectorEntities,
|
||||
TargetSelector,
|
||||
computeCreateDomains,
|
||||
} from "../../data/selector";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import "../ha-target-picker";
|
||||
@@ -42,6 +43,8 @@ export class HaTargetSelector extends LitElement {
|
||||
|
||||
@state() private _entitySources?: EntitySources;
|
||||
|
||||
@state() private _createDomains: string[] | undefined;
|
||||
|
||||
private _deviceIntegrationLookup = memoizeOne(getDeviceIntegrationLookup);
|
||||
|
||||
private _hasIntegration(selector: TargetSelector) {
|
||||
@@ -68,6 +71,9 @@ export class HaTargetSelector extends LitElement {
|
||||
this._entitySources = sources;
|
||||
});
|
||||
}
|
||||
if (changedProperties.has("selector")) {
|
||||
this._createDomains = computeCreateDomains(this.selector);
|
||||
}
|
||||
}
|
||||
|
||||
protected render() {
|
||||
@@ -82,7 +88,7 @@ export class HaTargetSelector extends LitElement {
|
||||
.deviceFilter=${this._filterDevices}
|
||||
.entityFilter=${this._filterEntities}
|
||||
.disabled=${this.disabled}
|
||||
.createDomains=${this.selector.target?.create_domains}
|
||||
.createDomains=${this._createDomains}
|
||||
></ha-target-picker>`;
|
||||
}
|
||||
|
||||
|
@@ -44,7 +44,6 @@ import "./ha-service-picker";
|
||||
import "./ha-settings-row";
|
||||
import "./ha-yaml-editor";
|
||||
import type { HaYamlEditor } from "./ha-yaml-editor";
|
||||
import { isHelperDomain } from "../panels/config/helpers/const";
|
||||
|
||||
const attributeFilter = (values: any[], attribute: any) => {
|
||||
if (typeof attribute === "object") {
|
||||
@@ -366,12 +365,8 @@ export class HaServiceControl extends LitElement {
|
||||
}
|
||||
|
||||
private _targetSelector = memoizeOne(
|
||||
(targetSelector: TargetSelector | null | undefined, domain?: string) => {
|
||||
const create_domains = isHelperDomain(domain) ? [domain] : undefined;
|
||||
return targetSelector
|
||||
? { target: { ...targetSelector, create_domains } }
|
||||
: { target: { create_domains } };
|
||||
}
|
||||
(targetSelector: TargetSelector | null | undefined) =>
|
||||
targetSelector ? { target: { ...targetSelector } } : { target: {} }
|
||||
);
|
||||
|
||||
protected render() {
|
||||
@@ -462,8 +457,7 @@ export class HaServiceControl extends LitElement {
|
||||
><ha-selector
|
||||
.hass=${this.hass}
|
||||
.selector=${this._targetSelector(
|
||||
serviceData.target as TargetSelector,
|
||||
domain
|
||||
serviceData.target as TargetSelector
|
||||
)}
|
||||
.disabled=${this.disabled}
|
||||
@value-changed=${this._targetChanged}
|
||||
|
@@ -54,7 +54,7 @@ export class HaSettingsRow extends LitElement {
|
||||
.body[three-line] {
|
||||
min-height: var(--paper-item-body-three-line-min-height, 88px);
|
||||
}
|
||||
:host(:not([wrap-heading])) > * {
|
||||
:host(:not([wrap-heading])) body > * {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { customElement } from "lit/decorators";
|
||||
import "element-internals-polyfill";
|
||||
import { MdSlider } from "@material/web/slider/slider";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
import { mainWindow } from "../common/dom/get_main_window";
|
||||
|
||||
@customElement("ha-slider")
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { customElement } from "lit/decorators";
|
||||
import "element-internals-polyfill";
|
||||
import { css } from "lit";
|
||||
import { MdSubMenu } from "@material/web/menu/sub-menu";
|
||||
import { css } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
|
||||
@customElement("ha-sub-menu")
|
||||
export class HaSubMenu extends MdSubMenu {
|
||||
|
@@ -1,15 +1,7 @@
|
||||
import type { Ripple } from "@material/mwc-ripple";
|
||||
import "@material/mwc-ripple/mwc-ripple";
|
||||
import { RippleHandlers } from "@material/mwc-ripple/ripple-handlers";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import {
|
||||
customElement,
|
||||
eventOptions,
|
||||
property,
|
||||
queryAsync,
|
||||
state,
|
||||
} from "lit/decorators";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import "./ha-ripple";
|
||||
|
||||
@customElement("ha-tab")
|
||||
export class HaTab extends LitElement {
|
||||
@@ -19,10 +11,6 @@ export class HaTab extends LitElement {
|
||||
|
||||
@property() public name?: string;
|
||||
|
||||
@queryAsync("mwc-ripple") private _ripple!: Promise<Ripple | null>;
|
||||
|
||||
@state() private _shouldRenderRipple = false;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<div
|
||||
@@ -30,60 +18,21 @@ export class HaTab extends LitElement {
|
||||
role="tab"
|
||||
aria-selected=${this.active}
|
||||
aria-label=${ifDefined(this.name)}
|
||||
@focus=${this.handleRippleFocus}
|
||||
@blur=${this.handleRippleBlur}
|
||||
@mousedown=${this.handleRippleActivate}
|
||||
@mouseup=${this.handleRippleDeactivate}
|
||||
@mouseenter=${this.handleRippleMouseEnter}
|
||||
@mouseleave=${this.handleRippleMouseLeave}
|
||||
@touchstart=${this.handleRippleActivate}
|
||||
@touchend=${this.handleRippleDeactivate}
|
||||
@touchcancel=${this.handleRippleDeactivate}
|
||||
@keydown=${this._handleKeyDown}
|
||||
>
|
||||
${this.narrow ? html`<slot name="icon"></slot>` : ""}
|
||||
<span class="name">${this.name}</span>
|
||||
${this._shouldRenderRipple ? html`<mwc-ripple></mwc-ripple>` : ""}
|
||||
<ha-ripple></ha-ripple>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
private _rippleHandlers: RippleHandlers = new RippleHandlers(() => {
|
||||
this._shouldRenderRipple = true;
|
||||
return this._ripple;
|
||||
});
|
||||
|
||||
private _handleKeyDown(ev: KeyboardEvent): void {
|
||||
if (ev.key === "Enter") {
|
||||
(ev.target as HTMLElement).click();
|
||||
}
|
||||
}
|
||||
|
||||
@eventOptions({ passive: true })
|
||||
private handleRippleActivate(evt?: Event) {
|
||||
this._rippleHandlers.startPress(evt);
|
||||
}
|
||||
|
||||
private handleRippleDeactivate() {
|
||||
this._rippleHandlers.endPress();
|
||||
}
|
||||
|
||||
private handleRippleMouseEnter() {
|
||||
this._rippleHandlers.startHover();
|
||||
}
|
||||
|
||||
private handleRippleMouseLeave() {
|
||||
this._rippleHandlers.endHover();
|
||||
}
|
||||
|
||||
private handleRippleFocus() {
|
||||
this._rippleHandlers.startFocus();
|
||||
}
|
||||
|
||||
private handleRippleBlur() {
|
||||
this._rippleHandlers.endFocus();
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return css`
|
||||
div {
|
||||
@@ -126,6 +75,15 @@ export class HaTab extends LitElement {
|
||||
:host([narrow]) div {
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
div:focus-visible:before {
|
||||
position: absolute;
|
||||
display: block;
|
||||
content: "";
|
||||
inset: 0;
|
||||
background-color: var(--secondary-text-color);
|
||||
opacity: 0.08;
|
||||
}
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,6 @@ import {
|
||||
} from "../../common/dom/setup-leaflet-map";
|
||||
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||
import { loadPolyfillIfNeeded } from "../../resources/resize-observer.polyfill";
|
||||
import { HomeAssistant, ThemeMode } from "../../types";
|
||||
import { isTouch } from "../../util/is_touch";
|
||||
import "../ha-icon-button";
|
||||
@@ -178,16 +177,24 @@ export class HaMap extends ReactiveElement {
|
||||
map!.classList.toggle("forced-light", this.themeMode === "light");
|
||||
}
|
||||
|
||||
private _loading = false;
|
||||
|
||||
private async _loadMap(): Promise<void> {
|
||||
if (this._loading) return;
|
||||
let map = this.shadowRoot!.getElementById("map");
|
||||
if (!map) {
|
||||
map = document.createElement("div");
|
||||
map.id = "map";
|
||||
this.shadowRoot!.append(map);
|
||||
}
|
||||
[this.leafletMap, this.Leaflet] = await setupLeafletMap(map);
|
||||
this._updateMapStyle();
|
||||
this._loaded = true;
|
||||
this._loading = true;
|
||||
try {
|
||||
[this.leafletMap, this.Leaflet] = await setupLeafletMap(map);
|
||||
this._updateMapStyle();
|
||||
this._loaded = true;
|
||||
} finally {
|
||||
this._loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
public fitMap(options?: { zoom?: number; pad?: number }): void {
|
||||
@@ -528,7 +535,6 @@ export class HaMap extends ReactiveElement {
|
||||
|
||||
private async _attachObserver(): Promise<void> {
|
||||
if (!this._resizeObserver) {
|
||||
await loadPolyfillIfNeeded();
|
||||
this._resizeObserver = new ResizeObserver(() => {
|
||||
this.leafletMap?.invalidateSize({ debounceMoveend: true });
|
||||
});
|
||||
|
@@ -39,7 +39,6 @@ import {
|
||||
import { browseLocalMediaPlayer } from "../../data/media_source";
|
||||
import { isTTSMediaSource } from "../../data/tts";
|
||||
import { showAlertDialog } from "../../dialogs/generic/show-dialog-box";
|
||||
import { loadPolyfillIfNeeded } from "../../resources/resize-observer.polyfill";
|
||||
import { haStyle } from "../../resources/styles";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import {
|
||||
@@ -770,7 +769,6 @@ export class HaMediaPlayerBrowse extends LitElement {
|
||||
|
||||
private async _attachResizeObserver(): Promise<void> {
|
||||
if (!this._resizeObserver) {
|
||||
await loadPolyfillIfNeeded();
|
||||
this._resizeObserver = new ResizeObserver(
|
||||
debounce(() => this._measureCard(), 250, false)
|
||||
);
|
||||
|
@@ -79,7 +79,7 @@ class SearchInputOutlined extends LitElement {
|
||||
}
|
||||
|
||||
private async _filterInputChanged(e) {
|
||||
this._filterChanged(e.target.value);
|
||||
this._filterChanged(e.target.value?.trim());
|
||||
}
|
||||
|
||||
private async _clearSearch() {
|
||||
|
@@ -67,7 +67,7 @@ class SearchInput extends LitElement {
|
||||
}
|
||||
|
||||
private async _filterInputChanged(e) {
|
||||
this._filterChanged(e.target.value);
|
||||
this._filterChanged(e.target.value?.trim());
|
||||
}
|
||||
|
||||
private async _clearSearch() {
|
||||
|
@@ -13,6 +13,7 @@ import {
|
||||
mdiClose,
|
||||
mdiCodeBraces,
|
||||
mdiCodeBrackets,
|
||||
mdiFormatListNumbered,
|
||||
mdiRefresh,
|
||||
mdiRoomService,
|
||||
mdiShuffleDisabled,
|
||||
@@ -29,6 +30,7 @@ import {
|
||||
ManualScriptConfig,
|
||||
ParallelAction,
|
||||
RepeatAction,
|
||||
SequenceAction,
|
||||
ServiceAction,
|
||||
WaitAction,
|
||||
WaitForTriggerAction,
|
||||
@@ -119,6 +121,7 @@ export class HatScriptGraph extends LitElement {
|
||||
repeat: this.render_repeat_node,
|
||||
choose: this.render_choose_node,
|
||||
if: this.render_if_node,
|
||||
sequence: this.render_sequence_node,
|
||||
parallel: this.render_parallel_node,
|
||||
other: this.render_other_node,
|
||||
};
|
||||
@@ -460,6 +463,44 @@ export class HatScriptGraph extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private render_sequence_node(
|
||||
node: SequenceAction,
|
||||
path: string,
|
||||
graphStart = false,
|
||||
disabled = false
|
||||
) {
|
||||
const trace: any = this.trace.trace[path];
|
||||
return html`
|
||||
<hat-graph-branch
|
||||
tabindex=${trace === undefined ? "-1" : "0"}
|
||||
@focus=${this.selectNode(node, path)}
|
||||
?track=${path in this.trace.trace}
|
||||
?active=${this.selected === path}
|
||||
.notEnabled=${disabled || node.enabled === false}
|
||||
>
|
||||
<div class="graph-container" ?track=${path in this.trace.trace}>
|
||||
<hat-graph-node
|
||||
.graphStart=${graphStart}
|
||||
.iconPath=${mdiFormatListNumbered}
|
||||
?track=${path in this.trace.trace}
|
||||
?active=${this.selected === path}
|
||||
.notEnabled=${disabled || node.enabled === false}
|
||||
slot="head"
|
||||
nofocus
|
||||
></hat-graph-node>
|
||||
${ensureArray(node.sequence).map((action, i) =>
|
||||
this.render_action_node(
|
||||
action,
|
||||
`${path}/sequence/${i}`,
|
||||
false,
|
||||
disabled || node.enabled === false
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
</hat-graph-branch>
|
||||
`;
|
||||
}
|
||||
|
||||
private render_parallel_node(
|
||||
node: ParallelAction,
|
||||
path: string,
|
||||
|
@@ -37,6 +37,7 @@ import {
|
||||
IfAction,
|
||||
ParallelAction,
|
||||
RepeatAction,
|
||||
SequenceAction,
|
||||
getActionType,
|
||||
} from "../../data/script";
|
||||
import { describeAction } from "../../data/script_i18n";
|
||||
@@ -310,6 +311,10 @@ class ActionRenderer {
|
||||
return this._handleIf(index);
|
||||
}
|
||||
|
||||
if (actionType === "sequence") {
|
||||
return this._handleSequence(index);
|
||||
}
|
||||
|
||||
if (actionType === "parallel") {
|
||||
return this._handleParallel(index);
|
||||
}
|
||||
@@ -579,6 +584,37 @@ class ActionRenderer {
|
||||
return i;
|
||||
}
|
||||
|
||||
private _handleSequence(index: number): number {
|
||||
const sequencePath = this.keys[index];
|
||||
const sequenceConfig = this._getDataFromPath(
|
||||
this.keys[index]
|
||||
) as SequenceAction;
|
||||
|
||||
this._renderEntry(
|
||||
sequencePath,
|
||||
sequenceConfig.alias ||
|
||||
describeAction(
|
||||
this.hass,
|
||||
this.entityReg,
|
||||
this.labelReg,
|
||||
this.floorReg,
|
||||
sequenceConfig,
|
||||
"sequence"
|
||||
),
|
||||
undefined,
|
||||
sequenceConfig.enabled === false
|
||||
);
|
||||
|
||||
let i: number;
|
||||
|
||||
for (i = index + 1; i < this.keys.length; i++) {
|
||||
const path = this.keys[i];
|
||||
this._renderItem(i, getActionType(this._getDataFromPath(path)));
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private _handleParallel(index: number): number {
|
||||
const parallelPath = this.keys[index];
|
||||
const startLevel = parallelPath.split("/").length;
|
||||
|
@@ -8,6 +8,7 @@ import {
|
||||
mdiDevices,
|
||||
mdiDotsHorizontal,
|
||||
mdiExcavator,
|
||||
mdiFormatListNumbered,
|
||||
mdiGestureDoubleTap,
|
||||
mdiHandBackRight,
|
||||
mdiPalette,
|
||||
@@ -35,6 +36,7 @@ export const ACTION_ICONS = {
|
||||
if: mdiCallSplit,
|
||||
device_id: mdiDevices,
|
||||
stop: mdiHandBackRight,
|
||||
sequence: mdiFormatListNumbered,
|
||||
parallel: mdiShuffleDisabled,
|
||||
variables: mdiApplicationVariableOutline,
|
||||
set_conversation_response: mdiBullhorn,
|
||||
@@ -61,6 +63,7 @@ export const ACTION_GROUPS: AutomationElementGroup = {
|
||||
choose: {},
|
||||
if: {},
|
||||
stop: {},
|
||||
sequence: {},
|
||||
parallel: {},
|
||||
variables: {},
|
||||
},
|
||||
|
@@ -11,6 +11,7 @@ import {
|
||||
HassEntityBase,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { HomeAssistant } from "../types";
|
||||
import { supportsFeature } from "../common/entity/supports-feature";
|
||||
|
||||
export const FORMAT_TEXT = "text";
|
||||
export const FORMAT_NUMBER = "number";
|
||||
@@ -96,3 +97,9 @@ export const ALARM_MODES: Record<AlarmMode, AlarmConfig> = {
|
||||
path: mdiShieldOff,
|
||||
},
|
||||
};
|
||||
|
||||
export const supportedAlarmModes = (stateObj: AlarmControlPanelEntity) =>
|
||||
(Object.keys(ALARM_MODES) as AlarmMode[]).filter((mode) => {
|
||||
const feature = ALARM_MODES[mode].feature;
|
||||
return !feature || supportsFeature(stateObj, feature);
|
||||
});
|
||||
|
@@ -173,7 +173,7 @@ export interface WaterSourceTypeEnergyPreference {
|
||||
unit_of_measurement?: string | null;
|
||||
}
|
||||
|
||||
type EnergySource =
|
||||
export type EnergySource =
|
||||
| SolarSourceTypeEnergyPreference
|
||||
| GridSourceTypeEnergyPreference
|
||||
| BatterySourceTypeEnergyPreference
|
||||
|
@@ -297,6 +297,7 @@ const processTimelineEntity = (
|
||||
state_localize: computeStateDisplayFromEntityAttributes(
|
||||
localize,
|
||||
locale,
|
||||
[], // numeric device classes not used for Timeline
|
||||
config,
|
||||
entities[entityId],
|
||||
entityId,
|
||||
|
@@ -44,6 +44,7 @@ export interface IntegrationManifest {
|
||||
| "local_polling"
|
||||
| "local_push";
|
||||
single_config_entry?: boolean;
|
||||
version?: string;
|
||||
}
|
||||
export interface IntegrationSetup {
|
||||
domain: string;
|
||||
|
@@ -26,6 +26,10 @@ export function isLocked(stateObj: LockEntity) {
|
||||
return stateObj.state === "locked";
|
||||
}
|
||||
|
||||
export function isUnlocked(stateObj: LockEntity) {
|
||||
return stateObj.state === "unlocked";
|
||||
}
|
||||
|
||||
export function isUnlocking(stateObj: LockEntity) {
|
||||
return stateObj.state === "unlocking";
|
||||
}
|
||||
@@ -38,15 +42,40 @@ export function isJammed(stateObj: LockEntity) {
|
||||
return stateObj.state === "jammed";
|
||||
}
|
||||
|
||||
export function isAvailable(stateObj: LockEntity) {
|
||||
export function isOpen(stateObj: LockEntity) {
|
||||
return stateObj.state === "open";
|
||||
}
|
||||
|
||||
export function isOpening(stateObj: LockEntity) {
|
||||
return stateObj.state === "opening";
|
||||
}
|
||||
|
||||
export function isWaiting(stateObj: LockEntity) {
|
||||
return ["opening", "unlocking", "locking"].includes(stateObj.state);
|
||||
}
|
||||
|
||||
export function canOpen(stateObj: LockEntity) {
|
||||
if (stateObj.state === UNAVAILABLE) {
|
||||
return false;
|
||||
}
|
||||
const assumedState = stateObj.attributes.assumed_state === true;
|
||||
return (
|
||||
assumedState ||
|
||||
(!isLocking(stateObj) && !isUnlocking(stateObj) && !isJammed(stateObj))
|
||||
);
|
||||
return assumedState || (!isOpen(stateObj) && !isWaiting(stateObj));
|
||||
}
|
||||
|
||||
export function canLock(stateObj: LockEntity) {
|
||||
if (stateObj.state === UNAVAILABLE) {
|
||||
return false;
|
||||
}
|
||||
const assumedState = stateObj.attributes.assumed_state === true;
|
||||
return assumedState || (!isLocked(stateObj) && !isWaiting(stateObj));
|
||||
}
|
||||
|
||||
export function canUnlock(stateObj: LockEntity) {
|
||||
if (stateObj.state === UNAVAILABLE) {
|
||||
return false;
|
||||
}
|
||||
const assumedState = stateObj.attributes.assumed_state === true;
|
||||
return assumedState || (!isUnlocked(stateObj) && !isWaiting(stateObj));
|
||||
}
|
||||
|
||||
export const callProtectedLockService = async (
|
||||
|
@@ -358,6 +358,10 @@ export const localizeStateMessage = (
|
||||
return localize(`${LOGBOOK_LOCALIZE_PATH}.is_locking`);
|
||||
case "unlocking":
|
||||
return localize(`${LOGBOOK_LOCALIZE_PATH}.is_unlocking`);
|
||||
case "opening":
|
||||
return localize(`${LOGBOOK_LOCALIZE_PATH}.is_opening`);
|
||||
case "open":
|
||||
return localize(`${LOGBOOK_LOCALIZE_PATH}.is_opened`);
|
||||
case "locked":
|
||||
return localize(`${LOGBOOK_LOCALIZE_PATH}.was_locked`);
|
||||
case "jammed":
|
||||
|
@@ -1,8 +1,10 @@
|
||||
import type { Condition } from "../../../panels/lovelace/common/validate-condition";
|
||||
import type { LovelaceCardConfig } from "./card";
|
||||
import type { LovelaceStrategyConfig } from "./strategy";
|
||||
|
||||
export interface LovelaceBaseSectionConfig {
|
||||
title?: string;
|
||||
visibility?: Condition[];
|
||||
}
|
||||
|
||||
export interface LovelaceSectionConfig extends LovelaceBaseSectionConfig {
|
||||
|
@@ -93,6 +93,7 @@ export type ScriptConfig = ManualScriptConfig | BlueprintScriptConfig;
|
||||
|
||||
export interface ManualScriptConfig {
|
||||
alias: string;
|
||||
description?: string;
|
||||
sequence: Action | Action[];
|
||||
icon?: string;
|
||||
mode?: (typeof MODES)[number];
|
||||
@@ -247,6 +248,10 @@ export interface StopAction extends BaseAction {
|
||||
error?: boolean;
|
||||
}
|
||||
|
||||
export interface SequenceAction extends BaseAction {
|
||||
sequence: (ManualScriptConfig | Action)[];
|
||||
}
|
||||
|
||||
export interface ParallelAction extends BaseAction {
|
||||
parallel: ManualScriptConfig | Action | (ManualScriptConfig | Action)[];
|
||||
}
|
||||
@@ -273,6 +278,7 @@ export type NonConditionAction =
|
||||
| VariablesAction
|
||||
| PlayMediaAction
|
||||
| StopAction
|
||||
| SequenceAction
|
||||
| ParallelAction
|
||||
| UnknownAction;
|
||||
|
||||
@@ -298,6 +304,7 @@ export interface ActionTypes {
|
||||
service: ServiceAction;
|
||||
play_media: PlayMediaAction;
|
||||
stop: StopAction;
|
||||
sequence: SequenceAction;
|
||||
parallel: ParallelAction;
|
||||
set_conversation_response: SetConversationResponseAction;
|
||||
unknown: UnknownAction;
|
||||
@@ -388,6 +395,9 @@ export const getActionType = (action: Action): ActionType => {
|
||||
if ("stop" in action) {
|
||||
return "stop";
|
||||
}
|
||||
if ("sequence" in action) {
|
||||
return "sequence";
|
||||
}
|
||||
if ("parallel" in action) {
|
||||
return "parallel";
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ import {
|
||||
PlayMediaAction,
|
||||
RepeatAction,
|
||||
SceneAction,
|
||||
SequenceAction,
|
||||
SetConversationResponseAction,
|
||||
StopAction,
|
||||
VariablesAction,
|
||||
@@ -89,7 +90,8 @@ const tryDescribeAction = <T extends ActionType>(
|
||||
const config = action as ActionTypes["service"];
|
||||
|
||||
const targets: string[] = [];
|
||||
if (config.target) {
|
||||
const targetOrData = config.target || config.data;
|
||||
if (targetOrData) {
|
||||
for (const [key, name] of Object.entries({
|
||||
area_id: "areas",
|
||||
device_id: "devices",
|
||||
@@ -97,12 +99,10 @@ const tryDescribeAction = <T extends ActionType>(
|
||||
floor_id: "floors",
|
||||
label_id: "labels",
|
||||
})) {
|
||||
if (!(key in config.target)) {
|
||||
if (!(key in targetOrData)) {
|
||||
continue;
|
||||
}
|
||||
const keyConf: string[] = Array.isArray(config.target[key])
|
||||
? config.target[key]
|
||||
: [config.target[key]];
|
||||
const keyConf: string[] = ensureArray(targetOrData[key]) || [];
|
||||
|
||||
for (const targetThing of keyConf) {
|
||||
if (isTemplate(targetThing)) {
|
||||
@@ -195,8 +195,12 @@ const tryDescribeAction = <T extends ActionType>(
|
||||
(config.service && isTemplate(config.service))
|
||||
) {
|
||||
return hass.localize(
|
||||
`${actionTranslationBaseKey}.service.description.service_based_on_template`,
|
||||
{ targets: formatListWithAnds(hass.locale, targets) }
|
||||
targets.length
|
||||
? `${actionTranslationBaseKey}.service.description.service_based_on_template`
|
||||
: `${actionTranslationBaseKey}.service.description.service_based_on_template_no_targets`,
|
||||
{
|
||||
targets: formatListWithAnds(hass.locale, targets),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -208,7 +212,9 @@ const tryDescribeAction = <T extends ActionType>(
|
||||
|
||||
if (config.metadata) {
|
||||
return hass.localize(
|
||||
`${actionTranslationBaseKey}.service.description.service_name`,
|
||||
targets.length
|
||||
? `${actionTranslationBaseKey}.service.description.service_name`
|
||||
: `${actionTranslationBaseKey}.service.description.service_name_no_targets`,
|
||||
{
|
||||
domain: domainToName(hass.localize, domain),
|
||||
name: service || config.service,
|
||||
@@ -218,7 +224,9 @@ const tryDescribeAction = <T extends ActionType>(
|
||||
}
|
||||
|
||||
return hass.localize(
|
||||
`${actionTranslationBaseKey}.service.description.service_based_on_name`,
|
||||
targets.length
|
||||
? `${actionTranslationBaseKey}.service.description.service_based_on_name`
|
||||
: `${actionTranslationBaseKey}.service.description.service_based_on_name_no_targets`,
|
||||
{
|
||||
name: service
|
||||
? `${domainToName(hass.localize, domain)}: ${service}`
|
||||
@@ -471,6 +479,15 @@ const tryDescribeAction = <T extends ActionType>(
|
||||
}`;
|
||||
}
|
||||
|
||||
if (actionType === "sequence") {
|
||||
const config = action as SequenceAction;
|
||||
const numActions = ensureArray(config.sequence).length;
|
||||
return hass.localize(
|
||||
`${actionTranslationBaseKey}.sequence.description.full`,
|
||||
{ number: numActions }
|
||||
);
|
||||
}
|
||||
|
||||
if (actionType === "parallel") {
|
||||
const config = action as ParallelAction;
|
||||
const numActions = ensureArray(config.parallel).length;
|
||||
|
@@ -13,6 +13,7 @@ import {
|
||||
EntityRegistryEntry,
|
||||
} from "./entity_registry";
|
||||
import { EntitySources } from "./entity_sources";
|
||||
import { isHelperDomain } from "../panels/config/helpers/const";
|
||||
|
||||
export type Selector =
|
||||
| ActionSelector
|
||||
@@ -405,7 +406,6 @@ export interface TargetSelector {
|
||||
target: {
|
||||
entity?: EntitySelectorFilter | readonly EntitySelectorFilter[];
|
||||
device?: DeviceSelectorFilter | readonly DeviceSelectorFilter[];
|
||||
create_domains?: string[];
|
||||
} | null;
|
||||
}
|
||||
|
||||
@@ -822,3 +822,34 @@ export const handleLegacyDeviceSelector = (
|
||||
device: rest,
|
||||
};
|
||||
};
|
||||
|
||||
export const computeCreateDomains = (
|
||||
selector: EntitySelector | TargetSelector
|
||||
): undefined | string[] => {
|
||||
let entityFilters: EntitySelectorFilter[] | undefined;
|
||||
|
||||
if ("target" in selector) {
|
||||
entityFilters = ensureArray(selector.target?.entity);
|
||||
} else if ("entity" in selector) {
|
||||
if (selector.entity?.include_entities) {
|
||||
return undefined;
|
||||
}
|
||||
entityFilters = ensureArray(selector.entity?.filter);
|
||||
}
|
||||
if (!entityFilters) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const createDomains = entityFilters.flatMap((entityFilter) =>
|
||||
!entityFilter.integration &&
|
||||
!entityFilter.device_class &&
|
||||
!entityFilter.supported_features &&
|
||||
entityFilter.domain
|
||||
? ensureArray(entityFilter.domain).filter((domain) =>
|
||||
isHelperDomain(domain)
|
||||
)
|
||||
: []
|
||||
);
|
||||
|
||||
return [...new Set(createDomains)];
|
||||
};
|
||||
|
@@ -18,7 +18,9 @@ export type SensorNumericDeviceClasses = {
|
||||
numeric_device_classes: string[];
|
||||
};
|
||||
|
||||
let sensorNumericDeviceClassesCache: SensorNumericDeviceClasses | undefined;
|
||||
let sensorNumericDeviceClassesCache:
|
||||
| Promise<SensorNumericDeviceClasses>
|
||||
| undefined;
|
||||
|
||||
export const getSensorNumericDeviceClasses = async (
|
||||
hass: HomeAssistant
|
||||
@@ -26,7 +28,7 @@ export const getSensorNumericDeviceClasses = async (
|
||||
if (sensorNumericDeviceClassesCache) {
|
||||
return sensorNumericDeviceClassesCache;
|
||||
}
|
||||
sensorNumericDeviceClassesCache = await hass.callWS({
|
||||
sensorNumericDeviceClassesCache = hass.callWS({
|
||||
type: "sensor/numeric_device_classes",
|
||||
});
|
||||
return sensorNumericDeviceClassesCache!;
|
||||
|
@@ -118,6 +118,10 @@ export const checkForEntityUpdates = async (
|
||||
return;
|
||||
}
|
||||
|
||||
showToast(element, {
|
||||
message: hass.localize("ui.panel.config.updates.checking_updates"),
|
||||
});
|
||||
|
||||
let updated = 0;
|
||||
|
||||
const unsubscribeEvents = await hass.connection.subscribeEvents<HassEvent>(
|
||||
@@ -154,7 +158,7 @@ export const checkForEntityUpdates = async (
|
||||
|
||||
// When updating, and entity does not support % show "Installing"
|
||||
// When updating, and entity does support % show "Installing (xx%)"
|
||||
// When update available, show the version
|
||||
// When update available, show "Update available"
|
||||
// When the latest version is skipped, show the latest version
|
||||
// When update is not available, show "Up-to-date"
|
||||
// When update is not available and there is no latest_version show "Unavailable"
|
||||
@@ -187,10 +191,6 @@ export const computeUpdateStateDisplay = (
|
||||
}
|
||||
return hass.localize("ui.card.update.installing");
|
||||
}
|
||||
|
||||
if (attributes.latest_version) {
|
||||
return attributes.latest_version;
|
||||
}
|
||||
}
|
||||
|
||||
return hass.formatEntityState(stateObj);
|
||||
|
@@ -13,7 +13,7 @@ import {
|
||||
LockEntity,
|
||||
LockEntityFeature,
|
||||
callProtectedLockService,
|
||||
isAvailable,
|
||||
canOpen,
|
||||
isJammed,
|
||||
} from "../../../data/lock";
|
||||
import "../../../state-control/lock/ha-state-control-lock-toggle";
|
||||
@@ -22,9 +22,9 @@ import "../components/ha-more-info-state-header";
|
||||
import { moreInfoControlStyle } from "../components/more-info-control-style";
|
||||
|
||||
const CONFIRM_TIMEOUT_SECOND = 5;
|
||||
const OPENED_TIMEOUT_SECOND = 3;
|
||||
const DONE_TIMEOUT_SECOND = 2;
|
||||
|
||||
type ButtonState = "normal" | "confirm" | "success";
|
||||
type ButtonState = "normal" | "confirm" | "done";
|
||||
|
||||
@customElement("more-info-lock")
|
||||
class MoreInfoLock extends LitElement {
|
||||
@@ -54,7 +54,7 @@ class MoreInfoLock extends LitElement {
|
||||
|
||||
callProtectedLockService(this, this.hass, this.stateObj!, "open");
|
||||
|
||||
this._setButtonState("success", OPENED_TIMEOUT_SECOND);
|
||||
this._setButtonState("done", DONE_TIMEOUT_SECOND);
|
||||
}
|
||||
|
||||
private _resetButtonState() {
|
||||
@@ -115,16 +115,16 @@ class MoreInfoLock extends LitElement {
|
||||
${supportsOpen
|
||||
? html`
|
||||
<div class="buttons">
|
||||
${this._buttonState === "success"
|
||||
${this._buttonState === "done"
|
||||
? html`
|
||||
<p class="open-success">
|
||||
<p class="open-done">
|
||||
<ha-svg-icon path=${mdiCheck}></ha-svg-icon>
|
||||
${this.hass.localize("ui.card.lock.open_door_success")}
|
||||
${this.hass.localize("ui.card.lock.open_door_done")}
|
||||
</p>
|
||||
`
|
||||
: html`
|
||||
<ha-control-button
|
||||
.disabled=${!isAvailable(this.stateObj)}
|
||||
.disabled=${!canOpen(this.stateObj)}
|
||||
class="open-button ${this._buttonState}"
|
||||
@click=${this._open}
|
||||
>
|
||||
@@ -175,7 +175,7 @@ class MoreInfoLock extends LitElement {
|
||||
.open-button.confirm {
|
||||
--control-button-background-color: var(--warning-color);
|
||||
}
|
||||
.open-success {
|
||||
.open-done {
|
||||
line-height: 60px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
@@ -129,6 +129,15 @@ interface EMOutgoingMessageAssistShow extends EMMessage {
|
||||
};
|
||||
}
|
||||
|
||||
interface EMOutgoingMessageThreadStoreInPlatformKeychain extends EMMessage {
|
||||
type: "thread/store_in_platform_keychain";
|
||||
payload: {
|
||||
mac_extended_address: string;
|
||||
border_agent_id: string | null;
|
||||
active_operational_dataset: string;
|
||||
};
|
||||
}
|
||||
|
||||
type EMOutgoingMessageWithoutAnswer =
|
||||
| EMMessageResultError
|
||||
| EMMessageResultSuccess
|
||||
@@ -146,7 +155,8 @@ type EMOutgoingMessageWithoutAnswer =
|
||||
| EMOutgoingMessageMatterCommission
|
||||
| EMOutgoingMessageSidebarShow
|
||||
| EMOutgoingMessageTagWrite
|
||||
| EMOutgoingMessageThemeUpdate;
|
||||
| EMOutgoingMessageThemeUpdate
|
||||
| EMOutgoingMessageThreadStoreInPlatformKeychain;
|
||||
|
||||
interface EMIncomingMessageRestart {
|
||||
id: number;
|
||||
@@ -239,6 +249,7 @@ export interface ExternalConfig {
|
||||
hasExoPlayer: boolean;
|
||||
canCommissionMatter: boolean;
|
||||
canImportThreadCredentials: boolean;
|
||||
canTransferThreadCredentialsToKeychain: boolean;
|
||||
hasAssist: boolean;
|
||||
hasBarCodeScanner: number;
|
||||
}
|
||||
|
@@ -231,6 +231,8 @@ export const ENTITY_COMPONENT_ICONS: Record<string, ComponentIcons> = {
|
||||
locking: "mdi:lock-clock",
|
||||
unlocked: "mdi:lock-open",
|
||||
unlocking: "mdi:lock-clock",
|
||||
opening: "mdi:lock-clock",
|
||||
open: "mdi:lock-open-variant",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -119,7 +119,8 @@ export const provideHass = (
|
||||
hass().localize,
|
||||
hass().locale,
|
||||
hass().config,
|
||||
hass().entities
|
||||
hass().entities,
|
||||
[] // numericDeviceClasses
|
||||
);
|
||||
hass().updateHass({
|
||||
formatEntityState,
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import "@material/mwc-ripple";
|
||||
import {
|
||||
css,
|
||||
CSSResultGroup,
|
||||
|
@@ -48,7 +48,7 @@ class DialogCommunity extends LitElement {
|
||||
<a
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
href="https://www.home-assistant.io/newsletter/"
|
||||
href="https://newsletter.openhomefoundation.org/"
|
||||
>
|
||||
<ha-list-item hasMeta graphic="icon">
|
||||
<img src="/static/icons/favicon-192x192.png" slot="graphic" />
|
||||
|
@@ -1,15 +1,7 @@
|
||||
import "@material/mwc-ripple";
|
||||
import type { Ripple } from "@material/mwc-ripple";
|
||||
import { RippleHandlers } from "@material/mwc-ripple/ripple-handlers";
|
||||
import { CSSResultGroup, LitElement, TemplateResult, css, html } from "lit";
|
||||
import {
|
||||
customElement,
|
||||
eventOptions,
|
||||
property,
|
||||
queryAsync,
|
||||
state,
|
||||
} from "lit/decorators";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import "../components/ha-card";
|
||||
import "../components/ha-ripple";
|
||||
import "../components/ha-svg-icon";
|
||||
|
||||
@customElement("onboarding-welcome-link")
|
||||
@@ -20,28 +12,15 @@ class OnboardingWelcomeLink extends LitElement {
|
||||
|
||||
@property({ type: Boolean }) public noninteractive = false;
|
||||
|
||||
@queryAsync("mwc-ripple") private _ripple!: Promise<Ripple | null>;
|
||||
|
||||
@state() private _shouldRenderRipple = false;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<ha-card
|
||||
.tabIndex=${this.noninteractive ? "-1" : "0"}
|
||||
@focus=${this.handleRippleFocus}
|
||||
@blur=${this.handleRippleBlur}
|
||||
@mousedown=${this.handleRippleActivate}
|
||||
@mouseup=${this.handleRippleDeactivate}
|
||||
@mouseenter=${this.handleRippleMouseEnter}
|
||||
@mouseleave=${this.handleRippleMouseLeave}
|
||||
@touchstart=${this.handleRippleActivate}
|
||||
@touchend=${this.handleRippleDeactivate}
|
||||
@touchcancel=${this.handleRippleDeactivate}
|
||||
@keydown=${this._handleKeyDown}
|
||||
>
|
||||
<ha-svg-icon .path=${this.iconPath}></ha-svg-icon>
|
||||
${this.label}
|
||||
${this._shouldRenderRipple ? html`<mwc-ripple></mwc-ripple>` : ""}
|
||||
<ha-ripple></ha-ripple>
|
||||
</ha-card>
|
||||
`;
|
||||
}
|
||||
@@ -52,36 +31,6 @@ class OnboardingWelcomeLink extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private _rippleHandlers: RippleHandlers = new RippleHandlers(() => {
|
||||
this._shouldRenderRipple = true;
|
||||
return this._ripple;
|
||||
});
|
||||
|
||||
private handleRippleMouseEnter() {
|
||||
this._rippleHandlers.startHover();
|
||||
}
|
||||
|
||||
private handleRippleMouseLeave() {
|
||||
this._rippleHandlers.endHover();
|
||||
}
|
||||
|
||||
@eventOptions({ passive: true })
|
||||
private handleRippleActivate(evt?: Event) {
|
||||
this._rippleHandlers.startPress(evt);
|
||||
}
|
||||
|
||||
private handleRippleDeactivate() {
|
||||
this._rippleHandlers.endPress();
|
||||
}
|
||||
|
||||
private handleRippleFocus() {
|
||||
this._rippleHandlers.startFocus();
|
||||
}
|
||||
|
||||
private handleRippleBlur() {
|
||||
this._rippleHandlers.endFocus();
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return css`
|
||||
:host {
|
||||
@@ -104,6 +53,14 @@ class OnboardingWelcomeLink extends LitElement {
|
||||
padding: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
ha-card:focus-visible:before {
|
||||
position: absolute;
|
||||
display: block;
|
||||
content: "";
|
||||
inset: 0;
|
||||
background-color: var(--secondary-text-color);
|
||||
opacity: 0.08;
|
||||
}
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
@@ -72,6 +72,7 @@ import "./types/ha-automation-action-delay";
|
||||
import "./types/ha-automation-action-device_id";
|
||||
import "./types/ha-automation-action-event";
|
||||
import "./types/ha-automation-action-if";
|
||||
import "./types/ha-automation-action-sequence";
|
||||
import "./types/ha-automation-action-parallel";
|
||||
import "./types/ha-automation-action-play_media";
|
||||
import "./types/ha-automation-action-repeat";
|
||||
|
@@ -0,0 +1,67 @@
|
||||
import { CSSResultGroup, html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
import "../../../../../components/ha-textfield";
|
||||
import { Action, SequenceAction } from "../../../../../data/script";
|
||||
import { haStyle } from "../../../../../resources/styles";
|
||||
import type { HomeAssistant, ItemPath } from "../../../../../types";
|
||||
import "../ha-automation-action";
|
||||
import type { ActionElement } from "../ha-automation-action-row";
|
||||
|
||||
@customElement("ha-automation-action-sequence")
|
||||
export class HaSequenceAction extends LitElement implements ActionElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
@property({ attribute: false }) public path?: ItemPath;
|
||||
|
||||
@property({ attribute: false }) public action!: SequenceAction;
|
||||
|
||||
public static get defaultConfig() {
|
||||
return {
|
||||
sequence: [],
|
||||
};
|
||||
}
|
||||
|
||||
private _getMemoizedPath = memoizeOne((path: ItemPath | undefined) => [
|
||||
...(path ?? []),
|
||||
"sequence",
|
||||
]);
|
||||
|
||||
protected render() {
|
||||
const { action } = this;
|
||||
|
||||
return html`
|
||||
<ha-automation-action
|
||||
.path=${this._getMemoizedPath(this.path)}
|
||||
.actions=${action.sequence}
|
||||
.disabled=${this.disabled}
|
||||
@value-changed=${this._actionsChanged}
|
||||
.hass=${this.hass}
|
||||
></ha-automation-action>
|
||||
`;
|
||||
}
|
||||
|
||||
private _actionsChanged(ev: CustomEvent) {
|
||||
ev.stopPropagation();
|
||||
const value = ev.detail.value as Action[];
|
||||
fireEvent(this, "value-changed", {
|
||||
value: {
|
||||
...this.action,
|
||||
sequence: value,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return haStyle;
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"ha-automation-action-sequence": HaSequenceAction;
|
||||
}
|
||||
}
|
@@ -138,7 +138,7 @@ class DialogAutomationMode extends LitElement implements HassDialog {
|
||||
}
|
||||
|
||||
private _save(): void {
|
||||
this._params.updateAutomation({
|
||||
this._params.updateConfig({
|
||||
...this._params.config,
|
||||
mode: this._newMode,
|
||||
max: this._newMax,
|
||||
|
@@ -1,18 +1,25 @@
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import type { AutomationConfig } from "../../../../data/automation";
|
||||
import type { ScriptConfig } from "../../../../data/script";
|
||||
|
||||
export const loadAutomationModeDialog = () =>
|
||||
import("./dialog-automation-mode");
|
||||
|
||||
export interface AutomationModeDialog {
|
||||
config: AutomationConfig;
|
||||
updateAutomation: (config: AutomationConfig) => void;
|
||||
updateConfig: (config: AutomationConfig) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export interface ScriptModeDialog {
|
||||
config: ScriptConfig;
|
||||
updateConfig: (config: ScriptConfig) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const showAutomationModeDialog = (
|
||||
element: HTMLElement,
|
||||
dialogParams: AutomationModeDialog
|
||||
dialogParams: AutomationModeDialog | ScriptModeDialog
|
||||
): void => {
|
||||
fireEvent(element, "show-dialog", {
|
||||
dialogTag: "ha-dialog-automation-mode",
|
||||
|
@@ -124,7 +124,7 @@ class DialogAutomationRename extends LitElement implements HassDialog {
|
||||
this._error = "Name is required";
|
||||
return;
|
||||
}
|
||||
this._params.updateAutomation({
|
||||
this._params.updateConfig({
|
||||
...this._params.config,
|
||||
alias: this._newName,
|
||||
description: this._newDescription,
|
||||
|
@@ -1,18 +1,25 @@
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import type { AutomationConfig } from "../../../../data/automation";
|
||||
import type { ScriptConfig } from "../../../../data/script";
|
||||
|
||||
export const loadAutomationRenameDialog = () =>
|
||||
import("./dialog-automation-rename");
|
||||
|
||||
export interface AutomationRenameDialog {
|
||||
config: AutomationConfig;
|
||||
updateAutomation: (config: AutomationConfig) => void;
|
||||
updateConfig: (config: AutomationConfig) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export interface ScriptRenameDialog {
|
||||
config: ScriptConfig;
|
||||
updateConfig: (config: ScriptConfig) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const showAutomationRenameDialog = (
|
||||
element: HTMLElement,
|
||||
dialogParams: AutomationRenameDialog
|
||||
dialogParams: AutomationRenameDialog | ScriptRenameDialog
|
||||
): void => {
|
||||
fireEvent(element, "show-dialog", {
|
||||
dialogTag: "ha-dialog-automation-rename",
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { html } from "lit";
|
||||
import { html, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import "../../../components/ha-alert";
|
||||
import { BlueprintAutomationConfig } from "../../../data/automation";
|
||||
import { fetchBlueprints } from "../../../data/blueprint";
|
||||
import { HaBlueprintGenericEditor } from "../blueprint/blueprint-generic-editor";
|
||||
import "../../../components/ha-markdown";
|
||||
|
||||
@customElement("blueprint-automation-editor")
|
||||
export class HaBlueprintAutomationEditor extends HaBlueprintGenericEditor {
|
||||
@@ -26,7 +27,7 @@ export class HaBlueprintAutomationEditor extends HaBlueprintGenericEditor {
|
||||
${this.hass.localize("ui.panel.config.automation.editor.migrate")}
|
||||
</mwc-button>
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
: nothing}
|
||||
${this.stateObj?.state === "off"
|
||||
? html`
|
||||
<ha-alert alert-type="info">
|
||||
@@ -42,8 +43,12 @@ export class HaBlueprintAutomationEditor extends HaBlueprintGenericEditor {
|
||||
`
|
||||
: ""}
|
||||
${this.config.description
|
||||
? html`<p class="description">${this.config.description}</p>`
|
||||
: ""}
|
||||
? html`<ha-markdown
|
||||
class="description"
|
||||
breaks
|
||||
.content=${this.config.description}
|
||||
></ha-markdown>`
|
||||
: nothing}
|
||||
${this.renderCard()}
|
||||
`;
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ import { property, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import { navigate } from "../../../common/navigate";
|
||||
import { computeRTL } from "../../../common/util/compute_rtl";
|
||||
import { afterNextRender } from "../../../common/util/render-status";
|
||||
import "../../../components/ha-button-menu";
|
||||
import "../../../components/ha-fab";
|
||||
@@ -117,22 +118,24 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
|
||||
private _configSubscriptionsId = 1;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
protected render(): TemplateResult | typeof nothing {
|
||||
if (!this._config) {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
const stateObj = this._entityId
|
||||
? this.hass.states[this._entityId]
|
||||
: undefined;
|
||||
|
||||
const useBlueprint = "use_blueprint" in this._config;
|
||||
return html`
|
||||
<hass-subpage
|
||||
.hass=${this.hass}
|
||||
.narrow=${this.narrow}
|
||||
.route=${this.route}
|
||||
.backCallback=${this._backTapped}
|
||||
.header=${!this._config
|
||||
? ""
|
||||
: this._config.alias ||
|
||||
this.hass.localize(
|
||||
"ui.panel.config.automation.editor.default_name"
|
||||
)}
|
||||
.header=${this._config.alias ||
|
||||
this.hass.localize("ui.panel.config.automation.editor.default_name")}
|
||||
>
|
||||
${this._config?.id && !this.narrow
|
||||
? html`
|
||||
@@ -171,7 +174,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
<ha-svg-icon slot="graphic" .path=${mdiPlay}></ha-svg-icon>
|
||||
</ha-list-item>
|
||||
|
||||
${stateObj && this._config && this.narrow
|
||||
${stateObj && this.narrow
|
||||
? html`<a
|
||||
href="/config/automation/trace/${encodeURIComponent(
|
||||
this._config.id!
|
||||
@@ -187,7 +190,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
></ha-svg-icon>
|
||||
</ha-list-item>
|
||||
</a>`
|
||||
: ""}
|
||||
: nothing}
|
||||
|
||||
<ha-list-item
|
||||
graphic="icon"
|
||||
@@ -197,8 +200,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
${this.hass.localize("ui.panel.config.automation.editor.rename")}
|
||||
<ha-svg-icon slot="graphic" .path=${mdiRenameBox}></ha-svg-icon>
|
||||
</ha-list-item>
|
||||
|
||||
${this._config && !("use_blueprint" in this._config)
|
||||
${!useBlueprint
|
||||
? html`
|
||||
<ha-list-item
|
||||
graphic="icon"
|
||||
@@ -214,7 +216,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
></ha-svg-icon>
|
||||
</ha-list-item>
|
||||
`
|
||||
: ""}
|
||||
: nothing}
|
||||
|
||||
<ha-list-item
|
||||
.disabled=${!this._readOnly && !this.automationId}
|
||||
@@ -288,35 +290,38 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
</ha-svg-icon>
|
||||
</ha-list-item>
|
||||
</ha-button-menu>
|
||||
|
||||
${this._config
|
||||
? html`
|
||||
<div
|
||||
class="content ${classMap({
|
||||
"yaml-mode": this._mode === "yaml",
|
||||
})}"
|
||||
@subscribe-automation-config=${this._subscribeAutomationConfig}
|
||||
<div
|
||||
class="content ${classMap({
|
||||
"yaml-mode": this._mode === "yaml",
|
||||
})}"
|
||||
@subscribe-automation-config=${this._subscribeAutomationConfig}
|
||||
>
|
||||
${this._errors || stateObj?.state === UNAVAILABLE
|
||||
? html`<ha-alert
|
||||
alert-type="error"
|
||||
.title=${stateObj?.state === UNAVAILABLE
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.automation.editor.unavailable"
|
||||
)
|
||||
: undefined}
|
||||
>
|
||||
${this._errors || stateObj?.state === UNAVAILABLE
|
||||
? html`<ha-alert
|
||||
alert-type="error"
|
||||
.title=${stateObj?.state === UNAVAILABLE
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.automation.editor.unavailable"
|
||||
)
|
||||
: undefined}
|
||||
>
|
||||
${this._errors || this._validationErrors}
|
||||
${stateObj?.state === UNAVAILABLE
|
||||
? html`<ha-svg-icon
|
||||
slot="icon"
|
||||
.path=${mdiRobotConfused}
|
||||
></ha-svg-icon>`
|
||||
: nothing}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
${this._mode === "gui"
|
||||
? "use_blueprint" in this._config
|
||||
${this._errors || this._validationErrors}
|
||||
${stateObj?.state === UNAVAILABLE
|
||||
? html`<ha-svg-icon
|
||||
slot="icon"
|
||||
.path=${mdiRobotConfused}
|
||||
></ha-svg-icon>`
|
||||
: nothing}
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
${this._mode === "gui"
|
||||
? html`
|
||||
<div
|
||||
class=${classMap({
|
||||
rtl: computeRTL(this.hass),
|
||||
})}
|
||||
>
|
||||
${useBlueprint
|
||||
? html`
|
||||
<blueprint-automation-editor
|
||||
.hass=${this.hass}
|
||||
@@ -340,51 +345,45 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
@value-changed=${this._valueChanged}
|
||||
@duplicate=${this._duplicate}
|
||||
></manual-automation-editor>
|
||||
`
|
||||
: this._mode === "yaml"
|
||||
? html` ${this._readOnly
|
||||
? html`<ha-alert alert-type="warning">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.read_only"
|
||||
)}
|
||||
<mwc-button
|
||||
slot="action"
|
||||
@click=${this._duplicate}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.migrate"
|
||||
)}
|
||||
</mwc-button>
|
||||
</ha-alert>`
|
||||
: ""}
|
||||
${stateObj?.state === "off"
|
||||
? html`
|
||||
<ha-alert alert-type="info">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.disabled"
|
||||
)}
|
||||
<mwc-button
|
||||
slot="action"
|
||||
@click=${this._toggle}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.enable"
|
||||
)}
|
||||
</mwc-button>
|
||||
</ha-alert>
|
||||
`
|
||||
: ""}
|
||||
<ha-yaml-editor
|
||||
copyClipboard
|
||||
.hass=${this.hass}
|
||||
.defaultValue=${this._preprocessYaml()}
|
||||
.readOnly=${this._readOnly}
|
||||
@value-changed=${this._yamlChanged}
|
||||
></ha-yaml-editor>`
|
||||
`}
|
||||
</div>
|
||||
`
|
||||
: this._mode === "yaml"
|
||||
? html` ${this._readOnly
|
||||
? html`<ha-alert alert-type="warning">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.read_only"
|
||||
)}
|
||||
<mwc-button slot="action" @click=${this._duplicate}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.migrate"
|
||||
)}
|
||||
</mwc-button>
|
||||
</ha-alert>`
|
||||
: nothing}
|
||||
</div>
|
||||
`
|
||||
: ""}
|
||||
${stateObj?.state === "off"
|
||||
? html`
|
||||
<ha-alert alert-type="info">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.disabled"
|
||||
)}
|
||||
<mwc-button slot="action" @click=${this._toggle}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.editor.enable"
|
||||
)}
|
||||
</mwc-button>
|
||||
</ha-alert>
|
||||
`
|
||||
: ""}
|
||||
<ha-yaml-editor
|
||||
copyClipboard
|
||||
.hass=${this.hass}
|
||||
.defaultValue=${this._preprocessYaml()}
|
||||
.readOnly=${this._readOnly}
|
||||
@value-changed=${this._yamlChanged}
|
||||
></ha-yaml-editor>`
|
||||
: nothing}
|
||||
</div>
|
||||
<ha-fab
|
||||
slot="fab"
|
||||
class=${classMap({ dirty: this._dirty })}
|
||||
@@ -689,7 +688,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
return new Promise((resolve) => {
|
||||
showAutomationRenameDialog(this, {
|
||||
config: this._config!,
|
||||
updateAutomation: (config) => {
|
||||
updateConfig: (config) => {
|
||||
this._config = config;
|
||||
this._dirty = true;
|
||||
this.requestUpdate();
|
||||
@@ -704,7 +703,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
return new Promise((resolve) => {
|
||||
showAutomationModeDialog(this, {
|
||||
config: this._config!,
|
||||
updateAutomation: (config) => {
|
||||
updateConfig: (config) => {
|
||||
this._config = config;
|
||||
this._dirty = true;
|
||||
this.requestUpdate();
|
||||
|
@@ -59,14 +59,14 @@ export class HaManualAutomationEditor extends LitElement {
|
||||
</mwc-button>
|
||||
</ha-alert>
|
||||
`
|
||||
: ""}
|
||||
: nothing}
|
||||
${this.config.description
|
||||
? html`<ha-markdown
|
||||
class="description"
|
||||
breaks
|
||||
.content=${this.config.description}
|
||||
></ha-markdown>`
|
||||
: ""}
|
||||
: nothing}
|
||||
<div class="header">
|
||||
<h2 id="triggers-heading" class="name">
|
||||
${this.hass.localize(
|
||||
|
@@ -3,6 +3,7 @@ import { css, html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
import { deepEqual } from "../../../../../common/util/deep-equal";
|
||||
import "../../../../../components/device/ha-device-picker";
|
||||
import "../../../../../components/device/ha-device-trigger-picker";
|
||||
import "../../../../../components/ha-form/ha-form";
|
||||
@@ -125,6 +126,20 @@ export class HaDeviceTrigger extends LitElement {
|
||||
this._capabilities = trigger.domain
|
||||
? await fetchDeviceTriggerCapabilities(this.hass, trigger)
|
||||
: undefined;
|
||||
|
||||
if (this._capabilities) {
|
||||
// Match yaml to what is displayed in the form from computeInitialHaFormData
|
||||
const newTrigger = {
|
||||
...this.trigger,
|
||||
...this._extraFieldsData(this.trigger, this._capabilities),
|
||||
};
|
||||
|
||||
if (!deepEqual(this.trigger, newTrigger)) {
|
||||
fireEvent(this, "value-changed", {
|
||||
value: newTrigger,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _devicePicked(ev) {
|
||||
|
@@ -7,6 +7,7 @@ import "../../../../components/ha-alert";
|
||||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-card";
|
||||
import "../../../../components/ha-expansion-panel";
|
||||
import "../../../../components/ha-formfield";
|
||||
import "../../../../components/ha-radio";
|
||||
import "../../../../components/ha-settings-row";
|
||||
import "../../../../components/ha-switch";
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { RequestSelectedDetail } from "@material/mwc-list/mwc-list-item";
|
||||
import { mdiDotsVertical, mdiUpdate } from "@mdi/js";
|
||||
import { mdiDotsVertical, mdiRefresh } from "@mdi/js";
|
||||
import { HassEntities } from "home-assistant-js-websocket";
|
||||
import { css, html, LitElement, TemplateResult } from "lit";
|
||||
import { LitElement, TemplateResult, css, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||
@@ -14,11 +14,11 @@ import "../../../components/ha-check-list-item";
|
||||
import "../../../components/ha-metric";
|
||||
import { extractApiErrorMessage } from "../../../data/hassio/common";
|
||||
import {
|
||||
fetchHassioSupervisorInfo,
|
||||
HassioSupervisorInfo,
|
||||
SupervisorOptions,
|
||||
fetchHassioSupervisorInfo,
|
||||
reloadSupervisor,
|
||||
setSupervisorOption,
|
||||
SupervisorOptions,
|
||||
} from "../../../data/hassio/supervisor";
|
||||
import {
|
||||
checkForEntityUpdates,
|
||||
@@ -66,7 +66,7 @@ class HaConfigSectionUpdates extends LitElement {
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.config.updates.check_updates"
|
||||
)}
|
||||
.path=${mdiUpdate}
|
||||
.path=${mdiRefresh}
|
||||
@click=${this._checkUpdates}
|
||||
></ha-icon-button>
|
||||
<ha-button-menu multi>
|
||||
|
@@ -4,7 +4,7 @@ import {
|
||||
mdiDotsVertical,
|
||||
mdiMagnify,
|
||||
mdiPower,
|
||||
mdiUpdate,
|
||||
mdiRefresh,
|
||||
} from "@mdi/js";
|
||||
import { HassEntities, UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import {
|
||||
@@ -83,7 +83,7 @@ const randomTip = (hass: HomeAssistant, narrow: boolean) => {
|
||||
>`,
|
||||
newsletter: html`<span class="keep-together"
|
||||
><a
|
||||
href=${documentationUrl(hass, `/newsletter`)}
|
||||
href="https://newsletter.openhomefoundation.org/"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>Newsletter</a
|
||||
@@ -206,7 +206,7 @@ class HaConfigDashboard extends SubscribeMixin(LitElement) {
|
||||
|
||||
<ha-list-item graphic="icon">
|
||||
${this.hass.localize("ui.panel.config.updates.check_updates")}
|
||||
<ha-svg-icon slot="graphic" .path=${mdiUpdate}></ha-svg-icon>
|
||||
<ha-svg-icon slot="graphic" .path=${mdiRefresh}></ha-svg-icon>
|
||||
</ha-list-item>
|
||||
|
||||
<ha-list-item graphic="icon">
|
||||
|
@@ -22,6 +22,7 @@ import {
|
||||
EnergyPreferencesValidation,
|
||||
energySourcesByType,
|
||||
EnergyValidationIssue,
|
||||
EnergySource,
|
||||
FlowFromGridSourceEnergyPreference,
|
||||
FlowToGridSourceEnergyPreference,
|
||||
GridSourceTypeEnergyPreference,
|
||||
@@ -449,11 +450,8 @@ export class EnergyGridSettings extends LitElement {
|
||||
),
|
||||
};
|
||||
|
||||
try {
|
||||
await this._savePreferences(preferences);
|
||||
} catch (err: any) {
|
||||
showAlertDialog(this, { title: `Failed to save config: ${err.message}` });
|
||||
}
|
||||
const cleanedPreferences = this._removeEmptySources(preferences);
|
||||
await this._savePreferences(cleanedPreferences);
|
||||
}
|
||||
|
||||
private async _deleteToSource(ev) {
|
||||
@@ -479,16 +477,35 @@ export class EnergyGridSettings extends LitElement {
|
||||
),
|
||||
};
|
||||
|
||||
try {
|
||||
await this._savePreferences(preferences);
|
||||
} catch (err: any) {
|
||||
showAlertDialog(this, { title: `Failed to save config: ${err.message}` });
|
||||
}
|
||||
const cleanedPreferences = this._removeEmptySources(preferences);
|
||||
await this._savePreferences(cleanedPreferences);
|
||||
}
|
||||
|
||||
private _removeEmptySources(preferences: EnergyPreferences) {
|
||||
// Check if grid sources became an empty type and remove if so
|
||||
preferences.energy_sources = preferences.energy_sources.reduce<
|
||||
EnergySource[]
|
||||
>((acc, source) => {
|
||||
if (
|
||||
source.type !== "grid" ||
|
||||
source.flow_from.length > 0 ||
|
||||
source.flow_to.length > 0
|
||||
) {
|
||||
acc.push(source);
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
return preferences;
|
||||
}
|
||||
|
||||
private async _savePreferences(preferences: EnergyPreferences) {
|
||||
const result = await saveEnergyPreferences(this.hass, preferences);
|
||||
fireEvent(this, "value-changed", { value: result });
|
||||
try {
|
||||
const result = await saveEnergyPreferences(this.hass, preferences);
|
||||
fireEvent(this, "value-changed", { value: result });
|
||||
} catch (err: any) {
|
||||
showAlertDialog(this, { title: `Failed to save config: ${err.message}` });
|
||||
}
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
|
@@ -105,7 +105,7 @@ export class DialogEnergyDeviceSettings
|
||||
type="text"
|
||||
.disabled=${!this._device}
|
||||
.value=${this._device?.name || ""}
|
||||
@change=${this._nameChanged}
|
||||
@input=${this._nameChanged}
|
||||
>
|
||||
</ha-textfield>
|
||||
|
||||
|
@@ -116,6 +116,9 @@ export interface EntityRow extends StateEntity {
|
||||
localized_platform: string;
|
||||
domain: string;
|
||||
label_entries: LabelRegistryEntry[];
|
||||
enabled: string;
|
||||
visible: string;
|
||||
available: string;
|
||||
}
|
||||
|
||||
@customElement("ha-config-entities")
|
||||
@@ -198,20 +201,36 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
||||
|
||||
private _states = memoize((localize: LocalizeFunc) => [
|
||||
{
|
||||
value: "disabled",
|
||||
label: localize("ui.panel.config.entities.picker.status.disabled"),
|
||||
},
|
||||
{
|
||||
value: "hidden",
|
||||
label: localize("ui.panel.config.entities.picker.status.hidden"),
|
||||
value: "available",
|
||||
label: localize("ui.panel.config.entities.picker.status.available"),
|
||||
},
|
||||
{
|
||||
value: "unavailable",
|
||||
label: localize("ui.panel.config.entities.picker.status.unavailable"),
|
||||
},
|
||||
{
|
||||
value: "enabled",
|
||||
label: localize("ui.panel.config.entities.picker.status.enabled"),
|
||||
},
|
||||
{
|
||||
value: "disabled",
|
||||
label: localize("ui.panel.config.entities.picker.status.disabled"),
|
||||
},
|
||||
{
|
||||
value: "visible",
|
||||
label: localize("ui.panel.config.entities.picker.status.visible"),
|
||||
},
|
||||
{
|
||||
value: "hidden",
|
||||
label: localize("ui.panel.config.entities.picker.status.hidden"),
|
||||
},
|
||||
{
|
||||
value: "readonly",
|
||||
label: localize("ui.panel.config.entities.picker.status.readonly"),
|
||||
label: localize("ui.panel.config.entities.picker.status.unmanageable"),
|
||||
},
|
||||
{
|
||||
value: "restored",
|
||||
label: localize("ui.panel.config.entities.picker.status.not_provided"),
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -310,7 +329,6 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
||||
type: "icon",
|
||||
sortable: true,
|
||||
filterable: true,
|
||||
groupable: true,
|
||||
width: "68px",
|
||||
template: (entry) =>
|
||||
entry.unavailable ||
|
||||
@@ -339,7 +357,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
||||
<simple-tooltip animation-delay="0" position="left">
|
||||
${entry.restored
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.entities.picker.status.restored"
|
||||
"ui.panel.config.entities.picker.status.not_provided"
|
||||
)
|
||||
: entry.unavailable
|
||||
? this.hass.localize(
|
||||
@@ -354,13 +372,31 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
||||
"ui.panel.config.entities.picker.status.hidden"
|
||||
)
|
||||
: this.hass.localize(
|
||||
"ui.panel.config.entities.picker.status.readonly"
|
||||
"ui.panel.config.entities.picker.status.unmanageable"
|
||||
)}
|
||||
</simple-tooltip>
|
||||
</div>
|
||||
`
|
||||
: "—",
|
||||
},
|
||||
available: {
|
||||
title: localize("ui.panel.config.entities.picker.headers.availability"),
|
||||
sortable: true,
|
||||
groupable: true,
|
||||
hidden: true,
|
||||
},
|
||||
visible: {
|
||||
title: localize("ui.panel.config.entities.picker.headers.visibility"),
|
||||
sortable: true,
|
||||
groupable: true,
|
||||
hidden: true,
|
||||
},
|
||||
enabled: {
|
||||
title: localize("ui.panel.config.entities.picker.headers.enabled"),
|
||||
sortable: true,
|
||||
groupable: true,
|
||||
hidden: true,
|
||||
},
|
||||
labels: {
|
||||
title: "",
|
||||
hidden: true,
|
||||
@@ -389,18 +425,24 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
||||
|
||||
const stateFilters = filters["ha-filter-states"]?.value;
|
||||
|
||||
const showReadOnly =
|
||||
!stateFilters?.length || stateFilters.includes("readonly");
|
||||
const showEnabled =
|
||||
!stateFilters?.length || stateFilters.includes("enabled");
|
||||
const showDisabled =
|
||||
!stateFilters?.length || stateFilters.includes("disabled");
|
||||
const showVisible =
|
||||
!stateFilters?.length || stateFilters.includes("visible");
|
||||
const showHidden =
|
||||
!stateFilters?.length || stateFilters.includes("hidden");
|
||||
const showAvailable =
|
||||
!stateFilters?.length || stateFilters.includes("available");
|
||||
const showUnavailable =
|
||||
!stateFilters?.length || stateFilters.includes("unavailable");
|
||||
const showRestored =
|
||||
!stateFilters?.length || stateFilters.includes("restored");
|
||||
const showReadOnly =
|
||||
!stateFilters?.length || stateFilters.includes("readonly");
|
||||
|
||||
let filteredEntities = showReadOnly
|
||||
? entities.concat(stateEntities)
|
||||
: entities;
|
||||
let filteredEntities = entities.concat(stateEntities);
|
||||
|
||||
let filteredConfigEntry: ConfigEntry | undefined;
|
||||
const filteredDomains = new Set<string>();
|
||||
@@ -459,26 +501,29 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
||||
}
|
||||
});
|
||||
|
||||
if (!showDisabled) {
|
||||
filteredEntities = filteredEntities.filter(
|
||||
(entity) => !entity.disabled_by
|
||||
);
|
||||
}
|
||||
|
||||
if (!showHidden) {
|
||||
filteredEntities = filteredEntities.filter(
|
||||
(entity) => !entity.hidden_by
|
||||
);
|
||||
}
|
||||
|
||||
for (const entry of filteredEntities) {
|
||||
const entity = this.hass.states[entry.entity_id];
|
||||
const unavailable = entity?.state === UNAVAILABLE;
|
||||
const restored = entity?.attributes.restored === true;
|
||||
const areaId = entry.area_id ?? devices[entry.device_id!]?.area_id;
|
||||
const area = areaId ? areas[areaId] : undefined;
|
||||
const hidden = !!entry.hidden_by;
|
||||
const disabled = !!entry.disabled_by;
|
||||
const readonly = entry.readonly;
|
||||
const available = entity?.state && entity.state !== UNAVAILABLE;
|
||||
|
||||
if (!showUnavailable && unavailable) {
|
||||
if (
|
||||
!(
|
||||
(showAvailable && available) ||
|
||||
(showUnavailable && unavailable) ||
|
||||
(showRestored && restored) ||
|
||||
(showVisible && !hidden) ||
|
||||
(showHidden && hidden) ||
|
||||
(showDisabled && disabled) ||
|
||||
(showEnabled && !disabled) ||
|
||||
(showReadOnly && readonly)
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -500,21 +545,30 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
||||
area: area ? area.name : "—",
|
||||
domain: domainToName(localize, computeDomain(entry.entity_id)),
|
||||
status: restored
|
||||
? localize("ui.panel.config.entities.picker.status.restored")
|
||||
? localize("ui.panel.config.entities.picker.status.not_provided")
|
||||
: unavailable
|
||||
? localize("ui.panel.config.entities.picker.status.unavailable")
|
||||
: entry.disabled_by
|
||||
: disabled
|
||||
? localize("ui.panel.config.entities.picker.status.disabled")
|
||||
: entry.hidden_by
|
||||
: hidden
|
||||
? localize("ui.panel.config.entities.picker.status.hidden")
|
||||
: entry.readonly
|
||||
: readonly
|
||||
? localize(
|
||||
"ui.panel.config.entities.picker.status.readonly"
|
||||
"ui.panel.config.entities.picker.status.unmanageable"
|
||||
)
|
||||
: localize(
|
||||
"ui.panel.config.entities.picker.status.available"
|
||||
),
|
||||
label_entries: labelsEntries,
|
||||
available: unavailable
|
||||
? localize("ui.panel.config.entities.picker.status.unavailable")
|
||||
: localize("ui.panel.config.entities.picker.status.available"),
|
||||
enabled: disabled
|
||||
? localize("ui.panel.config.entities.picker.status.disabled")
|
||||
: localize("ui.panel.config.entities.picker.status.enabled"),
|
||||
visible: hidden
|
||||
? localize("ui.panel.config.entities.picker.status.hidden")
|
||||
: localize("ui.panel.config.entities.picker.status.visible"),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -861,7 +915,7 @@ ${
|
||||
protected firstUpdated() {
|
||||
this._filters = {
|
||||
"ha-filter-states": {
|
||||
value: ["unavailable", "readonly"],
|
||||
value: ["enabled"],
|
||||
items: undefined,
|
||||
},
|
||||
};
|
||||
@@ -876,10 +930,7 @@ ${
|
||||
this._filters = {
|
||||
...this._filters,
|
||||
"ha-filter-states": {
|
||||
value: [
|
||||
...(this._filters["ha-filter-states"]?.value || []),
|
||||
"disabled",
|
||||
],
|
||||
value: [],
|
||||
items: undefined,
|
||||
},
|
||||
"ha-filter-integrations": {
|
||||
@@ -892,10 +943,7 @@ ${
|
||||
this._filters = {
|
||||
...this._filters,
|
||||
"ha-filter-states": {
|
||||
value: [
|
||||
...(this._filters["ha-filter-states"]?.value || []),
|
||||
"disabled",
|
||||
],
|
||||
value: [],
|
||||
items: undefined,
|
||||
},
|
||||
config_entry: {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user