mirror of
https://github.com/home-assistant/frontend.git
synced 2026-11-26 22:59:34 +00:00
Compare commits
27
Commits
20261125.1
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01f9c5eb5b | ||
|
|
40a28525fb | ||
|
|
f80deb0240 | ||
|
|
68313876d3 | ||
|
|
c3db90ae22 | ||
|
|
95e0988b93 | ||
|
|
00312420d8 | ||
|
|
f2116b61fc | ||
|
|
2e872965f6 | ||
|
|
cbf745f38a | ||
|
|
fe7cedd04b | ||
|
|
2e9d8a1788 | ||
|
|
332d612956 | ||
|
|
11ef852384 | ||
|
|
394d5999b8 | ||
|
|
384fdfdbc9 | ||
|
|
0cccdc5972 | ||
|
|
771eaa70ff | ||
|
|
aff47efe5e | ||
|
|
f13470719c | ||
|
|
5f769d613c | ||
|
|
f214ef8667 | ||
|
|
528ebe6b27 | ||
|
|
82e6f1106f | ||
|
|
f02656da54 | ||
|
|
25307e427d | ||
|
|
207cbcc585 |
No files matched your search
@@ -0,0 +1,43 @@
|
||||
---
|
||||
name: ha-frontend-browser-checks
|
||||
description: Check a Home Assistant frontend change in a browser and show it in a pull request. Use when checking how a change looks or behaves at different screen sizes, in light and dark mode, right to left (RTL) or with long translations, or when taking before and after screenshots or recording a demo of a feature for a pull request.
|
||||
---
|
||||
|
||||
# HA Frontend Browser Checks
|
||||
|
||||
Use this skill to check a visible change in a browser and to show it in a pull request. Any browser tool you already have works if it can open a page, set its size, run a script in it, take screenshots and record video. Load `ha-frontend-testing` for the dev servers, and `ha-frontend-loading` for loading states.
|
||||
|
||||
Screenshots and recordings help reviewers see what changed, but they don't make a large change easy to review. [Keep pull requests small](https://contributors.home-assistant.io/start/pull-requests/#keep-it-small), and make sure you have reviewed and understood the change and can explain it, as the [AI policy](https://contributors.home-assistant.io/start/ai-policy/) asks.
|
||||
|
||||
## Check Real Devices
|
||||
|
||||
Check the sizes the change affects rather than one fixed size, such as a phone, a tablet in both orientations, a laptop and a large desktop monitor. Include a small phone. Take each device's viewport in CSS pixels, its pixel ratio and touch support from the device presets your tools have, rather than from memory, and check the page really has that size once it's set.
|
||||
|
||||
## Check Light And Dark
|
||||
|
||||
When the change can look different in light and dark mode, such as a colour, border, background or image, check it in both. Switch the colour scheme in your browser tool, with the profile's theme following it, or pick light and dark in the profile. A fix for one mode only needs that mode.
|
||||
|
||||
## Check Right To Left (RTL)
|
||||
|
||||
Check layout, alignment, icons and anything with a direction in RTL. In the app, set your profile language to one written right to left, then set it back: many components take their direction from the language, so setting the page to RTL in your browser tool leaves them left to right. The gallery's RTL toggle checks styling only.
|
||||
|
||||
## Check Long Text
|
||||
|
||||
When a change adds or changes text, check it in a language with long words or long translations too, so labels, descriptions and buttons don't overflow or wrap badly. When the new string isn't translated yet, try a rough translation to check its length.
|
||||
|
||||
## Show It In The Pull Request
|
||||
|
||||
- When the change alters something that exists already, capture the same screen on `dev` and on your branch, in the same state, and put them side by side. Only a new screen, with nothing before it, needs just the after.
|
||||
- Keep the size of every capture fixed, screenshots as well as videos. Set the page size before you capture and don't change it in between, and capture the same area each time, so the subject sits in the same place in before and after. For a card or other part of the page, work out a fixed area around it for each size you test, and use that same area on both branches.
|
||||
- Say which device, size or mode each capture shows.
|
||||
- Make the change easy to see: capture the part of the screen it affects rather than a whole page where it's a few pixels.
|
||||
- Save captures outside the repository, so they can't be committed by accident.
|
||||
- Keep personal details out: use demo data, such as the demo or the Demo integration, and mask anything else before you capture, such as names, addresses, IP and MAC addresses, hostnames, serial numbers and tokens. Check each capture before you attach it.
|
||||
|
||||
Record a video when it shows the change better than a still, such as an animation, a drag, a loading sequence (hold the loading state as "Checking It" in `ha-frontend-loading` shows) or a flow across several screens. Keep each video short and small: GitHub limits upload sizes, and reviewers have to watch it. You can record it yourself with the tools you have; it doesn't need a person.
|
||||
|
||||
- Use the recording tools at hand: your browser tool's recorder for a page, or a desktop screen recorder for a window, such as a phone emulator, so the device frame shows.
|
||||
- Don't resize, zoom or take screenshots while recording, which redraw the page at another size and make the video jump.
|
||||
- Check the whole recording before you attach it. For a short clip, look at a frame every second or half second, not only the first and last, since the page can jump to another size partway through. Record again if it does. Take stills from the same frames, so they match the video.
|
||||
- Keep the window drawn on a screen. A hidden or minimised window records only a frame every few seconds.
|
||||
- Label each video, such as **Before** and **After**, and say what it shows and how you set it up. Say what you didn't record and why.
|
||||
@@ -20,7 +20,7 @@ When creating a pull request, use `.github/PULL_REQUEST_TEMPLATE.md` as the body
|
||||
- Do not omit, reorder, or rewrite template sections.
|
||||
- Check the appropriate "Type of change" box based on the actual change.
|
||||
- Do not check checklist items on behalf of the user.
|
||||
- If the PR includes UI changes, remind the user to add screenshots or a short video.
|
||||
- If the PR includes UI changes, add screenshots or a short video, taken as `ha-frontend-browser-checks` describes. Only ask the user to add them when you can't take them yourself.
|
||||
- Explain what the change does for users, not only implementation details.
|
||||
- Use Markdown.
|
||||
|
||||
|
||||
@@ -53,10 +53,11 @@ Detailed guidance lives in `.agents/skills/<name>/SKILL.md`. Load every matching
|
||||
- `ha-frontend-ux-readiness`: UI/UX routing that complements frontend review for new user experiences.
|
||||
- `ha-frontend-gallery`: gallery pages, demos, sidebar structure, content, and verification.
|
||||
- `ha-frontend-demo`: standalone demo structure, configurations, navigation, shared stubs, and verification.
|
||||
- `ha-frontend-browser-checks`: checking a change in a browser at real device sizes, in light and dark mode, right to left (RTL) and with long translations, and screenshots and recorded demos for pull requests.
|
||||
|
||||
## Pull Requests
|
||||
|
||||
When creating a pull request, use `.github/PULL_REQUEST_TEMPLATE.md` as the PR body. Preserve template sections, check only the appropriate type-of-change boxes, and do not check checklist items on behalf of the user. If the PR includes UI changes, remind the user to add screenshots or a short video.
|
||||
When creating a pull request, use `.github/PULL_REQUEST_TEMPLATE.md` as the PR body. Preserve template sections, check only the appropriate type-of-change boxes, and do not check checklist items on behalf of the user. If the PR includes UI changes, add screenshots or a short video, taken as `ha-frontend-browser-checks` describes. Only ask the user to add them when you can't take them yourself.
|
||||
|
||||
## AI policy
|
||||
|
||||
|
||||
@@ -70,6 +70,32 @@ const ENTITIES = [
|
||||
CoverEntityFeature.CLOSE_TILT,
|
||||
},
|
||||
},
|
||||
{
|
||||
entity_id: "cover.tilt_only_closed",
|
||||
state: "closed",
|
||||
attributes: {
|
||||
friendly_name: "Tilt-only blind closed",
|
||||
device_class: "blind",
|
||||
assumed_state: true,
|
||||
supported_features:
|
||||
CoverEntityFeature.OPEN_TILT +
|
||||
CoverEntityFeature.STOP_TILT +
|
||||
CoverEntityFeature.CLOSE_TILT,
|
||||
},
|
||||
},
|
||||
{
|
||||
entity_id: "cover.tilt_only_open",
|
||||
state: "open",
|
||||
attributes: {
|
||||
friendly_name: "Tilt-only blind open",
|
||||
device_class: "blind",
|
||||
assumed_state: true,
|
||||
supported_features:
|
||||
CoverEntityFeature.OPEN_TILT +
|
||||
CoverEntityFeature.STOP_TILT +
|
||||
CoverEntityFeature.CLOSE_TILT,
|
||||
},
|
||||
},
|
||||
{
|
||||
entity_id: "cover.tilt_slider_half",
|
||||
state: "on",
|
||||
|
||||
+3
-3
@@ -79,7 +79,7 @@
|
||||
"@swc/helpers": "0.5.24",
|
||||
"@tsparticles/engine": "4.5.4",
|
||||
"@tsparticles/preset-links": "4.5.4",
|
||||
"@versatiles/style": "9.1.0",
|
||||
"@versatiles/style": "9.1.1",
|
||||
"@vibrant/color": "4.0.4",
|
||||
"@vvo/tzdb": "6.204.0",
|
||||
"@webcomponents/scoped-custom-element-registry": "0.0.11",
|
||||
@@ -110,7 +110,7 @@
|
||||
"lit-html": "3.3.3",
|
||||
"maplibre-gl": "6.19.0",
|
||||
"marked": "18.2.1",
|
||||
"memoize-one": "6.0.0",
|
||||
"memoize-one": "7.0.0",
|
||||
"nanoid": "6.0.2",
|
||||
"node-vibrant": "4.0.4",
|
||||
"object-hash": "3.0.0",
|
||||
@@ -214,7 +214,7 @@
|
||||
"terser-webpack-plugin": "5.6.1",
|
||||
"ts-lit-plugin": "2.0.2",
|
||||
"typescript": "6.0.3",
|
||||
"typescript-eslint": "8.73.0",
|
||||
"typescript-eslint": "8.74.0",
|
||||
"vite": "8.3.8",
|
||||
"vite-tsconfig-paths": "6.1.1",
|
||||
"vitest": "5.1.1",
|
||||
|
||||
Generated
+86
-86
@@ -316,8 +316,8 @@ importers:
|
||||
specifier: 4.5.4
|
||||
version: 4.5.4
|
||||
'@versatiles/style':
|
||||
specifier: 9.1.0
|
||||
version: 9.1.0([email protected])
|
||||
specifier: 9.1.1
|
||||
version: 9.1.1([email protected])
|
||||
'@vibrant/color':
|
||||
specifier: 4.0.4
|
||||
version: 4.0.4
|
||||
@@ -409,8 +409,8 @@ importers:
|
||||
specifier: 18.2.1
|
||||
version: 18.2.1
|
||||
memoize-one:
|
||||
specifier: 6.0.0
|
||||
version: 6.0.0
|
||||
specifier: 7.0.0
|
||||
version: 7.0.0
|
||||
nanoid:
|
||||
specifier: 6.0.2
|
||||
version: 6.0.2
|
||||
@@ -615,7 +615,7 @@ importers:
|
||||
version: 0.13.11([email protected])
|
||||
eslint-plugin-import-x:
|
||||
specifier: 4.18.1
|
||||
version: 4.18.1(@typescript-eslint/[email protected]3.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])
|
||||
version: 4.18.1(@typescript-eslint/[email protected]4.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])
|
||||
eslint-plugin-lit:
|
||||
specifier: 2.3.1
|
||||
version: 2.3.1([email protected]([email protected]))
|
||||
@@ -624,7 +624,7 @@ importers:
|
||||
version: 5.1.3([email protected]([email protected]))
|
||||
eslint-plugin-unused-imports:
|
||||
specifier: 4.4.1
|
||||
version: 4.4.1(@typescript-eslint/[email protected]3.0(@typescript-eslint/[email protected]3.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))
|
||||
version: 4.4.1(@typescript-eslint/[email protected]4.0(@typescript-eslint/[email protected]4.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))
|
||||
eslint-plugin-wc:
|
||||
specifier: 3.1.0
|
||||
version: 3.1.0([email protected]([email protected]))
|
||||
@@ -716,8 +716,8 @@ importers:
|
||||
specifier: 6.0.3
|
||||
version: 6.0.3
|
||||
typescript-eslint:
|
||||
specifier: 8.73.0
|
||||
version: 8.73.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
specifier: 8.74.0
|
||||
version: 8.74.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
vite:
|
||||
specifier: 8.3.8
|
||||
version: 8.3.8(@types/[email protected])([email protected])([email protected])
|
||||
@@ -2353,8 +2353,8 @@ packages:
|
||||
leaflet: ^1.9.3
|
||||
maplibre-gl: ^2.4.0 || ^3.3.1 || ^4.3.2 || ^5.0.0 || ^6.0.0
|
||||
|
||||
'@maplibre/maplibre-gl-style-spec@26.8.0':
|
||||
resolution: {integrity: sha512-EClj+0m624zGw5gdCOsI5f88bYzkXfgoP2Sj5VGs2AYg9hZaPxvCumX5KDDs6aKFwl2ut+3jAeLhvrSz7hEsBQ==}
|
||||
'@maplibre/maplibre-gl-style-spec@26.9.0':
|
||||
resolution: {integrity: sha512-cQZK2lG3d6I5FjriPZCgJx/LiVMpWqoVibF+cgp2mkQ/P4BIGOsrA3WsvLw1wB28Q9JU9v2fapsQUJUbjjwa6g==}
|
||||
hasBin: true
|
||||
|
||||
'@maplibre/[email protected]':
|
||||
@@ -3535,50 +3535,50 @@ packages:
|
||||
'@types/[email protected]':
|
||||
resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==}
|
||||
|
||||
'@typescript-eslint/[email protected]3.0':
|
||||
resolution: {integrity: sha512-UkygMFer53Yzn29MCYFTHf34hGXf5KJhiDWfIm1tXtXRrym1CS6l5H9Y3yCtPWChpC0/f93H88gdj8tN0dd4kw==}
|
||||
'@typescript-eslint/[email protected]4.0':
|
||||
resolution: {integrity: sha512-z3KXk1+Vm+d82ZRplOoC89ho4Rf1da5ju6sx8//92GnN532U62DGPjECXkkVqtYzIv0zoJlpO39SX2Z9tk6LVw==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
peerDependencies:
|
||||
'@typescript-eslint/parser': ^8.73.0
|
||||
'@typescript-eslint/parser': ^8.74.0
|
||||
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
||||
typescript: '>=4.8.4 <6.1.0'
|
||||
|
||||
'@typescript-eslint/[email protected]3.0':
|
||||
resolution: {integrity: sha512-AuL45bVcmssHfZ3Di3cs9Q0l4gBm4ZFVrJOQEE7VpqW+PVgQaEwSwazz4TVIiFabXkk6U51EprYDwqw+HR8ePw==}
|
||||
'@typescript-eslint/[email protected]4.0':
|
||||
resolution: {integrity: sha512-ecr8AYdig7avVkxaHdQvxHnIJ/mOyliO4Gv/uWF8q69vBew/z3sexqBwHUZX5Vql+Ns0w4sH6gBLkICGbOvJkA==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
peerDependencies:
|
||||
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
||||
typescript: '>=4.8.4 <6.1.0'
|
||||
|
||||
'@typescript-eslint/[email protected]3.0':
|
||||
resolution: {integrity: sha512-/pEf8Rc4Mjk+qJnY0uO1+Gadeal8uv50xpuic+srG2vIVatA0XxvWMUeMtFvs6OCHqftiQ7/+qH4aehG5stzIA==}
|
||||
'@typescript-eslint/[email protected]4.0':
|
||||
resolution: {integrity: sha512-z/mymuE+JlEeSFIv3Mo70EvgG1Zz74Hl0IDfExfXutARAP834bt+MppTD7mVAwmZO0GdxdOAi0jbTam749eH6g==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
peerDependencies:
|
||||
typescript: '>=4.8.4 <6.1.0'
|
||||
|
||||
'@typescript-eslint/[email protected]3.0':
|
||||
resolution: {integrity: sha512-/TjD738Iq2rzj5z0ixVOi+TsvgjAzZPLPaH1yWdDBytR/HTR5gMpyYWZeCe5WTQZLwk3ho8AV7U3muoQCRtXBQ==}
|
||||
'@typescript-eslint/[email protected]4.0':
|
||||
resolution: {integrity: sha512-kpOdpu4CpWN5U38ox3f727DwWRBtUAVhyUJtqTBYe5gf2wYoxac7PgKP14txrxN7ICVtcjlLdzjqfRgpSnDKvQ==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
|
||||
'@typescript-eslint/[email protected]3.0':
|
||||
resolution: {integrity: sha512-lmtCFOfYaJfpqZywGuXi4FpNtE+NQ+YLe3T0K9rtEDcW8ZuGWvfI++pj8r05sYMI8vWT2CYK4rWyedmD6Rp4og==}
|
||||
'@typescript-eslint/[email protected]4.0':
|
||||
resolution: {integrity: sha512-p07wAuaS6BjCYgOSXKJi4YhvTnAf7fiG37e9THcpnYaQEt2QiTTYZWKwUFNgeRiywiMudazhzgddAirZ0GgHtQ==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
peerDependencies:
|
||||
typescript: '>=4.8.4 <6.1.0'
|
||||
|
||||
'@typescript-eslint/[email protected]3.0':
|
||||
resolution: {integrity: sha512-MOC9i4xy1F7KcDde7Ip8jf1SrRiALb2Km4UWxGNjUE2YlhjIEo1ayE27GHIwIQyfWuHTmEonQT14uyurlyC6aA==}
|
||||
'@typescript-eslint/[email protected]4.0':
|
||||
resolution: {integrity: sha512-CV3Y3la8l3F9ANfxcfpgSSiQgJTe4IeLEoZV4O/gcW86Ugp8X6SKiQ0vm+QegXaRIbbDMokZZSF3A1CgiU/kPw==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
peerDependencies:
|
||||
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
||||
typescript: '>=4.8.4 <6.1.0'
|
||||
|
||||
'@typescript-eslint/[email protected]3.0':
|
||||
resolution: {integrity: sha512-O/1ytYzflF16QDKXx4/qOXg1IuZp+n7hr9t+S0nv7N/2Tl8rJiNCshztV1gcSUvHbPtoX3+zmNbtSAyVbzxVfw==}
|
||||
'@typescript-eslint/[email protected]4.0':
|
||||
resolution: {integrity: sha512-MpnMrJCVNpP1iVL8NiHkQZgQqIMBH5ewDGUPBh1pqQXwFtMFjsl1M03QcYPXmv6stCKEiF0PN7CGbU1ZbXFzEA==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
|
||||
'@typescript-eslint/[email protected]3.0':
|
||||
resolution: {integrity: sha512-InjlBkSdWceIwIBWSwS3ENUp+i0O02PGX3Zv2wnihWJC1WDVGvG7mTHuf8b57uAaITj94d6tRPDH+sUEtXdRQQ==}
|
||||
'@typescript-eslint/[email protected]4.0':
|
||||
resolution: {integrity: sha512-wL348k6l92DNG+kPP5rVpKwNBoz7a3xRZy3TPKc1uymQttd7u7gcMv3eENmcuh4CjC4mO3FTM0DYstFXMyDLuw==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
peerDependencies:
|
||||
'@typescript/native': npm:typescript@>=7.1.0-dev.20261009.1 || >=7.1.0-beta <7.1.0-dev
|
||||
@@ -3587,15 +3587,15 @@ packages:
|
||||
'@typescript/native':
|
||||
optional: true
|
||||
|
||||
'@typescript-eslint/[email protected]3.0':
|
||||
resolution: {integrity: sha512-j2SVJJvVkXdUL0WcEzo4vEH1mO1vIi8KlVukcYA2MgMZvYN2LlZR4PmsW+GTSxSW24j6Q/EP7+MOifLtg5hmsA==}
|
||||
'@typescript-eslint/[email protected]4.0':
|
||||
resolution: {integrity: sha512-IpWXPxXXomzxyTcvjhZJexgdvtTR1TooLAPpuxzaGqQ8BHll1lf4Ysp/BTE/l0U5TJ+x1j7B4bEM8pLRrvY+XA==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
peerDependencies:
|
||||
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
||||
typescript: '>=4.8.4 <6.1.0'
|
||||
|
||||
'@typescript-eslint/[email protected]3.0':
|
||||
resolution: {integrity: sha512-k4lsFVpRZICbltkIEEH4hZRkwXkqDF1GHBpClKQOHQY+RkoZAAuyc1ci3I6p+CB6v3U4jaHIUshc4RzzQXZWLg==}
|
||||
'@typescript-eslint/[email protected]4.0':
|
||||
resolution: {integrity: sha512-XSZmOtMUbWCBIM+2BK134FyMFxmll1mW2mPLk/PSwYQYzGIPMgJAqL929U4qXVizLv7Xq5b7r41/o7Ombuwk0g==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
|
||||
'@typescript/[email protected]':
|
||||
@@ -3838,8 +3838,8 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@versatiles/[email protected].0':
|
||||
resolution: {integrity: sha512-P2gLER3/VAOLGCMiumZ1hjHenlsAiI4mz1gPSak9ZAci0BgPYVfY+oo01MIYIfN4A+AvL1gfwZ3eC2vYQVqtlQ==}
|
||||
'@versatiles/[email protected].1':
|
||||
resolution: {integrity: sha512-JMOuqOq+uOX2PQZORX5rm0fxrvEx5KUvz/Oxr1JIOtuWRjdO5izpXPfg9/s+DeImd3Xpt8BG05X/hL5rkmY+9Q==}
|
||||
engines: {node: '>=20'}
|
||||
peerDependencies:
|
||||
maplibre-gl: '>=5.5.0'
|
||||
@@ -6197,8 +6197,8 @@ packages:
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==}
|
||||
|
||||
memoize-one@6.0.0:
|
||||
resolution: {integrity: sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==}
|
||||
memoize-one@7.0.0:
|
||||
resolution: {integrity: sha512-2N/rFuzS9eTTDXVmo/PO86KmapXPCOqDgR3eOnmWW1NVW8YXGzXcTWMKiGq/VAsYVl42Pd8rQ2DMsoYunIATLw==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-+y4mDxU4rvXXu5UDSGCGNiesFmwCHuefGMoPCO1WYucNYj7DsLqrFaa2fXVI0H+NNiPTwwzKwspn9yTZqUGqng==}
|
||||
@@ -7604,8 +7604,8 @@ packages:
|
||||
resolution: {integrity: sha512-phPGCwqr2+Qo0fwniCE8e4pKnGu/yFb5nD5Y8bf0EEeiI5GklnACYA9GFy/DrAeRrKHXvHn+1SUsOWgJp6RO+g==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
[email protected]3.0:
|
||||
resolution: {integrity: sha512-+EnKy9rkYPun4l+kG2bDuYWQ6y1tGVgdR/tY1U9AC6h21CjEwOoc7gsjwe0FXB8uWFzk4QiCFbuRWgX758PiAg==}
|
||||
[email protected]4.0:
|
||||
resolution: {integrity: sha512-OsWQlsedt1ZpZXfZZMNK3m4SoQONFFcy4h/uRznsCeRfVuEic3gh4KGUs2pJJ5o0Jj0Jr7keUHQGN1Ns9aDw7Q==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
peerDependencies:
|
||||
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
|
||||
@@ -10228,7 +10228,7 @@ snapshots:
|
||||
leaflet: 1.9.4
|
||||
maplibre-gl: 6.19.0
|
||||
|
||||
'@maplibre/maplibre-gl-style-spec@26.8.0':
|
||||
'@maplibre/maplibre-gl-style-spec@26.9.0':
|
||||
dependencies:
|
||||
'@mapbox/jsonlint-lines-primitives': 2.0.3
|
||||
'@mapbox/unitbezier': 1.0.0
|
||||
@@ -11443,14 +11443,14 @@ snapshots:
|
||||
dependencies:
|
||||
'@types/node': 24.19.2
|
||||
|
||||
'@typescript-eslint/[email protected]3.0(@typescript-eslint/[email protected]3.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])':
|
||||
'@typescript-eslint/[email protected]4.0(@typescript-eslint/[email protected]4.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])':
|
||||
dependencies:
|
||||
'@eslint-community/regexpp': 4.12.2
|
||||
'@typescript-eslint/parser': 8.73.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/scope-manager': 8.73.0
|
||||
'@typescript-eslint/type-utils': 8.73.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/utils': 8.73.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/visitor-keys': 8.73.0
|
||||
'@typescript-eslint/parser': 8.74.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/scope-manager': 8.74.0
|
||||
'@typescript-eslint/type-utils': 8.74.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/utils': 8.74.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/visitor-keys': 8.74.0
|
||||
eslint: 10.15.0([email protected])
|
||||
ignore: 7.0.6
|
||||
natural-compare: 1.4.0
|
||||
@@ -11460,12 +11460,12 @@ snapshots:
|
||||
- '@typescript/native'
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/[email protected]3.0([email protected]([email protected]))([email protected])([email protected])([email protected])':
|
||||
'@typescript-eslint/[email protected]4.0([email protected]([email protected]))([email protected])([email protected])([email protected])':
|
||||
dependencies:
|
||||
'@typescript-eslint/scope-manager': 8.73.0
|
||||
'@typescript-eslint/types': 8.73.0
|
||||
'@typescript-eslint/typescript-estree': 8.73.0([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/visitor-keys': 8.73.0
|
||||
'@typescript-eslint/scope-manager': 8.74.0
|
||||
'@typescript-eslint/types': 8.74.0
|
||||
'@typescript-eslint/typescript-estree': 8.74.0([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/visitor-keys': 8.74.0
|
||||
debug: 4.4.3([email protected])
|
||||
eslint: 10.15.0([email protected])
|
||||
typescript: 6.0.3
|
||||
@@ -11473,29 +11473,29 @@ snapshots:
|
||||
- '@typescript/native'
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/[email protected]3.0([email protected])([email protected])':
|
||||
'@typescript-eslint/[email protected]4.0([email protected])([email protected])':
|
||||
dependencies:
|
||||
'@typescript-eslint/tsconfig-utils': 8.73.0([email protected])
|
||||
'@typescript-eslint/types': 8.73.0
|
||||
'@typescript-eslint/tsconfig-utils': 8.74.0([email protected])
|
||||
'@typescript-eslint/types': 8.74.0
|
||||
debug: 4.4.3([email protected])
|
||||
typescript: 6.0.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/[email protected]3.0':
|
||||
'@typescript-eslint/[email protected]4.0':
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 8.73.0
|
||||
'@typescript-eslint/visitor-keys': 8.73.0
|
||||
'@typescript-eslint/types': 8.74.0
|
||||
'@typescript-eslint/visitor-keys': 8.74.0
|
||||
|
||||
'@typescript-eslint/[email protected]3.0([email protected])':
|
||||
'@typescript-eslint/[email protected]4.0([email protected])':
|
||||
dependencies:
|
||||
typescript: 6.0.3
|
||||
|
||||
'@typescript-eslint/[email protected]3.0([email protected]([email protected]))([email protected])([email protected])([email protected])':
|
||||
'@typescript-eslint/[email protected]4.0([email protected]([email protected]))([email protected])([email protected])([email protected])':
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 8.73.0
|
||||
'@typescript-eslint/typescript-estree': 8.73.0([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/utils': 8.73.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/types': 8.74.0
|
||||
'@typescript-eslint/typescript-estree': 8.74.0([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/utils': 8.74.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
debug: 4.4.3([email protected])
|
||||
eslint: 10.15.0([email protected])
|
||||
ts-api-utils: 2.5.0([email protected])
|
||||
@@ -11504,14 +11504,14 @@ snapshots:
|
||||
- '@typescript/native'
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/[email protected]3.0': {}
|
||||
'@typescript-eslint/[email protected]4.0': {}
|
||||
|
||||
'@typescript-eslint/[email protected]3.0([email protected])([email protected])([email protected])':
|
||||
'@typescript-eslint/[email protected]4.0([email protected])([email protected])([email protected])':
|
||||
dependencies:
|
||||
'@typescript-eslint/project-service': 8.73.0([email protected])([email protected])
|
||||
'@typescript-eslint/tsconfig-utils': 8.73.0([email protected])
|
||||
'@typescript-eslint/types': 8.73.0
|
||||
'@typescript-eslint/visitor-keys': 8.73.0
|
||||
'@typescript-eslint/project-service': 8.74.0([email protected])([email protected])
|
||||
'@typescript-eslint/tsconfig-utils': 8.74.0([email protected])
|
||||
'@typescript-eslint/types': 8.74.0
|
||||
'@typescript-eslint/visitor-keys': 8.74.0
|
||||
debug: 4.4.3([email protected])
|
||||
minimatch: 11.0.5
|
||||
semver: 7.8.5
|
||||
@@ -11523,21 +11523,21 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/[email protected]3.0([email protected]([email protected]))([email protected])([email protected])([email protected])':
|
||||
'@typescript-eslint/[email protected]4.0([email protected]([email protected]))([email protected])([email protected])([email protected])':
|
||||
dependencies:
|
||||
'@eslint-community/eslint-utils': 4.10.1([email protected]([email protected]))
|
||||
'@typescript-eslint/scope-manager': 8.73.0
|
||||
'@typescript-eslint/types': 8.73.0
|
||||
'@typescript-eslint/typescript-estree': 8.73.0([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/scope-manager': 8.74.0
|
||||
'@typescript-eslint/types': 8.74.0
|
||||
'@typescript-eslint/typescript-estree': 8.74.0([email protected])([email protected])([email protected])
|
||||
eslint: 10.15.0([email protected])
|
||||
typescript: 6.0.3
|
||||
transitivePeerDependencies:
|
||||
- '@typescript/native'
|
||||
- supports-color
|
||||
|
||||
'@typescript-eslint/[email protected]3.0':
|
||||
'@typescript-eslint/[email protected]4.0':
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 8.73.0
|
||||
'@typescript-eslint/types': 8.74.0
|
||||
eslint-visitor-keys: 5.0.1
|
||||
|
||||
'@typescript/[email protected]':
|
||||
@@ -11670,9 +11670,9 @@ snapshots:
|
||||
'@unrs/[email protected]':
|
||||
optional: true
|
||||
|
||||
'@versatiles/[email protected].0([email protected])':
|
||||
'@versatiles/[email protected].1([email protected])':
|
||||
dependencies:
|
||||
'@maplibre/maplibre-gl-style-spec': 26.8.0
|
||||
'@maplibre/maplibre-gl-style-spec': 26.9.0
|
||||
optionalDependencies:
|
||||
maplibre-gl: 6.19.0
|
||||
|
||||
@@ -12870,9 +12870,9 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
[email protected](@typescript-eslint/[email protected]3.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected]):
|
||||
[email protected](@typescript-eslint/[email protected]4.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected]):
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 8.73.0
|
||||
'@typescript-eslint/types': 8.74.0
|
||||
cjs-module-lexer: 2.3.0
|
||||
comment-parser: 1.4.8
|
||||
debug: 4.4.3([email protected])
|
||||
@@ -12885,7 +12885,7 @@ snapshots:
|
||||
stable-hash-x: 0.2.0
|
||||
unrs-resolver: 1.12.2
|
||||
optionalDependencies:
|
||||
'@typescript-eslint/utils': 8.73.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/utils': 8.74.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -12909,11 +12909,11 @@ snapshots:
|
||||
parse5: 8.1.0
|
||||
parse5-htmlparser2-tree-adapter: 8.0.1
|
||||
|
||||
[email protected](@typescript-eslint/[email protected]3.0(@typescript-eslint/[email protected]3.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected])):
|
||||
[email protected](@typescript-eslint/[email protected]4.0(@typescript-eslint/[email protected]4.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected])):
|
||||
dependencies:
|
||||
eslint: 10.15.0([email protected])
|
||||
optionalDependencies:
|
||||
'@typescript-eslint/eslint-plugin': 8.73.0(@typescript-eslint/[email protected]3.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/eslint-plugin': 8.74.0(@typescript-eslint/[email protected]4.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
|
||||
[email protected]([email protected]([email protected])):
|
||||
dependencies:
|
||||
@@ -14150,7 +14150,7 @@ snapshots:
|
||||
'@mapbox/unitbezier': 1.0.0
|
||||
'@mapbox/vector-tile': 3.0.0
|
||||
'@maplibre/geojson-vt': 6.3.2
|
||||
'@maplibre/maplibre-gl-style-spec': 26.8.0
|
||||
'@maplibre/maplibre-gl-style-spec': 26.9.0
|
||||
'@maplibre/mlt': 1.3.0
|
||||
'@maplibre/vt-pbf': 4.3.3
|
||||
'@types/geojson': 7946.0.16
|
||||
@@ -14180,7 +14180,7 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
memoize-one@6.0.0: {}
|
||||
memoize-one@7.0.0: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
@@ -15748,12 +15748,12 @@ snapshots:
|
||||
possible-typed-array-names: 1.1.0
|
||||
reflect.getprototypeof: 1.0.10
|
||||
|
||||
[email protected]3.0([email protected]([email protected]))([email protected])([email protected])([email protected]):
|
||||
[email protected]4.0([email protected]([email protected]))([email protected])([email protected])([email protected]):
|
||||
dependencies:
|
||||
'@typescript-eslint/eslint-plugin': 8.73.0(@typescript-eslint/[email protected]3.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/parser': 8.73.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/typescript-estree': 8.73.0([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/utils': 8.73.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/eslint-plugin': 8.74.0(@typescript-eslint/[email protected]4.0([email protected]([email protected]))([email protected])([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/parser': 8.74.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/typescript-estree': 8.74.0([email protected])([email protected])([email protected])
|
||||
'@typescript-eslint/utils': 8.74.0([email protected]([email protected]))([email protected])([email protected])([email protected])
|
||||
eslint: 10.15.0([email protected])
|
||||
typescript: 6.0.3
|
||||
transitivePeerDependencies:
|
||||
|
||||
+2
-2
@@ -126,9 +126,9 @@
|
||||
"matchPackageNames": ["echarts", "zrender"]
|
||||
},
|
||||
{
|
||||
"description": "Group formatjs monorepo package",
|
||||
"description": "Group formatjs monorepo packages",
|
||||
"groupName": "formatjs",
|
||||
"matchPackageNames": ["@formatjs/**"]
|
||||
"matchPackageNames": ["@formatjs/**", "intl-messageformat"]
|
||||
},
|
||||
{
|
||||
"description": "Group Playwright package and CI container updates",
|
||||
|
||||
@@ -235,7 +235,7 @@ export class HaCameraPlayer extends LitElement {
|
||||
const aspectRatio = this._aspectRatio();
|
||||
if (aspectRatio !== this._firedAspectRatio) {
|
||||
this._firedAspectRatio = aspectRatio;
|
||||
fireEvent(this, "camera-aspect-ratio-changed", { aspectRatio });
|
||||
fireEvent(this, "media-size-changed", { aspectRatio });
|
||||
}
|
||||
if (changedProps.has("keepAwake")) {
|
||||
if (this.keepAwake) {
|
||||
@@ -1189,6 +1189,7 @@ declare global {
|
||||
"ha-camera-player": HaCameraPlayer;
|
||||
}
|
||||
interface HASSDomEvents {
|
||||
"camera-aspect-ratio-changed": { aspectRatio: number };
|
||||
/** The natural width limits the picture's width when it is set */
|
||||
"media-size-changed": { aspectRatio: number; naturalWidth?: number };
|
||||
}
|
||||
}
|
||||
@@ -328,6 +328,11 @@ export function generateStatisticsChartData(
|
||||
: undefined,
|
||||
color: chartType === "bar" ? backgroundColor : borderColor,
|
||||
};
|
||||
if (chartType === "bar") {
|
||||
// echarts sizes bars from the smallest gap between points, so sparse
|
||||
// data (one point, or points far apart) gets huge bars without a cap
|
||||
(series as BarSeriesOption).barMaxWidth = 50;
|
||||
}
|
||||
if (chartStacked) {
|
||||
series.stack = `band-stacked`;
|
||||
series.stackStrategy = "samesign";
|
||||
|
||||
@@ -179,6 +179,10 @@ export class HaControlCircularSlider extends LitElement {
|
||||
|
||||
disconnectedCallback(): void {
|
||||
super.disconnectedCallback();
|
||||
this._destroyListeners();
|
||||
if (this._activeSlider) {
|
||||
this._cancelInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
private _managers: HammerManager[] = [];
|
||||
@@ -248,6 +252,18 @@ export class HaControlCircularSlider extends LitElement {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private _cancelInteraction() {
|
||||
if (this._activeSlider) {
|
||||
fireEvent(this, `${this._activeSlider}-changing`, {
|
||||
value: undefined,
|
||||
});
|
||||
}
|
||||
this._activeSlider = undefined;
|
||||
this._localValue = this.value;
|
||||
this._localLow = this.low;
|
||||
this._localHigh = this.high;
|
||||
}
|
||||
|
||||
private _setupListeners() {
|
||||
if (this._interactions && this._managers.length === 0) {
|
||||
this._interactions.forEach((interaction) => {
|
||||
@@ -279,15 +295,7 @@ export class HaControlCircularSlider extends LitElement {
|
||||
mc.add(new Tap({ event: "singletap" }));
|
||||
|
||||
const cancelInteraction = () => {
|
||||
if (this._activeSlider) {
|
||||
fireEvent(this, `${this._activeSlider}-changing`, {
|
||||
value: undefined,
|
||||
});
|
||||
}
|
||||
this._activeSlider = undefined;
|
||||
this._localValue = this.value;
|
||||
this._localLow = this.low;
|
||||
this._localHigh = this.high;
|
||||
this._cancelInteraction();
|
||||
if (pressToActivate) {
|
||||
panRecognizer.set({ enable: false });
|
||||
}
|
||||
|
||||
@@ -250,8 +250,8 @@ export class HaDialog extends ScrollableFadeMixin(LitElement) {
|
||||
this._hassConfig?.auth.external &&
|
||||
isIosApp(this._hassConfig.auth.external)
|
||||
) {
|
||||
const element = this.querySelector("[autofocus]");
|
||||
if (element !== null) {
|
||||
const element = this._autofocusElement();
|
||||
if (element) {
|
||||
if (!element.id) {
|
||||
element.id = "ha-dialog-autofocus";
|
||||
}
|
||||
@@ -264,10 +264,30 @@ export class HaDialog extends ScrollableFadeMixin(LitElement) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
(this.querySelector("[autofocus]") as HTMLElement | null)?.focus();
|
||||
this._autofocusElement()?.focus();
|
||||
});
|
||||
};
|
||||
|
||||
// Wrappers like ha-adaptive-dialog pass their content in through slots
|
||||
private _autofocusElement(): HTMLElement | null {
|
||||
const element = this.querySelector<HTMLElement>("[autofocus]");
|
||||
if (element) {
|
||||
return element;
|
||||
}
|
||||
for (const slot of this.querySelectorAll("slot")) {
|
||||
for (const assigned of slot.assignedElements({ flatten: true })) {
|
||||
if (assigned.matches("[autofocus]")) {
|
||||
return assigned as HTMLElement;
|
||||
}
|
||||
const nested = assigned.querySelector<HTMLElement>("[autofocus]");
|
||||
if (nested) {
|
||||
return nested;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private _handleAfterShow = (ev: Event) => {
|
||||
if (ev.eventPhase !== Event.AT_TARGET) {
|
||||
return;
|
||||
|
||||
@@ -238,6 +238,7 @@ export class HaGridSizeEditor extends LitElement {
|
||||
grid-template-rows: auto auto;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: var(--ha-space-2);
|
||||
padding-left: var(--ha-space-4);
|
||||
}
|
||||
.precise {
|
||||
grid-area: precise;
|
||||
|
||||
@@ -45,7 +45,7 @@ function adjustRgb(
|
||||
if (wv != null) {
|
||||
return rgbw2rgb([...rgb, wv] as [number, number, number, number]);
|
||||
}
|
||||
if (cw != null && ww !== null) {
|
||||
if (cw != null && ww != null) {
|
||||
return rgbww2rgb(
|
||||
[...rgb, cw, ww] as [number, number, number, number, number],
|
||||
minKelvin,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { TemplateResult } from "lit";
|
||||
import type { PropertyValues, TemplateResult } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
import type { ActionHandlerOptions } from "../../data/lovelace/action_handler";
|
||||
import { actionHandler } from "../../panels/lovelace/common/directives/action-handler-directive";
|
||||
import { actionHandlerBind } from "../../panels/lovelace/common/directives/action-handler-directive";
|
||||
import "../ha-icon";
|
||||
import "../ha-svg-icon";
|
||||
|
||||
@@ -56,6 +56,11 @@ export class HaTileIcon extends LitElement {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
protected updated(changedProps: PropertyValues<this>): void {
|
||||
super.updated(changedProps);
|
||||
actionHandlerBind(this, this.actionHandlerOptions);
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
const hasImage = Boolean(this.imageUrl);
|
||||
|
||||
@@ -67,7 +72,6 @@ export class HaTileIcon extends LitElement {
|
||||
aria-label=${ifDefined(
|
||||
this.interactive ? this.accessibleLabel : undefined
|
||||
)}
|
||||
.actionHandler=${actionHandler(this.actionHandlerOptions)}
|
||||
>
|
||||
<slot name="icon">${this._renderIcon()}</slot>
|
||||
</div>
|
||||
@@ -94,6 +98,7 @@ export class HaTileIcon extends LitElement {
|
||||
:host([interactive]) {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
pointer-events: auto;
|
||||
cursor: pointer;
|
||||
}
|
||||
:host([interactive]:active) {
|
||||
transform: scale(1.2);
|
||||
@@ -143,6 +148,9 @@ export class HaTileIcon extends LitElement {
|
||||
transition: color 180ms ease-in-out;
|
||||
pointer-events: none;
|
||||
}
|
||||
::slotted(:not([slot])) {
|
||||
pointer-events: none;
|
||||
}
|
||||
.container img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
@@ -5,6 +5,9 @@ import {
|
||||
} from "home-assistant-js-websocket";
|
||||
import type { Store } from "home-assistant-js-websocket/dist/store";
|
||||
import type { DataTableRowData } from "../components/data-table/ha-data-table";
|
||||
import type { HomeAssistant } from "../types";
|
||||
import type { ConfigEntry } from "./config_entries";
|
||||
import type { DeviceRegistryEntry } from "./device/device_registry";
|
||||
|
||||
export interface BluetoothDeviceData extends DataTableRowData {
|
||||
address: string;
|
||||
@@ -74,6 +77,54 @@ export const isScannerStateMismatch = (state: BluetoothScannerState): boolean =>
|
||||
state.requested_mode !== "auto" &&
|
||||
state.current_mode !== state.requested_mode;
|
||||
|
||||
export interface BluetoothAdapterDevice {
|
||||
device: DeviceRegistryEntry;
|
||||
entry: ConfigEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the Bluetooth adapters into enabled and disabled ones. An adapter is
|
||||
* a device with a Bluetooth connection that belongs to a `bluetooth` config
|
||||
* entry. Config entries without such a device (for example ignored discoveries
|
||||
* or removed proxies) are not adapters, unless they are disabled, so they can
|
||||
* still be enabled again.
|
||||
*/
|
||||
export const getBluetoothAdapters = (
|
||||
devices: HomeAssistant["devices"],
|
||||
configEntries: ConfigEntry[]
|
||||
) => {
|
||||
const entryMap = new Map(configEntries.map((e) => [e.entry_id, e]));
|
||||
|
||||
const enabledDevices: BluetoothAdapterDevice[] = [];
|
||||
const disabledDevices: BluetoothAdapterDevice[] = [];
|
||||
const matchedEntryIds = new Set<string>();
|
||||
|
||||
for (const device of Object.values(devices)) {
|
||||
const btConnection = device.connections.find((c) => c[0] === "bluetooth");
|
||||
if (!btConnection) {
|
||||
continue;
|
||||
}
|
||||
const entry = device.config_entries
|
||||
.map((id) => entryMap.get(id))
|
||||
.find((e) => e !== undefined);
|
||||
if (!entry) {
|
||||
continue;
|
||||
}
|
||||
matchedEntryIds.add(entry.entry_id);
|
||||
if (entry.disabled_by !== null) {
|
||||
disabledDevices.push({ device, entry });
|
||||
} else {
|
||||
enabledDevices.push({ device, entry });
|
||||
}
|
||||
}
|
||||
|
||||
const disabledEntriesWithoutDevice = configEntries.filter(
|
||||
(e) => e.disabled_by !== null && !matchedEntryIds.has(e.entry_id)
|
||||
);
|
||||
|
||||
return { enabledDevices, disabledDevices, disabledEntriesWithoutDevice };
|
||||
};
|
||||
|
||||
export const subscribeBluetoothScannersDetailsUpdates = (
|
||||
conn: Connection,
|
||||
store: Store<BluetoothScannersDetails>
|
||||
|
||||
+19
-5
@@ -239,12 +239,29 @@ export interface CoverEntity extends HassEntityBase {
|
||||
attributes: CoverEntityAttributes;
|
||||
}
|
||||
|
||||
// For covers that report no value, the open or closed state tells where it is
|
||||
const valueFromState = (stateObj: CoverEntity): number | undefined => {
|
||||
if (stateObj.state === UNKNOWN || stateObj.state === UNAVAILABLE) {
|
||||
return undefined;
|
||||
}
|
||||
return stateObj.state === "closed" || stateObj.state === "opening" ? 0 : 100;
|
||||
};
|
||||
|
||||
export const coverCurrentValue = (
|
||||
stateObj: CoverEntity,
|
||||
mode: CoverControlMode
|
||||
): number | undefined => {
|
||||
if (mode === "tilt") {
|
||||
return stateObj.attributes.current_tilt_position ?? undefined;
|
||||
const tilt = stateObj.attributes.current_tilt_position;
|
||||
// The state only describes the slats when the cover can't move up or down
|
||||
if (
|
||||
tilt != null ||
|
||||
coverSupportsTiltPosition(stateObj) ||
|
||||
coverHasPositionControls(stateObj)
|
||||
) {
|
||||
return tilt ?? undefined;
|
||||
}
|
||||
return valueFromState(stateObj);
|
||||
}
|
||||
const position = stateObj.attributes.current_position;
|
||||
if (
|
||||
@@ -253,10 +270,7 @@ export const coverCurrentValue = (
|
||||
) {
|
||||
return position ?? undefined;
|
||||
}
|
||||
if (stateObj.state === UNKNOWN || stateObj.state === UNAVAILABLE) {
|
||||
return undefined;
|
||||
}
|
||||
return stateObj.state === "closed" || stateObj.state === "opening" ? 0 : 100;
|
||||
return valueFromState(stateObj);
|
||||
};
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -167,3 +167,9 @@ export const updateDismissedSuggestions = (
|
||||
statisticId,
|
||||
];
|
||||
};
|
||||
|
||||
/** The dismissed statistics without the restored one. */
|
||||
export const restoreDismissedSuggestion = (
|
||||
dismissed: string[],
|
||||
statisticId: string
|
||||
): string[] => dismissed.filter((id) => id !== statisticId);
|
||||
@@ -3,8 +3,11 @@ import {
|
||||
mdiImageMultipleOutline,
|
||||
mdiLightningBolt,
|
||||
} from "@mdi/js";
|
||||
import type { ContextType } from "@lit/context";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, state } from "lit/decorators";
|
||||
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
||||
import { consume } from "../../common/decorators/consume";
|
||||
import { consumeLocalize } from "../../common/decorators/consume-context-entry";
|
||||
import type { LocalizeFunc } from "../../common/translations/localize";
|
||||
import { CAMERA_STREAM_TYPE_NAMES } from "../../components/camera/ha-camera-stream-badge";
|
||||
@@ -21,6 +24,8 @@ import {
|
||||
type CameraStreamType,
|
||||
type StreamType,
|
||||
} from "../../data/camera-streams";
|
||||
import { fetchCloudStatus } from "../../data/cloud";
|
||||
import { apiContext, configContext } from "../../data/context";
|
||||
import { haStyleDialog, haStyleDialogFixedTop } from "../../resources/styles";
|
||||
import { DialogMixin } from "../dialog-mixin";
|
||||
import type { CameraStreamInfoDialogParams } from "./show-dialog-camera-stream-info";
|
||||
@@ -40,6 +45,34 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
|
||||
@consumeLocalize()
|
||||
private _localize!: LocalizeFunc;
|
||||
|
||||
@consume({ context: apiContext })
|
||||
private _api!: ContextType<typeof apiContext>;
|
||||
|
||||
@consume({ context: configContext })
|
||||
private _hassConfig!: ContextType<typeof configContext>;
|
||||
|
||||
@state() private _cloudIceServers = false;
|
||||
|
||||
protected firstUpdated() {
|
||||
this._fetchCloudIceServers();
|
||||
}
|
||||
|
||||
// The same check that core uses to add the cloud TURN servers
|
||||
private async _fetchCloudIceServers() {
|
||||
if (!isComponentLoaded(this._hassConfig.config, "cloud")) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const status = await fetchCloudStatus(this._api.callWS);
|
||||
this._cloudIceServers =
|
||||
status.logged_in &&
|
||||
status.active_subscription &&
|
||||
status.prefs.cloud_ice_servers_enabled;
|
||||
} catch (_err) {
|
||||
// Without the cloud status the label stays hidden
|
||||
}
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (!this.params) {
|
||||
return nothing;
|
||||
@@ -124,6 +157,18 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
|
||||
wrap-supporting-text
|
||||
>
|
||||
<ha-svg-icon slot="start" .path=${icon}></ha-svg-icon>
|
||||
${
|
||||
type === STREAM_TYPE_WEB_RTC && this._cloudIceServers
|
||||
? html`<span slot="headline" class="headline">
|
||||
${CAMERA_STREAM_TYPE_NAMES[type]}
|
||||
<span class="tag cloud"
|
||||
>${this._localize(
|
||||
"ui.dialogs.camera_stream_info.enhanced_by_cloud"
|
||||
)}</span
|
||||
>
|
||||
</span>`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
current
|
||||
? html`<span slot="end" class="tag current"
|
||||
@@ -188,6 +233,20 @@ class DialogCameraStreamInfo extends DialogMixin<CameraStreamInfoDialogParams>(
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
|
||||
.headline {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--ha-space-2);
|
||||
/* The row keeps the headline on one line, but a long tag must wrap */
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.tag.cloud {
|
||||
background-color: var(--ha-color-fill-primary-quiet-resting);
|
||||
color: var(--ha-color-on-primary-quiet);
|
||||
}
|
||||
|
||||
.tag.current {
|
||||
background-color: var(--ha-color-fill-success-quiet-resting);
|
||||
color: var(--ha-color-on-success-quiet);
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
coverHasPositionControls,
|
||||
coverHasTiltControls,
|
||||
coverModeAttribute,
|
||||
coverSupportsPosition,
|
||||
coverSupportsSetValue,
|
||||
defaultCoverMode,
|
||||
} from "../../../data/cover";
|
||||
@@ -164,7 +163,7 @@ class MoreInfoCover extends LitElement {
|
||||
if (!request || this._drag) {
|
||||
return undefined;
|
||||
}
|
||||
if (request.mode === "position" && !coverSupportsPosition(this.stateObj!)) {
|
||||
if (!coverSupportsSetValue(this.stateObj!, request.mode)) {
|
||||
return this._hint(request.value ? "requested_open" : "requested_closed");
|
||||
}
|
||||
return this._hint("requested", {
|
||||
|
||||
@@ -2,6 +2,8 @@ import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { consume } from "../../../common/decorators/consume";
|
||||
import { transform } from "../../../common/decorators/transform";
|
||||
import type { HASSDomCurrentTargetEvent } from "../../../common/dom/fire_event";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import { connectionContext, formattersContext } from "../../../data/context";
|
||||
import type { ImageEntity } from "../../../data/image";
|
||||
import { computeImageUrl } from "../../../data/image";
|
||||
@@ -28,6 +30,17 @@ class MoreInfoImage extends LitElement {
|
||||
|
||||
@property({ attribute: false }) public stateObj?: ImageEntity;
|
||||
|
||||
private _size?: HASSDomEvents["media-size-changed"];
|
||||
|
||||
public connectedCallback() {
|
||||
super.connectedCallback();
|
||||
// A cached view that was detached while the picture loaded couldn't send
|
||||
// its size, and the picture doesn't load again when it's shown
|
||||
if (this._size) {
|
||||
fireEvent(this, "media-size-changed", this._size);
|
||||
}
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (!this._connection || !this.stateObj) {
|
||||
return nothing;
|
||||
@@ -39,16 +52,28 @@ class MoreInfoImage extends LitElement {
|
||||
return html`<img
|
||||
alt=${this._formatEntityName?.(this.stateObj) || this.stateObj.entity_id}
|
||||
src=${this._connection.hassUrl(imageUrl)}
|
||||
@load=${this._imageLoaded}
|
||||
/> `;
|
||||
}
|
||||
|
||||
private _imageLoaded(ev: HASSDomCurrentTargetEvent<HTMLImageElement>) {
|
||||
const { naturalWidth, naturalHeight } = ev.currentTarget;
|
||||
if (!naturalWidth || !naturalHeight) {
|
||||
return;
|
||||
}
|
||||
this._size = { aspectRatio: naturalWidth / naturalHeight, naturalWidth };
|
||||
fireEvent(this, "media-size-changed", this._size);
|
||||
}
|
||||
|
||||
static styles = css`
|
||||
:host {
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
img {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
max-width: 100%;
|
||||
max-height: var(--more-info-media-max-height, none);
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -149,10 +149,12 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
|
||||
@property({ type: Boolean, reflect: true }) public large = false;
|
||||
|
||||
@state() private _fill = false;
|
||||
// The dialog grows with the camera's or image's picture, as high as there
|
||||
// is room for
|
||||
@state() private _mediaAspectRatio?: number;
|
||||
|
||||
// The dialog grows with the camera's picture, as high as there is room for
|
||||
@state() private _cameraAspectRatio?: number;
|
||||
// An image is not shown larger than it is
|
||||
@state() private _mediaNaturalWidth?: number;
|
||||
|
||||
// Height of the controls the camera's info shows below the picture
|
||||
@state() private _cameraControlsHeight?: string;
|
||||
@@ -196,12 +198,6 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
}
|
||||
|
||||
public showDialog(params: MoreInfoDialogParams) {
|
||||
// The camera player keeps running for the same entity and doesn't send
|
||||
// its size again
|
||||
if (params.entityId !== this._entityId) {
|
||||
this._cameraAspectRatio = undefined;
|
||||
this._cameraControlsHeight = undefined;
|
||||
}
|
||||
this._entityId = params.entityId;
|
||||
if (!this._entityId) {
|
||||
this.closeDialog();
|
||||
@@ -219,7 +215,6 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._detailsYamlMode = false;
|
||||
|
||||
this.large = params.large ?? false;
|
||||
this._fill = false;
|
||||
this._open = true;
|
||||
this._loadEntityRegistryEntry();
|
||||
}
|
||||
@@ -265,8 +260,6 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._currView = DEFAULT_VIEW;
|
||||
this._childViewStack = [];
|
||||
this._returnUrl = undefined;
|
||||
this._cameraAspectRatio = undefined;
|
||||
this._cameraControlsHeight = undefined;
|
||||
this._isEscapeEnabled = true;
|
||||
window.removeEventListener("dialog-closed", this._enableEscapeKeyClose);
|
||||
window.removeEventListener("show-dialog", this._disableEscapeKeyClose);
|
||||
@@ -691,30 +684,32 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
`
|
||||
: nothing;
|
||||
|
||||
// Also when the camera was opened from a smaller entity's related view
|
||||
const cameraAspectRatio =
|
||||
domain === "camera" && isDefaultView
|
||||
? this._cameraAspectRatio
|
||||
// Also when it was opened from a smaller entity's related view
|
||||
const mediaAspectRatio =
|
||||
(domain === "camera" || domain === "image") && isDefaultView
|
||||
? this._mediaAspectRatio
|
||||
: undefined;
|
||||
// As wide as the picture is when it's as high as there is room for
|
||||
const fullHeightWidth = `var(--more-info-media-max-height) * ${mediaAspectRatio}`;
|
||||
const mediaPictureWidth = this._mediaNaturalWidth
|
||||
? `min(${fullHeightWidth}, ${this._mediaNaturalWidth}px)`
|
||||
: fullHeightWidth;
|
||||
|
||||
return html`
|
||||
<ha-adaptive-dialog
|
||||
.open=${this._open}
|
||||
.width=${
|
||||
this._fill
|
||||
? "full"
|
||||
: this.large || cameraAspectRatio
|
||||
? "large"
|
||||
: "medium"
|
||||
}
|
||||
class=${classMap({ camera: domain === "camera" })}
|
||||
.width=${this.large || mediaAspectRatio ? "large" : "medium"}
|
||||
class=${classMap({
|
||||
camera: domain === "camera",
|
||||
image: domain === "image",
|
||||
})}
|
||||
style=${styleMap({
|
||||
"--more-info-camera-controls-height": this._cameraControlsHeight,
|
||||
"--ha-dialog-width-lg": cameraAspectRatio
|
||||
? `clamp(var(--ha-dialog-width-md, 580px), calc(var(--video-max-height) * ${cameraAspectRatio}), 1920px)`
|
||||
"--ha-dialog-width-lg": mediaAspectRatio
|
||||
? `clamp(var(--ha-dialog-width-md, 580px), calc(${mediaPictureWidth} + var(--more-info-media-inline-padding, 0px)), 1920px)`
|
||||
: undefined,
|
||||
})}
|
||||
@camera-aspect-ratio-changed=${this._cameraAspectRatioChanged}
|
||||
@media-size-changed=${this._mediaSizeChanged}
|
||||
@camera-controls-height-changed=${this._cameraControlsHeightChanged}
|
||||
.accessibleLabel=${title}
|
||||
@closed=${this._dialogClosed}
|
||||
@@ -747,7 +742,7 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
></ha-icon-button-prev>
|
||||
`
|
||||
}
|
||||
<span slot="headerTitle" @click=${this._enlarge} class="title">
|
||||
<span slot="headerTitle" class="title">
|
||||
${
|
||||
breadcrumb.length > 0
|
||||
? !__DEMO__ && isAdmin
|
||||
@@ -1071,6 +1066,17 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
`;
|
||||
}
|
||||
|
||||
protected willUpdate(changedProps: PropertyValues) {
|
||||
super.willUpdate(changedProps);
|
||||
// Also when going to a related entity or back. The camera player or image
|
||||
// of the same entity keeps running and doesn't send its size again.
|
||||
if (changedProps.has("_entityId")) {
|
||||
this._mediaAspectRatio = undefined;
|
||||
this._mediaNaturalWidth = undefined;
|
||||
this._cameraControlsHeight = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues<this>) {
|
||||
super.firstUpdated(changedProps);
|
||||
this.addEventListener("close-dialog", () => this.closeDialog());
|
||||
@@ -1140,10 +1146,11 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._entry = ev.detail;
|
||||
}
|
||||
|
||||
private _cameraAspectRatioChanged(
|
||||
ev: HASSDomEvent<HASSDomEvents["camera-aspect-ratio-changed"]>
|
||||
private _mediaSizeChanged(
|
||||
ev: HASSDomEvent<HASSDomEvents["media-size-changed"]>
|
||||
) {
|
||||
this._cameraAspectRatio = ev.detail.aspectRatio;
|
||||
this._mediaAspectRatio = ev.detail.aspectRatio;
|
||||
this._mediaNaturalWidth = ev.detail.naturalWidth;
|
||||
}
|
||||
|
||||
private _cameraControlsHeightChanged(
|
||||
@@ -1152,12 +1159,6 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
this._cameraControlsHeight = ev.detail.height;
|
||||
}
|
||||
|
||||
private _enlarge() {
|
||||
withViewTransition(() => {
|
||||
this._fill = !this._fill;
|
||||
});
|
||||
}
|
||||
|
||||
private _handleOpened() {
|
||||
window.addEventListener("dialog-closed", this._enableEscapeKeyClose);
|
||||
window.addEventListener("show-dialog", this._disableEscapeKeyClose);
|
||||
@@ -1216,12 +1217,14 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
--dialog-content-padding: 0;
|
||||
}
|
||||
|
||||
/* The dialog's margin, its header of about 68px and the controls
|
||||
below the picture */
|
||||
ha-adaptive-dialog.camera {
|
||||
--video-max-height: calc(
|
||||
100vh - var(--ha-space-20) -
|
||||
68px - var(--more-info-camera-controls-height, 0px)
|
||||
/* The dialog's margin, the safe area like the dialog's height limit,
|
||||
its header of about 68px and what the info shows besides the
|
||||
picture */
|
||||
ha-adaptive-dialog.camera,
|
||||
ha-adaptive-dialog.image {
|
||||
--more-info-media-max-height: calc(
|
||||
100vh - var(--ha-space-20) - var(--safe-area-inset-y, 0px) -
|
||||
68px - var(--more-info-media-reserved-height, 0px)
|
||||
);
|
||||
/* Along with the height of the picture */
|
||||
--ha-dialog-width-transition:
|
||||
@@ -1232,14 +1235,33 @@ export class MoreInfoDialog extends DirtyStateProviderMixin<
|
||||
/* A custom property takes any value, so it can't fall back to the
|
||||
declaration before it. svh like the height limit of the dialog. */
|
||||
@supports (height: 1svh) {
|
||||
ha-adaptive-dialog.camera {
|
||||
--video-max-height: calc(
|
||||
100svh - var(--ha-space-20) -
|
||||
68px - var(--more-info-camera-controls-height, 0px)
|
||||
ha-adaptive-dialog.camera,
|
||||
ha-adaptive-dialog.image {
|
||||
--more-info-media-max-height: calc(
|
||||
100svh - var(--ha-space-20) - var(--safe-area-inset-y, 0px) -
|
||||
68px - var(--more-info-media-reserved-height, 0px)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ha-adaptive-dialog.camera {
|
||||
--more-info-media-reserved-height: var(
|
||||
--more-info-camera-controls-height,
|
||||
0px
|
||||
);
|
||||
--video-max-height: var(--more-info-media-max-height);
|
||||
}
|
||||
|
||||
/* The info's padding around the picture and the entity's row of 40px
|
||||
above it, with 16px between them */
|
||||
ha-adaptive-dialog.image {
|
||||
--more-info-media-reserved-height: calc(
|
||||
var(--ha-space-6) +
|
||||
max(var(--safe-area-inset-bottom, 0px), var(--ha-space-6)) + 56px
|
||||
);
|
||||
--more-info-media-inline-padding: calc(var(--ha-space-6) * 2);
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
|
||||
@@ -95,6 +95,23 @@ class DialogStartupProgress extends DialogMixin(LitElement) {
|
||||
.slice(0, MAX_SLOWEST);
|
||||
});
|
||||
}
|
||||
if (changedProps.has("_progress") || changedProps.has("_setups")) {
|
||||
this._loadTitles();
|
||||
}
|
||||
}
|
||||
|
||||
private _loadTitles() {
|
||||
const progress = this._progress
|
||||
? this._computeProgress(this._progress, this._config.config.state)
|
||||
: undefined;
|
||||
const domains = [
|
||||
...(progress?.active.map(([domain]) => domain) ?? []),
|
||||
...(progress?.failed ?? []),
|
||||
...(this._setups?.map((setup) => setup.domain) ?? []),
|
||||
];
|
||||
if (domains.length) {
|
||||
this._i18n.loadBackendTranslation("title", domains);
|
||||
}
|
||||
}
|
||||
|
||||
protected render() {
|
||||
|
||||
+29
-1
@@ -75,11 +75,39 @@ const clearUrlParams = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const SERVER_CHECK_TIMEOUT = 10_000;
|
||||
|
||||
const checkServer = async () => {
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), SERVER_CHECK_TIMEOUT);
|
||||
try {
|
||||
const response = await fetch(`${hassUrl}/manifest.json`, {
|
||||
mode: "no-cors",
|
||||
cache: "no-store",
|
||||
signal: controller.signal,
|
||||
});
|
||||
if (response.status >= 500) {
|
||||
throw new Error(`Home Assistant responded with ${response.status}`);
|
||||
}
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
};
|
||||
|
||||
// The login page is never cached, so check the server is up before getAuth redirects to it.
|
||||
const loadTokensOrCheckServer = async () => {
|
||||
const tokens = loadTokens();
|
||||
if (!tokens || tokens.hassUrl !== hassUrl) {
|
||||
await checkServer();
|
||||
}
|
||||
return tokens;
|
||||
};
|
||||
|
||||
const authOptions = {
|
||||
hassUrl,
|
||||
limitHassInstance: true,
|
||||
saveTokens,
|
||||
loadTokens: () => Promise.resolve(loadTokens()),
|
||||
loadTokens: loadTokensOrCheckServer,
|
||||
};
|
||||
|
||||
const getAuthDroppingStaleCallback = async () => {
|
||||
|
||||
@@ -89,7 +89,11 @@ class HaBackupConfigAgents extends LitElement {
|
||||
|
||||
const retention = this.agentsConfig?.[agentId]?.retention;
|
||||
|
||||
if (retention) {
|
||||
if (retention && !this._value.includes(agentId)) {
|
||||
texts.push(
|
||||
this.hass.localize("ui.panel.config.backup.agents.retention_inactive")
|
||||
);
|
||||
} else if (retention) {
|
||||
if (retention.copies === null && retention.days === null) {
|
||||
texts.push(
|
||||
this.hass.localize("ui.panel.config.backup.agents.retention_all")
|
||||
|
||||
@@ -120,21 +120,34 @@ class HaConfigBackupDetails extends LitElement {
|
||||
</p>
|
||||
</div>
|
||||
`
|
||||
: html`<ha-backup-config-retention
|
||||
location-specific
|
||||
.headline=${this.hass.localize(
|
||||
`ui.panel.config.backup.location.retention_for_${isLocalAgent(this.agentId) ? "this_system" : "location"}`,
|
||||
{ location: agentName }
|
||||
)}
|
||||
.hass=${this.hass}
|
||||
.retention=${
|
||||
!this.config
|
||||
? undefined
|
||||
: this.config.agents[this.agentId]
|
||||
?.retention || null
|
||||
}
|
||||
@value-changed=${this._retentionChanged}
|
||||
></ha-backup-config-retention>`
|
||||
: html`${
|
||||
this.config &&
|
||||
!this.config.create_backup.agent_ids.includes(
|
||||
this.agentId
|
||||
)
|
||||
? html`<div class="card-content">
|
||||
<ha-alert alert-type="info">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.backup.location.retention_inactive"
|
||||
)}
|
||||
</ha-alert>
|
||||
</div>`
|
||||
: nothing
|
||||
}<ha-backup-config-retention
|
||||
location-specific
|
||||
.headline=${this.hass.localize(
|
||||
`ui.panel.config.backup.location.retention_for_${isLocalAgent(this.agentId) ? "this_system" : "location"}`,
|
||||
{ location: agentName }
|
||||
)}
|
||||
.hass=${this.hass}
|
||||
.retention=${
|
||||
!this.config
|
||||
? undefined
|
||||
: this.config.agents[this.agentId]
|
||||
?.retention || null
|
||||
}
|
||||
@value-changed=${this._retentionChanged}
|
||||
></ha-backup-config-retention>`
|
||||
}
|
||||
</ha-card>
|
||||
<ha-card>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { mdiFire, mdiFlash, mdiLightbulbOnOutline, mdiWater } from "@mdi/js";
|
||||
import type { ContextType } from "@lit/context";
|
||||
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import type { CSSResultGroup, TemplateResult } from "lit";
|
||||
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { repeat } from "lit/directives/repeat";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { consume } from "../../../../common/decorators/consume";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import { consumeEntityStates } from "../../../../common/decorators/consume-context-entry";
|
||||
import { computeAreaName } from "../../../../common/entity/compute_area_name";
|
||||
import { getEntityAreaId } from "../../../../common/entity/context/get_entity_context";
|
||||
@@ -35,6 +36,7 @@ import type {
|
||||
import {
|
||||
computeEnergySuggestions,
|
||||
ENERGY_SUGGESTION_EDITORS,
|
||||
restoreDismissedSuggestion,
|
||||
updateDismissedSuggestions,
|
||||
} from "../../../../data/energy_suggestions";
|
||||
import {
|
||||
@@ -65,6 +67,8 @@ export class EnergySuggestions extends LitElement {
|
||||
|
||||
@property() public tab: EnergySuggestionTab = "electricity";
|
||||
|
||||
@property({ type: Boolean, attribute: false }) public showDismissed = false;
|
||||
|
||||
@state() private _statistics?: StatisticsMetaData[];
|
||||
|
||||
@state() private _dismissed?: string[];
|
||||
@@ -72,6 +76,11 @@ export class EnergySuggestions extends LitElement {
|
||||
// Dismissals not yet echoed by the subscription, so an older echo can't drop them
|
||||
@state() private _pendingDismissed: string[] = [];
|
||||
|
||||
// Restores not yet echoed by the subscription
|
||||
@state() private _pendingRestored: string[] = [];
|
||||
|
||||
private _reportedDismissedCount?: number;
|
||||
|
||||
@state() private _slots: Record<string, EnergySuggestionSlot> = {};
|
||||
|
||||
@state() private _loadFailed = false;
|
||||
@@ -114,27 +123,46 @@ export class EnergySuggestions extends LitElement {
|
||||
(
|
||||
statistics: StatisticsMetaData[],
|
||||
preferences: EnergyPreferences,
|
||||
dismissed: string[],
|
||||
states: HomeAssistant["states"],
|
||||
tab: EnergySuggestionTab
|
||||
) =>
|
||||
computeEnergySuggestions({
|
||||
statistics,
|
||||
preferences,
|
||||
dismissed,
|
||||
states,
|
||||
}).filter((suggestion) => suggestion.tab === tab)
|
||||
computeEnergySuggestions({ statistics, preferences, states }).filter(
|
||||
(suggestion) => suggestion.tab === tab
|
||||
)
|
||||
);
|
||||
|
||||
private _allDismissed = memoizeOne((stored: string[], pending: string[]) =>
|
||||
pending.length
|
||||
? [...stored, ...pending.filter((id) => !stored.includes(id))]
|
||||
: stored
|
||||
private _splitSuggestions = memoizeOne(
|
||||
(all: EnergyMeterSuggestion[], dismissed: string[]) => ({
|
||||
suggestions: all.filter(
|
||||
(suggestion) => !dismissed.includes(suggestion.statisticId)
|
||||
),
|
||||
dismissedSuggestions: all.filter((suggestion) =>
|
||||
dismissed.includes(suggestion.statisticId)
|
||||
),
|
||||
})
|
||||
);
|
||||
|
||||
private _allDismissed = memoizeOne(
|
||||
(stored: string[], pending: string[], restored: string[]) =>
|
||||
[...stored, ...pending.filter((id) => !stored.includes(id))].filter(
|
||||
(id) => !restored.includes(id)
|
||||
)
|
||||
);
|
||||
|
||||
private get _currentDismissed(): string[] {
|
||||
return this._allDismissed(
|
||||
this._dismissed!,
|
||||
this._pendingDismissed,
|
||||
this._pendingRestored
|
||||
);
|
||||
}
|
||||
|
||||
// Kept live so a dismiss in another tab isn't overwritten by this one.
|
||||
private _unsubDismissed?: Promise<UnsubscribeFunc>;
|
||||
|
||||
// Each save builds on the list the previous one stored
|
||||
private _saveQueue: Promise<unknown> = Promise.resolve();
|
||||
|
||||
connectedCallback() {
|
||||
super.connectedCallback();
|
||||
this._load();
|
||||
@@ -161,6 +189,9 @@ export class EnergySuggestions extends LitElement {
|
||||
this._pendingDismissed = this._pendingDismissed.filter(
|
||||
(id) => !dismissed.includes(id)
|
||||
);
|
||||
this._pendingRestored = this._pendingRestored.filter((id) =>
|
||||
dismissed.includes(id)
|
||||
);
|
||||
}
|
||||
);
|
||||
try {
|
||||
@@ -203,14 +234,8 @@ export class EnergySuggestions extends LitElement {
|
||||
if (!this._statistics || !this._dismissed) {
|
||||
return nothing;
|
||||
}
|
||||
const suggestions = this._computeSuggestions(
|
||||
this._statistics,
|
||||
this.preferences,
|
||||
this._allDismissed(this._dismissed, this._pendingDismissed),
|
||||
this._states,
|
||||
this.tab
|
||||
);
|
||||
if (!suggestions.length) {
|
||||
const { suggestions, dismissedSuggestions, showDismissed } = this._view()!;
|
||||
if (!suggestions.length && !showDismissed) {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
@@ -218,27 +243,67 @@ export class EnergySuggestions extends LitElement {
|
||||
<ha-card>
|
||||
<h1 class="card-header">
|
||||
<ha-svg-icon .path=${mdiLightbulbOnOutline}></ha-svg-icon>
|
||||
${this._i18n.localize("ui.panel.config.energy.suggestions.title", {
|
||||
count: suggestions.length,
|
||||
})}
|
||||
${
|
||||
suggestions.length
|
||||
? this._i18n.localize(
|
||||
"ui.panel.config.energy.suggestions.title",
|
||||
{
|
||||
count: suggestions.length,
|
||||
}
|
||||
)
|
||||
: this._i18n.localize(
|
||||
"ui.panel.config.energy.suggestions.dismissed_title"
|
||||
)
|
||||
}
|
||||
</h1>
|
||||
<div class="card-content">
|
||||
<p>
|
||||
${this._i18n.localize("ui.panel.config.energy.suggestions.sub")}
|
||||
</p>
|
||||
<div class="items-container">
|
||||
${repeat(
|
||||
suggestions,
|
||||
(suggestion) => suggestion.statisticId,
|
||||
(suggestion) => this._renderSuggestion(suggestion)
|
||||
${this._i18n.localize(
|
||||
suggestions.length
|
||||
? "ui.panel.config.energy.suggestions.sub"
|
||||
: "ui.panel.config.energy.suggestions.dismissed_sub"
|
||||
)}
|
||||
</div>
|
||||
</p>
|
||||
${
|
||||
suggestions.length
|
||||
? html`<div class="items-container">
|
||||
${repeat(
|
||||
suggestions,
|
||||
(suggestion) => suggestion.statisticId,
|
||||
(suggestion) => this._renderSuggestion(suggestion, false)
|
||||
)}
|
||||
</div>`
|
||||
: nothing
|
||||
}
|
||||
${
|
||||
showDismissed
|
||||
? html`${
|
||||
suggestions.length
|
||||
? html`<h3>
|
||||
${this._i18n.localize(
|
||||
"ui.panel.config.energy.suggestions.dismissed"
|
||||
)}
|
||||
</h3>`
|
||||
: nothing
|
||||
}
|
||||
<div class="items-container">
|
||||
${repeat(
|
||||
dismissedSuggestions,
|
||||
(suggestion) => suggestion.statisticId,
|
||||
(suggestion) => this._renderSuggestion(suggestion, true)
|
||||
)}
|
||||
</div>`
|
||||
: nothing
|
||||
}
|
||||
</div>
|
||||
</ha-card>
|
||||
`;
|
||||
}
|
||||
|
||||
private _renderSuggestion(suggestion: EnergyMeterSuggestion) {
|
||||
private _renderSuggestion(
|
||||
suggestion: EnergyMeterSuggestion,
|
||||
dismissed: boolean
|
||||
) {
|
||||
const slot = this._slotFor(suggestion);
|
||||
const label = getStatisticLabel(
|
||||
this._states,
|
||||
@@ -300,9 +365,11 @@ export class EnergySuggestions extends LitElement {
|
||||
appearance="plain"
|
||||
variant="neutral"
|
||||
.suggestion=${suggestion}
|
||||
@click=${this._dismiss}
|
||||
@click=${dismissed ? this._restore : this._dismiss}
|
||||
>${this._i18n.localize(
|
||||
"ui.panel.config.energy.suggestions.dismiss"
|
||||
dismissed
|
||||
? "ui.panel.config.energy.suggestions.restore"
|
||||
: "ui.panel.config.energy.suggestions.dismiss"
|
||||
)}</ha-button
|
||||
>
|
||||
</div>
|
||||
@@ -341,14 +408,13 @@ export class EnergySuggestions extends LitElement {
|
||||
.suggestion;
|
||||
const statisticId = suggestion.statisticId;
|
||||
this._pendingDismissed = [...this._pendingDismissed, statisticId];
|
||||
this._pendingRestored = this._pendingRestored.filter(
|
||||
(id) => id !== statisticId
|
||||
);
|
||||
try {
|
||||
await saveFrontendUserData(this._connection.connection, "energy", {
|
||||
dismissed_suggestions: updateDismissedSuggestions(
|
||||
this._allDismissed(this._dismissed!, this._pendingDismissed),
|
||||
statisticId,
|
||||
this._statistics!
|
||||
),
|
||||
});
|
||||
await this._saveDismissed((dismissed) =>
|
||||
updateDismissedSuggestions(dismissed, statisticId, this._statistics!)
|
||||
);
|
||||
} catch (err: any) {
|
||||
this._pendingDismissed = this._pendingDismissed.filter(
|
||||
(id) => id !== statisticId
|
||||
@@ -362,6 +428,70 @@ export class EnergySuggestions extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private _view() {
|
||||
if (this._loadFailed || !this._statistics || !this._dismissed) {
|
||||
return undefined;
|
||||
}
|
||||
const { suggestions, dismissedSuggestions } = this._splitSuggestions(
|
||||
this._computeSuggestions(
|
||||
this._statistics,
|
||||
this.preferences,
|
||||
this._states,
|
||||
this.tab
|
||||
),
|
||||
this._currentDismissed
|
||||
);
|
||||
return {
|
||||
suggestions,
|
||||
dismissedSuggestions,
|
||||
showDismissed: this.showDismissed && dismissedSuggestions.length > 0,
|
||||
};
|
||||
}
|
||||
|
||||
protected updated(changedProps: PropertyValues): void {
|
||||
super.updated(changedProps);
|
||||
const count = this._view()?.dismissedSuggestions.length ?? 0;
|
||||
if (count !== this._reportedDismissedCount) {
|
||||
this._reportedDismissedCount = count;
|
||||
fireEvent(this, "energy-suggestions-dismissed-count", { count });
|
||||
}
|
||||
}
|
||||
|
||||
private async _restore(ev: Event) {
|
||||
const suggestion: EnergyMeterSuggestion = (ev.currentTarget as any)
|
||||
.suggestion;
|
||||
const statisticId = suggestion.statisticId;
|
||||
this._pendingRestored = [...this._pendingRestored, statisticId];
|
||||
this._pendingDismissed = this._pendingDismissed.filter(
|
||||
(id) => id !== statisticId
|
||||
);
|
||||
try {
|
||||
await this._saveDismissed((dismissed) =>
|
||||
restoreDismissedSuggestion(dismissed, statisticId)
|
||||
);
|
||||
} catch (err: any) {
|
||||
this._pendingRestored = this._pendingRestored.filter(
|
||||
(id) => id !== statisticId
|
||||
);
|
||||
showAlertDialog(this, {
|
||||
title: this._i18n.localize(
|
||||
"ui.panel.config.energy.suggestions.restore_failed"
|
||||
),
|
||||
text: err.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private _saveDismissed(update: (dismissed: string[]) => string[]) {
|
||||
const save = this._saveQueue.then(() =>
|
||||
saveFrontendUserData(this._connection.connection, "energy", {
|
||||
dismissed_suggestions: update(this._dismissed!),
|
||||
})
|
||||
);
|
||||
this._saveQueue = save.catch(() => undefined);
|
||||
return save;
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return [
|
||||
haStyle,
|
||||
@@ -407,4 +537,8 @@ declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"ha-energy-suggestions": EnergySuggestions;
|
||||
}
|
||||
|
||||
interface HASSDomEvents {
|
||||
"energy-suggestions-dismissed-count": { count: number };
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
import "../../../layouts/hass-error-screen";
|
||||
import {
|
||||
mdiDotsVertical,
|
||||
mdiDownload,
|
||||
mdiEye,
|
||||
mdiEyeOff,
|
||||
mdiFire,
|
||||
mdiLightningBolt,
|
||||
mdiViewDashboardEdit,
|
||||
@@ -10,6 +13,7 @@ import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { cache } from "lit/directives/cache";
|
||||
import type { HASSDomEvent } from "../../../common/dom/fire_event";
|
||||
import { navigate } from "../../../common/navigate";
|
||||
import type {
|
||||
EnergyPreferencesValidation,
|
||||
@@ -38,6 +42,9 @@ import "./components/ha-energy-battery-settings";
|
||||
import "./components/ha-energy-gas-settings";
|
||||
import "./components/ha-energy-water-settings";
|
||||
import "./components/ha-energy-suggestions";
|
||||
import "../../../components/ha-dropdown";
|
||||
import "../../../components/ha-dropdown-item";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import { fileDownload } from "../../../util/file_download";
|
||||
import { showToast } from "../../../util/toast";
|
||||
import type { PageNavigation } from "../../../layouts/hass-tabs-subpage";
|
||||
@@ -98,6 +105,11 @@ class HaConfigEnergy extends LitElement {
|
||||
|
||||
@state() private _statsMetadata?: Record<string, StatisticsMetaData>;
|
||||
|
||||
// Dismissed meters on the current tab, as counted by the suggestions card
|
||||
@state() private _dismissedSuggestions = 0;
|
||||
|
||||
@state() private _showDismissedSuggestions = false;
|
||||
|
||||
private get _currTab(): string {
|
||||
return this.route.path.split("/")[1] || "electricity";
|
||||
}
|
||||
@@ -105,6 +117,10 @@ class HaConfigEnergy extends LitElement {
|
||||
protected willUpdate(changedProperties: PropertyValues<this>) {
|
||||
if (changedProperties.has("route")) {
|
||||
const [, tab, kind, ...key] = this.route.path.split("/");
|
||||
const oldTab = changedProperties.get("route")?.path.split("/")[1];
|
||||
if (oldTab !== undefined && oldTab !== tab) {
|
||||
this._showDismissedSuggestions = false;
|
||||
}
|
||||
if (!tab || !TABS.some((t) => t.path.endsWith(`/${tab}`))) {
|
||||
navigate(`${this.route.prefix}/electricity${location.search}`, {
|
||||
replace: true,
|
||||
@@ -175,6 +191,35 @@ class HaConfigEnergy extends LitElement {
|
||||
)}
|
||||
@click=${this._downloadDiagnostics}
|
||||
></ha-icon-button>
|
||||
${
|
||||
this._dismissedSuggestions
|
||||
? html`<ha-dropdown
|
||||
@wa-select=${this._toggleDismissedSuggestions}
|
||||
>
|
||||
<ha-icon-button
|
||||
slot="trigger"
|
||||
.label=${this.hass.localize("ui.common.menu")}
|
||||
.path=${mdiDotsVertical}
|
||||
></ha-icon-button>
|
||||
<ha-dropdown-item value="toggle_dismissed">
|
||||
<ha-svg-icon
|
||||
slot="icon"
|
||||
.path=${this._showDismissedSuggestions ? mdiEyeOff : mdiEye}
|
||||
></ha-svg-icon>
|
||||
${
|
||||
this._showDismissedSuggestions
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.energy.suggestions.hide_dismissed"
|
||||
)
|
||||
: this.hass.localize(
|
||||
"ui.panel.config.energy.suggestions.show_dismissed",
|
||||
{ count: this._dismissedSuggestions }
|
||||
)
|
||||
}
|
||||
</ha-dropdown-item>
|
||||
</ha-dropdown>`
|
||||
: nothing
|
||||
}
|
||||
</div>
|
||||
<ha-alert>
|
||||
${this.hass.localize("ui.panel.config.energy.new_device_info")}
|
||||
@@ -184,6 +229,8 @@ class HaConfigEnergy extends LitElement {
|
||||
.preferences=${this._preferences!}
|
||||
.listPath=${`${this.route.prefix}/${this._currTab}`}
|
||||
.tab=${this._currTab}
|
||||
.showDismissed=${this._showDismissedSuggestions}
|
||||
@energy-suggestions-dismissed-count=${this._dismissedSuggestionsChanged}
|
||||
></ha-energy-suggestions>
|
||||
${cache(this._renderTabContent())}
|
||||
</div>
|
||||
@@ -446,6 +493,19 @@ class HaConfigEnergy extends LitElement {
|
||||
this._statsMetadata = statsMetadata;
|
||||
}
|
||||
|
||||
private _dismissedSuggestionsChanged(
|
||||
ev: HASSDomEvent<HASSDomEvents["energy-suggestions-dismissed-count"]>
|
||||
) {
|
||||
this._dismissedSuggestions = ev.detail.count;
|
||||
if (!this._dismissedSuggestions) {
|
||||
this._showDismissedSuggestions = false;
|
||||
}
|
||||
}
|
||||
|
||||
private _toggleDismissedSuggestions() {
|
||||
this._showDismissedSuggestions = !this._showDismissedSuggestions;
|
||||
}
|
||||
|
||||
private _customise() {
|
||||
if (!this._preferences) {
|
||||
return;
|
||||
|
||||
+5
-46
@@ -16,12 +16,14 @@ import "../../../../../components/item/ha-list-item-base";
|
||||
import "../../../../../components/item/ha-list-item-button";
|
||||
import "../../../../../components/list/ha-list-base";
|
||||
import type {
|
||||
BluetoothAdapterDevice,
|
||||
BluetoothAllocationsData,
|
||||
BluetoothScannerState,
|
||||
BluetoothScannersDetails,
|
||||
HaScannerType,
|
||||
} from "../../../../../data/bluetooth";
|
||||
import {
|
||||
getBluetoothAdapters,
|
||||
isScannerStateMismatch,
|
||||
subscribeBluetoothConnectionAllocations,
|
||||
subscribeBluetoothScannerState,
|
||||
@@ -176,52 +178,11 @@ export class BluetoothAdapterInfoPage extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private _getBluetoothDevices = memoizeOne(
|
||||
(devices: HomeAssistant["devices"], configEntries: ConfigEntry[]) => {
|
||||
const entryMap = new Map(configEntries.map((e) => [e.entry_id, e]));
|
||||
|
||||
const enabledDevices: {
|
||||
device: DeviceRegistryEntry;
|
||||
entry: ConfigEntry;
|
||||
}[] = [];
|
||||
const disabledDevices: {
|
||||
device: DeviceRegistryEntry;
|
||||
entry: ConfigEntry;
|
||||
}[] = [];
|
||||
const matchedEntryIds = new Set<string>();
|
||||
|
||||
for (const device of Object.values(devices)) {
|
||||
const btConnection = device.connections.find(
|
||||
(c) => c[0] === "bluetooth"
|
||||
);
|
||||
if (!btConnection) {
|
||||
continue;
|
||||
}
|
||||
const entry = device.config_entries
|
||||
.map((id) => entryMap.get(id))
|
||||
.find((e) => e !== undefined);
|
||||
if (!entry) {
|
||||
continue;
|
||||
}
|
||||
matchedEntryIds.add(entry.entry_id);
|
||||
if (entry.disabled_by !== null) {
|
||||
disabledDevices.push({ device, entry });
|
||||
} else {
|
||||
enabledDevices.push({ device, entry });
|
||||
}
|
||||
}
|
||||
|
||||
const disabledEntriesWithoutDevice = configEntries.filter(
|
||||
(e) => e.disabled_by !== null && !matchedEntryIds.has(e.entry_id)
|
||||
);
|
||||
|
||||
return { enabledDevices, disabledDevices, disabledEntriesWithoutDevice };
|
||||
}
|
||||
);
|
||||
private _getBluetoothAdapters = memoizeOne(getBluetoothAdapters);
|
||||
|
||||
protected render(): TemplateResult {
|
||||
const { enabledDevices, disabledDevices, disabledEntriesWithoutDevice } =
|
||||
this._getBluetoothDevices(this.hass.devices, this._configEntries);
|
||||
this._getBluetoothAdapters(this.hass.devices, this._configEntries);
|
||||
|
||||
return html`
|
||||
<hass-subpage
|
||||
@@ -301,9 +262,7 @@ export class BluetoothAdapterInfoPage extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _renderAdaptersList(
|
||||
devices: { device: DeviceRegistryEntry; entry: ConfigEntry }[]
|
||||
) {
|
||||
private _renderAdaptersList(devices: BluetoothAdapterDevice[]) {
|
||||
if (devices.length === 0) {
|
||||
return html`<ha-list-item-base>
|
||||
<div slot="headline">
|
||||
|
||||
+122
-49
@@ -11,18 +11,24 @@ import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import type { CSSResultGroup, TemplateResult } from "lit";
|
||||
import { LitElement, css, html } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import "../../../../../components/animation/ha-fade-in";
|
||||
import "../../../../../components/ha-alert";
|
||||
import "../../../../../components/ha-button";
|
||||
import "../../../../../components/ha-card";
|
||||
import "../../../../../components/ha-icon-next";
|
||||
import "../../../../../components/ha-svg-icon";
|
||||
import "../../../../../components/item/ha-list-item-button";
|
||||
import "../../../../../components/list/ha-list-nav";
|
||||
import "../../../../../components/skeleton/ha-skeleton";
|
||||
import "../../../../../components/skeleton/ha-skeleton-text";
|
||||
import type {
|
||||
BluetoothAllocationsData,
|
||||
BluetoothDeviceData,
|
||||
BluetoothScannerState,
|
||||
} from "../../../../../data/bluetooth";
|
||||
import {
|
||||
getBluetoothAdapters,
|
||||
isScannerStateMismatch,
|
||||
subscribeBluetoothAdvertisements,
|
||||
subscribeBluetoothConnectionAllocations,
|
||||
@@ -34,6 +40,7 @@ import "../../../../../layouts/hass-subpage";
|
||||
import { haStyle } from "../../../../../resources/styles";
|
||||
import type { HomeAssistant, Route } from "../../../../../types";
|
||||
import { brandsUrl } from "../../../../../util/brands-url";
|
||||
import { getWsErrorMessage } from "../../../../../util/ws-error";
|
||||
|
||||
@customElement("bluetooth-config-dashboard")
|
||||
export class BluetoothConfigDashboard extends LitElement {
|
||||
@@ -45,7 +52,9 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
|
||||
@property({ attribute: "is-wide", type: Boolean }) public isWide = false;
|
||||
|
||||
@state() private _configEntries: ConfigEntry[] = [];
|
||||
@state() private _configEntries?: ConfigEntry[];
|
||||
|
||||
@state() private _configEntriesError?: string;
|
||||
|
||||
@state() private _connectionAllocationData: BluetoothAllocationsData[] = [];
|
||||
|
||||
@@ -69,11 +78,17 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private async _loadConfigEntries(): Promise<void> {
|
||||
this._configEntries = await getConfigEntries(this.hass, {
|
||||
domain: "bluetooth",
|
||||
});
|
||||
}
|
||||
private _loadConfigEntries = async (): Promise<void> => {
|
||||
this._configEntriesError = undefined;
|
||||
try {
|
||||
this._configEntries = await getConfigEntries(this.hass, {
|
||||
domain: "bluetooth",
|
||||
});
|
||||
} catch (err: unknown) {
|
||||
this._configEntriesError =
|
||||
getWsErrorMessage(err) || this.hass.localize("ui.common.unknown_error");
|
||||
}
|
||||
};
|
||||
|
||||
private async _subscribeBluetoothConnectionAllocations(): Promise<void> {
|
||||
if (this._unsubConnectionAllocations) {
|
||||
@@ -131,11 +146,17 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private _getBluetoothAdapters = memoizeOne(getBluetoothAdapters);
|
||||
|
||||
protected render(): TemplateResult {
|
||||
const enabledEntries = this._configEntries.filter(
|
||||
(e) => e.disabled_by === null
|
||||
);
|
||||
const adapterCount = enabledEntries.length;
|
||||
// The device registry is null until it has loaded.
|
||||
const adapterCount =
|
||||
this._configEntries && this.hass.devices
|
||||
? this._getBluetoothAdapters(this.hass.devices, this._configEntries)
|
||||
.enabledDevices.length
|
||||
: undefined;
|
||||
const error = this._configEntriesError;
|
||||
const loading = adapterCount === undefined && !error;
|
||||
const totalSlots = this._connectionAllocationData.reduce(
|
||||
(sum, a) => sum + a.slots,
|
||||
0
|
||||
@@ -163,40 +184,67 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
back-path="/config/connectivity"
|
||||
>
|
||||
<div class="container">
|
||||
<ha-card class="content network-status">
|
||||
<div class="card-content">
|
||||
<div class="heading">
|
||||
<div class="icon ${status}">
|
||||
<ha-svg-icon .path=${statusIcon}></ha-svg-icon>
|
||||
</div>
|
||||
<div class="details">
|
||||
${this.hass.localize(
|
||||
`ui.panel.config.bluetooth.status_${status}`
|
||||
)}<br />
|
||||
<small>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.bluetooth.connections_summary",
|
||||
{ used: usedSlots, total: totalSlots }
|
||||
)}
|
||||
</small>
|
||||
</div>
|
||||
<img
|
||||
class="logo"
|
||||
alt="Bluetooth"
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
src=${brandsUrl(
|
||||
{
|
||||
domain: "bluetooth",
|
||||
type: "icon",
|
||||
darkOptimized: this.hass.themes?.darkMode,
|
||||
},
|
||||
this.hass.auth.data.hassUrl
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ha-card>
|
||||
${
|
||||
error
|
||||
? html`<ha-alert alert-type="error" class="content">
|
||||
${error}
|
||||
<ha-button
|
||||
slot="action"
|
||||
appearance="plain"
|
||||
@click=${this._loadConfigEntries}
|
||||
>
|
||||
${this.hass.localize("ui.common.retry")}
|
||||
</ha-button>
|
||||
</ha-alert>`
|
||||
: html`<ha-card class="content network-status">
|
||||
<div class="card-content">
|
||||
<div class="heading">
|
||||
${
|
||||
loading
|
||||
? html`<ha-fade-in .duration=${300} easing="ease-in">
|
||||
<ha-skeleton
|
||||
class="status-icon"
|
||||
role="progressbar"
|
||||
aria-label=${this.hass.localize("ui.common.loading")}
|
||||
></ha-skeleton>
|
||||
</ha-fade-in>`
|
||||
: html`<div class="icon ${status}">
|
||||
<ha-svg-icon .path=${statusIcon}></ha-svg-icon>
|
||||
</div>`
|
||||
}
|
||||
<div class="details">
|
||||
${
|
||||
loading
|
||||
? this._renderTextSkeleton()
|
||||
: this.hass.localize(
|
||||
`ui.panel.config.bluetooth.status_${status}`
|
||||
)
|
||||
}<br />
|
||||
<small>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.bluetooth.connections_summary",
|
||||
{ used: usedSlots, total: totalSlots }
|
||||
)}
|
||||
</small>
|
||||
</div>
|
||||
<img
|
||||
class="logo"
|
||||
alt="Bluetooth"
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
src=${brandsUrl(
|
||||
{
|
||||
domain: "bluetooth",
|
||||
type: "icon",
|
||||
darkOptimized: this.hass.themes?.darkMode,
|
||||
},
|
||||
this.hass.auth.data.hassUrl
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ha-card>`
|
||||
}
|
||||
|
||||
<ha-card class="network-card">
|
||||
<div class="card-header">
|
||||
@@ -224,10 +272,17 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
.path=${mdiAccessPoint}
|
||||
></ha-svg-icon>
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.bluetooth.adapters_count",
|
||||
{ count: adapterCount }
|
||||
)}
|
||||
${
|
||||
// A link needs its name, so no skeleton while loading
|
||||
adapterCount === undefined
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.bluetooth.adapter_info_title"
|
||||
)
|
||||
: this.hass.localize(
|
||||
"ui.panel.config.bluetooth.adapters_count",
|
||||
{ count: adapterCount }
|
||||
)
|
||||
}
|
||||
</div>
|
||||
<ha-icon-next slot="end"></ha-icon-next>
|
||||
</ha-list-item-button>
|
||||
@@ -268,6 +323,15 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _renderTextSkeleton() {
|
||||
return html`<ha-fade-in .duration=${300} easing="ease-in">
|
||||
<ha-skeleton-text
|
||||
role="progressbar"
|
||||
aria-label=${this.hass.localize("ui.common.loading")}
|
||||
></ha-skeleton-text>
|
||||
</ha-fade-in>`;
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return [
|
||||
haStyle,
|
||||
@@ -276,7 +340,9 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
padding: var(--ha-space-2) var(--ha-content-gutter) var(--ha-space-4);
|
||||
}
|
||||
|
||||
ha-card {
|
||||
ha-card,
|
||||
ha-alert {
|
||||
display: block;
|
||||
margin: 0px auto var(--ha-space-4);
|
||||
max-width: var(--ha-content-width-narrow);
|
||||
}
|
||||
@@ -326,6 +392,13 @@ export class BluetoothConfigDashboard extends LitElement {
|
||||
--icon-color: var(--primary-color);
|
||||
}
|
||||
|
||||
.network-status div.heading .status-icon {
|
||||
display: block;
|
||||
width: var(--ha-space-10);
|
||||
height: var(--ha-space-10);
|
||||
--ha-skeleton-border-radius: var(--ha-border-radius-2xl);
|
||||
}
|
||||
|
||||
.network-status div.heading .icon.online {
|
||||
--icon-color: var(--success-color);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { live } from "lit/directives/live";
|
||||
import { consume } from "../../../common/decorators/consume";
|
||||
import {
|
||||
consumeEntityState,
|
||||
@@ -139,7 +140,7 @@ class HuiNumericInputCardFeature
|
||||
return html`
|
||||
<ha-control-number-buttons
|
||||
.label=${label}
|
||||
.value=${value}
|
||||
.value=${live(value)}
|
||||
.min=${stateObj.attributes.min}
|
||||
.max=${stateObj.attributes.max}
|
||||
.step=${stateObj.attributes.step}
|
||||
@@ -153,7 +154,7 @@ class HuiNumericInputCardFeature
|
||||
return html`
|
||||
<ha-control-slider
|
||||
.label=${label}
|
||||
.value=${value}
|
||||
.value=${live(value)}
|
||||
.min=${stateObj.attributes.min}
|
||||
.max=${stateObj.attributes.max}
|
||||
.step=${stateObj.attributes.step}
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { styleMap } from "lit/directives/style-map";
|
||||
import { consume } from "../../../common/decorators/consume";
|
||||
import durationToSeconds from "../../../common/datetime/duration_to_seconds";
|
||||
import { consumeEntityState } from "../../../common/decorators/consume-context-entry";
|
||||
import { computeDomain } from "../../../common/entity/compute_domain";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import type { LovelaceCardFeature } from "../types";
|
||||
import { cardFeatureStyles } from "./common/card-feature-styles";
|
||||
import type {
|
||||
LovelaceCardFeatureContext,
|
||||
TimerProgressCardFeatureConfig,
|
||||
} from "./types";
|
||||
import { TimerRemainingTimeController } from "../../../common/controllers/timer-remaining-time-controller";
|
||||
import { reducedMotionContext } from "../../../data/context";
|
||||
|
||||
export const supportsTimerProgressCardFeature = (
|
||||
hass: HomeAssistant,
|
||||
context: LovelaceCardFeatureContext
|
||||
) => {
|
||||
const stateObj = context.entity_id
|
||||
? hass.states[context.entity_id]
|
||||
: undefined;
|
||||
return !!stateObj && computeDomain(stateObj.entity_id) === "timer";
|
||||
};
|
||||
|
||||
@customElement("hui-timer-progress-card-feature")
|
||||
class HuiTimerProgressCardFeature
|
||||
extends LitElement
|
||||
implements LovelaceCardFeature
|
||||
{
|
||||
@property({ attribute: false }) public context?: LovelaceCardFeatureContext;
|
||||
|
||||
@state()
|
||||
@consumeEntityState({ entityIdPath: ["context", "entity_id"] })
|
||||
private _stateObj?: HassEntity;
|
||||
|
||||
@state()
|
||||
@consume({ context: reducedMotionContext, subscribe: true })
|
||||
private _reducedMotion = false;
|
||||
|
||||
@state() private _config?: TimerProgressCardFeatureConfig;
|
||||
private _timeRemaining = new TimerRemainingTimeController(this);
|
||||
private _prevRatio = 0;
|
||||
private _animate = false;
|
||||
|
||||
static getStubConfig(): TimerProgressCardFeatureConfig {
|
||||
return { type: "timer-progress" };
|
||||
}
|
||||
|
||||
public setConfig(config: TimerProgressCardFeatureConfig): void {
|
||||
if (!config) {
|
||||
throw new Error("Invalid configuration");
|
||||
}
|
||||
this._config = config;
|
||||
}
|
||||
|
||||
protected update(changedProps: PropertyValues): void {
|
||||
if (changedProps.has("_stateObj")) {
|
||||
this._timeRemaining.setStateObj(this._stateObj);
|
||||
}
|
||||
if (this._stateObj) {
|
||||
const ratio = this._ratio(this._stateObj);
|
||||
this._animate =
|
||||
!this._reducedMotion &&
|
||||
this._stateObj.state === "active" &&
|
||||
ratio <= this._prevRatio;
|
||||
this._prevRatio = ratio;
|
||||
}
|
||||
super.update(changedProps);
|
||||
}
|
||||
|
||||
private _ratio(stateObj: HassEntity, offset = 0): number {
|
||||
const { duration } = stateObj.attributes;
|
||||
const total =
|
||||
typeof duration === "string" ? durationToSeconds(duration) : 0;
|
||||
if (!total || stateObj.state === "idle") {
|
||||
return 0;
|
||||
}
|
||||
const left = (this._timeRemaining.timeRemaining ?? 0) - offset;
|
||||
return Math.min(Math.max(left / total, 0), 1);
|
||||
}
|
||||
|
||||
protected render() {
|
||||
if (
|
||||
!this._config ||
|
||||
!this.context ||
|
||||
!this._stateObj ||
|
||||
computeDomain(this._stateObj.entity_id) !== "timer"
|
||||
) {
|
||||
return nothing;
|
||||
}
|
||||
const stateObj = this._stateObj;
|
||||
const ratio = this._ratio(stateObj);
|
||||
const target = this._animate ? this._ratio(stateObj, 1) : ratio;
|
||||
return html`
|
||||
<div
|
||||
class="track"
|
||||
role="progressbar"
|
||||
aria-label=${stateObj.attributes.friendly_name || stateObj.entity_id}
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100"
|
||||
aria-valuenow=${Math.round(ratio * 100)}
|
||||
>
|
||||
<div
|
||||
class="bar"
|
||||
style=${styleMap({
|
||||
transform: `scaleX(${target})`,
|
||||
transition: this._animate ? "transform 1s linear" : "none",
|
||||
})}
|
||||
></div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
static styles = [
|
||||
cardFeatureStyles,
|
||||
css`
|
||||
:host {
|
||||
pointer-events: none !important;
|
||||
}
|
||||
.track {
|
||||
height: var(--feature-height);
|
||||
border-radius: var(--feature-border-radius);
|
||||
background: color-mix(in srgb, var(--feature-color) 20%, transparent);
|
||||
overflow: hidden;
|
||||
}
|
||||
.bar {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
transform-origin: var(--float-start, left);
|
||||
background: var(--feature-color);
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"hui-timer-progress-card-feature": HuiTimerProgressCardFeature;
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import { supportsTargetHumidityCardFeature } from "./hui-target-humidity-card-fe
|
||||
import { supportsTargetTemperatureCardFeature } from "./hui-target-temperature-card-feature";
|
||||
import { supportsTimerActionsCardFeature } from "./hui-timer-actions-card-feature";
|
||||
import { supportsTimerPresetsCardFeature } from "./hui-timer-presets-card-feature";
|
||||
import { supportsTimerProgressCardFeature } from "./hui-timer-progress-card-feature";
|
||||
import { supportsToggleCardFeature } from "./hui-toggle-card-feature";
|
||||
import { supportsTrendGraphCardFeature } from "./hui-trend-graph-card-feature";
|
||||
import { supportsUpdateActionsCardFeature } from "./hui-update-actions-card-feature";
|
||||
@@ -110,6 +111,7 @@ export const UI_FEATURE_TYPES = [
|
||||
"target-temperature",
|
||||
"timer-actions",
|
||||
"timer-presets",
|
||||
"timer-progress",
|
||||
"toggle",
|
||||
"update-actions",
|
||||
"vacuum-commands",
|
||||
@@ -169,6 +171,7 @@ export const SUPPORTS_FEATURE_TYPES: Record<UiFeatureType, SupportsFeature> = {
|
||||
"temperature-forecast": supportsTemperatureForecastCardFeature,
|
||||
"timer-actions": supportsTimerActionsCardFeature,
|
||||
"timer-presets": supportsTimerPresetsCardFeature,
|
||||
"timer-progress": supportsTimerProgressCardFeature,
|
||||
toggle: supportsToggleCardFeature,
|
||||
"update-actions": supportsUpdateActionsCardFeature,
|
||||
"vacuum-commands": supportsVacuumCommandsCardFeature,
|
||||
|
||||
@@ -237,6 +237,10 @@ export interface TimerPresetsCardFeatureConfig {
|
||||
style?: "buttons" | "dropdown";
|
||||
}
|
||||
|
||||
export interface TimerProgressCardFeatureConfig {
|
||||
type: "timer-progress";
|
||||
}
|
||||
|
||||
export interface WaterHeaterOperationModesCardFeatureConfig {
|
||||
type: "water-heater-operation-modes";
|
||||
style?: "dropdown" | "icons";
|
||||
@@ -406,6 +410,7 @@ export type LovelaceCardFeatureConfig =
|
||||
| TargetTemperatureCardFeatureConfig
|
||||
| TimerActionsCardFeatureConfig
|
||||
| TimerPresetsCardFeatureConfig
|
||||
| TimerProgressCardFeatureConfig
|
||||
| ToggleCardFeatureConfig
|
||||
| UpdateActionsCardFeatureConfig
|
||||
| VacuumCommandsCardFeatureConfig
|
||||
|
||||
@@ -84,7 +84,7 @@ const DOMAIN_VARIANTS: Record<string, TileVariant[]> = {
|
||||
],
|
||||
alarm_control_panel: [TILE_VARIANT, ["alarm-modes"]],
|
||||
counter: [TILE_VARIANT, ["counter-actions"]],
|
||||
timer: [TILE_VARIANT, ["timer-actions"]],
|
||||
timer: [TILE_VARIANT, ["timer-actions"], ["timer-progress"]],
|
||||
input_select: SELECT_VARIANTS,
|
||||
select: SELECT_VARIANTS,
|
||||
input_number: NUMERIC_INPUT_VARIANTS,
|
||||
|
||||
@@ -38,6 +38,7 @@ import "../card-features/hui-target-humidity-card-feature";
|
||||
import "../card-features/hui-target-temperature-card-feature";
|
||||
import "../card-features/hui-timer-actions-card-feature";
|
||||
import "../card-features/hui-timer-presets-card-feature";
|
||||
import "../card-features/hui-timer-progress-card-feature";
|
||||
import "../card-features/hui-toggle-card-feature";
|
||||
import "../card-features/hui-update-actions-card-feature";
|
||||
import "../card-features/hui-vacuum-commands-card-feature";
|
||||
@@ -104,6 +105,7 @@ const TYPES = new Set<LovelaceCardFeatureConfig["type"]>([
|
||||
"temperature-forecast",
|
||||
"timer-actions",
|
||||
"timer-presets",
|
||||
"timer-progress",
|
||||
"toggle",
|
||||
"update-actions",
|
||||
"vacuum-commands",
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { mdiClose, mdiHelpCircleOutline } from "@mdi/js";
|
||||
import {
|
||||
mdiClose,
|
||||
mdiFullscreen,
|
||||
mdiFullscreenExit,
|
||||
mdiHelpCircleOutline,
|
||||
} from "@mdi/js";
|
||||
import deepFreeze from "deep-freeze";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
@@ -68,6 +73,8 @@ export class HuiDialogEditBadge
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
@state() private _animateWidth = false;
|
||||
|
||||
@state() private _badgeConfig?: LovelaceBadgeConfig;
|
||||
|
||||
@state() private _saving = false;
|
||||
@@ -195,6 +202,8 @@ export class HuiDialogEditBadge
|
||||
.open=${this._open}
|
||||
.accessibleLabel=${heading}
|
||||
.width=${this.large ? "full" : "large"}
|
||||
class=${this._animateWidth ? "animate-width" : ""}
|
||||
@dialog-set-fullscreen=${this._stopWidthAnimation}
|
||||
.preventScrimClose=${this.isEffectiveDirtyState}
|
||||
@keydown=${this._ignoreKeydown}
|
||||
@closed=${this._dialogClosed}
|
||||
@@ -205,12 +214,18 @@ export class HuiDialogEditBadge
|
||||
.label=${this.hass.localize("ui.common.close")}
|
||||
.path=${mdiClose}
|
||||
></ha-icon-button>
|
||||
<span
|
||||
slot="headerTitle"
|
||||
class="title-enlargeable"
|
||||
@click=${this._enlarge}
|
||||
>${heading}</span
|
||||
>
|
||||
<span slot="headerTitle">${heading}</span>
|
||||
<ha-icon-button
|
||||
slot="headerActionItems"
|
||||
class="enlarge"
|
||||
.path=${this.large ? mdiFullscreenExit : mdiFullscreen}
|
||||
.label=${this.hass.localize(
|
||||
this.large
|
||||
? "ui.panel.lovelace.editor.edit_badge.shrink"
|
||||
: "ui.panel.lovelace.editor.edit_badge.enlarge"
|
||||
)}
|
||||
@click=${this._toggleLarge}
|
||||
></ha-icon-button>
|
||||
${
|
||||
this._documentationURL !== undefined
|
||||
? html`
|
||||
@@ -304,10 +319,14 @@ export class HuiDialogEditBadge
|
||||
`;
|
||||
}
|
||||
|
||||
private _enlarge() {
|
||||
withViewTransition(() => {
|
||||
this.large = !this.large;
|
||||
});
|
||||
private _toggleLarge() {
|
||||
this._animateWidth = true;
|
||||
this.large = !this.large;
|
||||
}
|
||||
|
||||
// The code editor's fullscreen changes the height at once, so the width must not lag behind
|
||||
private _stopWidthAnimation() {
|
||||
this._animateWidth = false;
|
||||
}
|
||||
|
||||
private _ignoreKeydown(ev: KeyboardEvent) {
|
||||
@@ -494,8 +513,18 @@ export class HuiDialogEditBadge
|
||||
ha-dialog ha-icon-button[slot="headerActionItems"] {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
.title-enlargeable {
|
||||
display: block;
|
||||
ha-dialog.animate-width {
|
||||
--ha-dialog-width-transition:
|
||||
min-width var(--ha-animation-duration-normal) ease-out,
|
||||
max-width var(--ha-animation-duration-normal) ease-out;
|
||||
}
|
||||
ha-dialog[fullscreen] .enlarge {
|
||||
display: none;
|
||||
}
|
||||
@media (max-width: 999px) {
|
||||
.enlarge {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
@@ -504,7 +504,7 @@ export class HaGridLayoutSlider extends LitElement {
|
||||
left 180ms ease-in-out,
|
||||
bottom 180ms ease-in-out;
|
||||
--handle-spacing: calc(2 * var(--handle-margin) + var(--handle-size));
|
||||
--slider-tooltip-margin: 0px;
|
||||
--slider-tooltip-margin: var(--ha-space-1);
|
||||
--slider-tooltip-range: 100%;
|
||||
--slider-tooltip-offset: 0px;
|
||||
--slider-tooltip-position: calc(
|
||||
|
||||
@@ -420,7 +420,7 @@ export class HuiCardLayoutEditor extends LitElement {
|
||||
}
|
||||
ha-grid-size-picker {
|
||||
display: block;
|
||||
margin: 16px auto;
|
||||
margin: var(--ha-space-4) auto;
|
||||
direction: ltr;
|
||||
}
|
||||
`,
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { mdiClose, mdiHelpCircleOutline } from "@mdi/js";
|
||||
import {
|
||||
mdiClose,
|
||||
mdiFullscreen,
|
||||
mdiFullscreenExit,
|
||||
mdiHelpCircleOutline,
|
||||
} from "@mdi/js";
|
||||
import deepFreeze from "deep-freeze";
|
||||
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
@@ -76,6 +81,8 @@ export class HuiDialogEditCard
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
@state() private _animateWidth = false;
|
||||
|
||||
@state() private _cardConfig?: LovelaceCardConfig;
|
||||
|
||||
@state() private _sectionConfig?: LovelaceSectionConfig;
|
||||
@@ -207,6 +214,8 @@ export class HuiDialogEditCard
|
||||
.open=${this._open}
|
||||
.accessibleLabel=${heading}
|
||||
.width=${this.large ? "full" : "large"}
|
||||
class=${this._animateWidth ? "animate-width" : ""}
|
||||
@dialog-set-fullscreen=${this._stopWidthAnimation}
|
||||
.preventScrimClose=${this.isEffectiveDirtyState}
|
||||
@keydown=${this._ignoreKeydown}
|
||||
@closed=${this._dialogClosed}
|
||||
@@ -217,12 +226,18 @@ export class HuiDialogEditCard
|
||||
.label=${this.hass.localize("ui.common.close")}
|
||||
.path=${mdiClose}
|
||||
></ha-icon-button>
|
||||
<span
|
||||
slot="headerTitle"
|
||||
class="title-enlargeable"
|
||||
@click=${this._enlarge}
|
||||
>${heading}</span
|
||||
>
|
||||
<span slot="headerTitle">${heading}</span>
|
||||
<ha-icon-button
|
||||
slot="headerActionItems"
|
||||
class="enlarge"
|
||||
.path=${this.large ? mdiFullscreenExit : mdiFullscreen}
|
||||
.label=${this.hass.localize(
|
||||
this.large
|
||||
? "ui.panel.lovelace.editor.edit_card.shrink"
|
||||
: "ui.panel.lovelace.editor.edit_card.enlarge"
|
||||
)}
|
||||
@click=${this._toggleLarge}
|
||||
></ha-icon-button>
|
||||
${
|
||||
this._documentationURL !== undefined
|
||||
? html`
|
||||
@@ -330,10 +345,14 @@ export class HuiDialogEditCard
|
||||
`;
|
||||
}
|
||||
|
||||
private _enlarge() {
|
||||
withViewTransition(() => {
|
||||
this.large = !this.large;
|
||||
});
|
||||
private _toggleLarge() {
|
||||
this._animateWidth = true;
|
||||
this.large = !this.large;
|
||||
}
|
||||
|
||||
// The code editor's fullscreen changes the height at once, so the width must not lag behind
|
||||
private _stopWidthAnimation() {
|
||||
this._animateWidth = false;
|
||||
}
|
||||
|
||||
private _ignoreKeydown(ev: KeyboardEvent) {
|
||||
@@ -576,8 +595,18 @@ export class HuiDialogEditCard
|
||||
ha-dialog ha-icon-button[slot="headerActionItems"] {
|
||||
color: var(--secondary-text-color);
|
||||
}
|
||||
.title-enlargeable {
|
||||
display: block;
|
||||
ha-dialog.animate-width {
|
||||
--ha-dialog-width-transition:
|
||||
min-width var(--ha-animation-duration-normal) ease-out,
|
||||
max-width var(--ha-animation-duration-normal) ease-out;
|
||||
}
|
||||
ha-dialog[fullscreen] .enlarge {
|
||||
display: none;
|
||||
}
|
||||
@media (max-width: 999px) {
|
||||
.enlarge {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
`,
|
||||
];
|
||||
|
||||
@@ -67,6 +67,7 @@ import { supportsTargetHumidityCardFeature } from "../../card-features/hui-targe
|
||||
import { supportsTargetTemperatureCardFeature } from "../../card-features/hui-target-temperature-card-feature";
|
||||
import { supportsTimerActionsCardFeature } from "../../card-features/hui-timer-actions-card-feature";
|
||||
import { supportsTimerPresetsCardFeature } from "../../card-features/hui-timer-presets-card-feature";
|
||||
import { supportsTimerProgressCardFeature } from "../../card-features/hui-timer-progress-card-feature";
|
||||
import { supportsToggleCardFeature } from "../../card-features/hui-toggle-card-feature";
|
||||
import { supportsTrendGraphCardFeature } from "../../card-features/hui-trend-graph-card-feature";
|
||||
import { supportsUpdateActionsCardFeature } from "../../card-features/hui-update-actions-card-feature";
|
||||
@@ -136,6 +137,7 @@ const UI_FEATURE_TYPES = [
|
||||
"temperature-forecast",
|
||||
"timer-actions",
|
||||
"timer-presets",
|
||||
"timer-progress",
|
||||
"toggle",
|
||||
"update-actions",
|
||||
"vacuum-commands",
|
||||
@@ -239,6 +241,7 @@ const SUPPORTS_FEATURE_TYPES: Record<
|
||||
"temperature-forecast": supportsTemperatureForecastCardFeature,
|
||||
"timer-actions": supportsTimerActionsCardFeature,
|
||||
"timer-presets": supportsTimerPresetsCardFeature,
|
||||
"timer-progress": supportsTimerProgressCardFeature,
|
||||
toggle: supportsToggleCardFeature,
|
||||
"update-actions": supportsUpdateActionsCardFeature,
|
||||
"vacuum-commands": supportsVacuumCommandsCardFeature,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { live } from "lit/directives/live";
|
||||
import { debounce } from "../../../common/util/debounce";
|
||||
import "../../../components/ha-slider";
|
||||
import "../../../components/input/ha-input";
|
||||
@@ -88,7 +89,7 @@ class HuiNumberEntityRow extends LitElement implements LovelaceRow {
|
||||
.step=${Number(stateObj.attributes.step)}
|
||||
.min=${Number(stateObj.attributes.min)}
|
||||
.max=${Number(stateObj.attributes.max)}
|
||||
.value=${Number(stateObj.state)}
|
||||
.value=${live(Number(stateObj.state))}
|
||||
@change=${this._selectedValueChanged}
|
||||
></ha-slider>
|
||||
<span class="state">
|
||||
@@ -111,7 +112,7 @@ class HuiNumberEntityRow extends LitElement implements LovelaceRow {
|
||||
.step=${Number(stateObj.attributes.step)}
|
||||
.min=${Number(stateObj.attributes.min)}
|
||||
.max=${Number(stateObj.attributes.max)}
|
||||
.value=${Number(stateObj.state).toString()}
|
||||
.value=${live(Number(stateObj.state).toString())}
|
||||
type="number"
|
||||
@change=${this._selectedValueChanged}
|
||||
>
|
||||
|
||||
@@ -138,10 +138,13 @@ export const statusesOfTab = (
|
||||
tab === "installed" ? INSTALLED_STATUS_ORDER : STATUS_ORDER;
|
||||
|
||||
// The filters are kept for every tab. A status picked on another tab that this
|
||||
// one can't list is left out here, instead of leaving the table empty.
|
||||
// one can't list is left out here, instead of leaving the table empty. So is
|
||||
// an integration category nothing on this tab is in, when the ones it lists
|
||||
// are given. Before the repositories load it lists none, so the URL keeps them.
|
||||
export const filtersOfTab = (
|
||||
filters: RepositoryFilters,
|
||||
tab: MarketplaceTab
|
||||
tab: MarketplaceTab,
|
||||
integrationCategories?: readonly string[]
|
||||
): RepositoryFilters => {
|
||||
const statuses: readonly string[] = statusesOfTab(tab);
|
||||
|
||||
@@ -150,25 +153,31 @@ export const filtersOfTab = (
|
||||
[STATUS_FILTER]: filters[STATUS_FILTER]?.filter((status) =>
|
||||
statuses.includes(status)
|
||||
),
|
||||
[INTEGRATION_CATEGORY_FILTER]: integrationCategories
|
||||
? filters[INTEGRATION_CATEGORY_FILTER]?.filter((slug) =>
|
||||
integrationCategories.includes(slug)
|
||||
)
|
||||
: filters[INTEGRATION_CATEGORY_FILTER],
|
||||
};
|
||||
};
|
||||
|
||||
// The status pane only sends what this tab lists, so statuses picked on another
|
||||
// tab that this one can't list are kept for when that tab is opened again
|
||||
// A pane only sends what it lists, so what was picked on another tab that this
|
||||
// one can't list is kept for when that tab is opened again
|
||||
export const paneFilterOfTab = (
|
||||
previous: string[] | undefined,
|
||||
listed: readonly string[],
|
||||
picked: string[] = []
|
||||
): string[] => [
|
||||
...(previous?.filter((value) => !listed.includes(value)) ?? []),
|
||||
...picked,
|
||||
];
|
||||
|
||||
export const statusFilterOfTab = (
|
||||
filters: RepositoryFilters,
|
||||
tab: MarketplaceTab,
|
||||
picked: string[] = []
|
||||
): string[] => {
|
||||
const statuses: readonly string[] = statusesOfTab(tab);
|
||||
|
||||
return [
|
||||
...(filters[STATUS_FILTER]?.filter(
|
||||
(status) => !statuses.includes(status)
|
||||
) ?? []),
|
||||
...picked,
|
||||
];
|
||||
};
|
||||
picked?: string[]
|
||||
): string[] =>
|
||||
paneFilterOfTab(filters[STATUS_FILTER], statusesOfTab(tab), picked);
|
||||
|
||||
const matchesFilters = (
|
||||
repository: RepositoryBase,
|
||||
|
||||
@@ -100,6 +100,7 @@ import {
|
||||
filterRepositories,
|
||||
filtersOfTab,
|
||||
marketplaceUpdateEntityIds,
|
||||
paneFilterOfTab,
|
||||
skippedUpdateRepositories,
|
||||
SOURCE_FILTER,
|
||||
SOURCE_ORDER,
|
||||
@@ -345,15 +346,7 @@ export class HaMarketplaceDashboard extends LitElement {
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
const marketplaceRepositories = this._applySkippedUpdates(
|
||||
this.marketplace.repositories,
|
||||
this._skippedUpdateRepositories(
|
||||
this._marketplaceUpdateEntityIds,
|
||||
this._entities,
|
||||
this._devices,
|
||||
this._states ?? {}
|
||||
)
|
||||
);
|
||||
const marketplaceRepositories = this._marketplaceRepositories();
|
||||
const tabs = this._tabs(
|
||||
this._i18n.localize,
|
||||
marketplaceRepositories.filter((repository) => repository.pending_upgrade)
|
||||
@@ -374,19 +367,22 @@ export class HaMarketplaceDashboard extends LitElement {
|
||||
</hass-tabs-subpage>`;
|
||||
}
|
||||
|
||||
const filters = this._filtersOfTab(this._filters, this.tab);
|
||||
const tabRepositories = this._repositoriesOfTab(
|
||||
marketplaceRepositories,
|
||||
this.tab
|
||||
);
|
||||
const integrationCategoryStates = this._tabIntegrationCategoryStates();
|
||||
const filters = this._filtersOfTab(
|
||||
this._filters,
|
||||
this.tab,
|
||||
this._stateValues(integrationCategoryStates)
|
||||
);
|
||||
const repositories = this._filterRepositories(
|
||||
this._repositoriesOfTab(marketplaceRepositories, this.tab),
|
||||
tabRepositories,
|
||||
this._i18n.localize,
|
||||
filters
|
||||
);
|
||||
|
||||
const integrationCategoryStates = this._integrationCategoryStates(
|
||||
this.marketplace.repositories,
|
||||
this._i18n.localize,
|
||||
this._integrationCategoryIcons
|
||||
);
|
||||
|
||||
return html`<hass-tabs-subpage-data-table
|
||||
.tabs=${tabs}
|
||||
.columns=${this._columns(
|
||||
@@ -506,7 +502,7 @@ export class HaMarketplaceDashboard extends LitElement {
|
||||
.label=${this._i18n.localize(
|
||||
"ui.panel.marketplace.filters.integration_category"
|
||||
)}
|
||||
.value=${this._filters[INTEGRATION_CATEGORY_FILTER]}
|
||||
.value=${filters[INTEGRATION_CATEGORY_FILTER]}
|
||||
.states=${integrationCategoryStates}
|
||||
.narrow=${this.narrow}
|
||||
@data-table-filter-changed=${this._integrationCategoryFilterChanged}
|
||||
@@ -591,6 +587,18 @@ export class HaMarketplaceDashboard extends LitElement {
|
||||
|
||||
private _tabs = memoize(marketplaceTabs);
|
||||
|
||||
private _marketplaceRepositories(): MarketplaceRepository[] {
|
||||
return this._applySkippedUpdates(
|
||||
this.marketplace.repositories,
|
||||
this._skippedUpdateRepositories(
|
||||
this._marketplaceUpdateEntityIds,
|
||||
this._entities,
|
||||
this._devices,
|
||||
this._states ?? {}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private _repositoriesOfTab = memoize(repositoriesOfTab);
|
||||
|
||||
private _skippedUpdateRepositories = memoize(skippedUpdateRepositories);
|
||||
@@ -607,6 +615,10 @@ export class HaMarketplaceDashboard extends LitElement {
|
||||
|
||||
private _filtersOfTab = memoize(filtersOfTab);
|
||||
|
||||
private _stateValues = memoize((options: { value: string }[]) =>
|
||||
options.map((option) => option.value)
|
||||
);
|
||||
|
||||
private _columns = memoize(
|
||||
(
|
||||
localizeFunc: LocalizeFunc,
|
||||
@@ -1123,6 +1135,14 @@ export class HaMarketplaceDashboard extends LitElement {
|
||||
}
|
||||
);
|
||||
|
||||
private _tabIntegrationCategoryStates() {
|
||||
return this._integrationCategoryStates(
|
||||
this._repositoriesOfTab(this._marketplaceRepositories(), this.tab),
|
||||
this._i18n.localize,
|
||||
this._integrationCategoryIcons
|
||||
);
|
||||
}
|
||||
|
||||
private _sourceStates = memoize((localize: LocalizeFunc) =>
|
||||
SOURCE_ORDER.map((source) => ({
|
||||
value: source,
|
||||
@@ -1219,15 +1239,24 @@ export class HaMarketplaceDashboard extends LitElement {
|
||||
private _integrationCategoryFilterChanged(
|
||||
ev: CustomEvent<{ value: string[] }>
|
||||
) {
|
||||
const listed = this._stateValues(this._tabIntegrationCategoryStates());
|
||||
const filters = {
|
||||
...this._filters,
|
||||
[INTEGRATION_CATEGORY_FILTER]: ev.detail.value,
|
||||
[INTEGRATION_CATEGORY_FILTER]: paneFilterOfTab(
|
||||
this._filters[INTEGRATION_CATEGORY_FILTER],
|
||||
listed,
|
||||
ev.detail.value
|
||||
),
|
||||
};
|
||||
|
||||
if (this._isUserChange(filters)) {
|
||||
this._storageFilters = {
|
||||
...this._storageFilters,
|
||||
[INTEGRATION_CATEGORY_FILTER]: ev.detail.value,
|
||||
[INTEGRATION_CATEGORY_FILTER]: paneFilterOfTab(
|
||||
this._storageFilters[INTEGRATION_CATEGORY_FILTER],
|
||||
listed,
|
||||
ev.detail.value
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -197,13 +197,12 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
|
||||
|
||||
private _settingPreReleases = new Set<string>();
|
||||
|
||||
private _loadingIntegrationCategoryIcons = false;
|
||||
|
||||
protected async firstUpdated(
|
||||
changedProperties: PropertyValues<this>
|
||||
): Promise<void> {
|
||||
super.firstUpdated(changedProperties);
|
||||
getIntegrationCategoryIcons(this._connection.connection).then((icons) => {
|
||||
this._integrationCategoryIcons = icons;
|
||||
});
|
||||
await this._loadRepository();
|
||||
}
|
||||
|
||||
@@ -324,24 +323,29 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
|
||||
this._fetchRepository(existing.id);
|
||||
}
|
||||
|
||||
protected willUpdate(changedProps: PropertyValues<this>): void {
|
||||
protected willUpdate(changedProps: PropertyValues): void {
|
||||
super.willUpdate(changedProps);
|
||||
|
||||
// The router reuses this element when going from one repository to
|
||||
// another, the first one is loaded by firstUpdated.
|
||||
const previousRoute = changedProps.get("route");
|
||||
const previousRoute = changedProps.get("route") as Route | undefined;
|
||||
if (
|
||||
!this.hasUpdated ||
|
||||
!previousRoute ||
|
||||
repositoryIdFromRoute(previousRoute) === repositoryIdFromRoute(this.route)
|
||||
this.hasUpdated &&
|
||||
previousRoute &&
|
||||
repositoryIdFromRoute(previousRoute) !== repositoryIdFromRoute(this.route)
|
||||
) {
|
||||
return;
|
||||
this._repository = undefined;
|
||||
this._error = undefined;
|
||||
this._refreshError = undefined;
|
||||
this._loadRepositoryFromRoute();
|
||||
}
|
||||
|
||||
this._repository = undefined;
|
||||
this._error = undefined;
|
||||
this._refreshError = undefined;
|
||||
this._loadRepositoryFromRoute();
|
||||
if (
|
||||
changedProps.has("_repository") &&
|
||||
this._repository?.integration_categories?.length
|
||||
) {
|
||||
this._loadIntegrationCategoryIcons();
|
||||
}
|
||||
}
|
||||
|
||||
protected updated(changedProps: PropertyValues<this>): void {
|
||||
@@ -396,6 +400,24 @@ export class HaMarketplaceRepositoryDashboard extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
// Only integrations have categories, other repositories don't need them
|
||||
private async _loadIntegrationCategoryIcons(): Promise<void> {
|
||||
if (
|
||||
this._integrationCategoryIcons ||
|
||||
this._loadingIntegrationCategoryIcons
|
||||
) {
|
||||
return;
|
||||
}
|
||||
this._loadingIntegrationCategoryIcons = true;
|
||||
try {
|
||||
this._integrationCategoryIcons = await getIntegrationCategoryIcons(
|
||||
this._connection.connection
|
||||
);
|
||||
} finally {
|
||||
this._loadingIntegrationCategoryIcons = false;
|
||||
}
|
||||
}
|
||||
|
||||
private _loadRepositoryFromRoute(): void {
|
||||
const repositoryId = repositoryIdFromRoute(this.route);
|
||||
if (!repositoryId) {
|
||||
|
||||
@@ -27,7 +27,6 @@ import {
|
||||
coverCurrentValue,
|
||||
coverHasTiltControls,
|
||||
coverModeAttribute,
|
||||
coverSupportsPosition,
|
||||
coverSupportsSetValue,
|
||||
coverSupportsTiltPosition,
|
||||
coverTiltOpenness,
|
||||
@@ -78,6 +77,17 @@ const pillHandle = (cx: number, cy: number, vertical: boolean) =>
|
||||
const swipeResistance = (distance: number) =>
|
||||
SWIPE_RESISTANCE * (1 - Math.exp(-Math.max(0, distance) / 30));
|
||||
|
||||
const OPEN_CLOSE_FEATURES: Record<
|
||||
CoverControlMode,
|
||||
Record<CoverSwipe["action"], CoverEntityFeature>
|
||||
> = {
|
||||
position: { open: CoverEntityFeature.OPEN, close: CoverEntityFeature.CLOSE },
|
||||
tilt: {
|
||||
open: CoverEntityFeature.OPEN_TILT,
|
||||
close: CoverEntityFeature.CLOSE_TILT,
|
||||
},
|
||||
};
|
||||
|
||||
const modeSprings = (): ModeSprings => ({
|
||||
position: new PercentSpring(),
|
||||
tilt: new PercentSpring(),
|
||||
@@ -190,11 +200,11 @@ export class HaStateControlCover extends LitElement {
|
||||
}
|
||||
|
||||
private get _openCloseOnly(): boolean {
|
||||
const features = OPEN_CLOSE_FEATURES[this.mode];
|
||||
return (
|
||||
this.mode === "position" &&
|
||||
!coverSupportsPosition(this.stateObj) &&
|
||||
(supportsFeature(this.stateObj, CoverEntityFeature.OPEN) ||
|
||||
supportsFeature(this.stateObj, CoverEntityFeature.CLOSE))
|
||||
!this._canSetValue &&
|
||||
(supportsFeature(this.stateObj, features.open) ||
|
||||
supportsFeature(this.stateObj, features.close))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -208,7 +218,9 @@ export class HaStateControlCover extends LitElement {
|
||||
private get _interactive(): boolean {
|
||||
return (
|
||||
this.stateObj.state !== UNAVAILABLE &&
|
||||
(this._canSetValue || (this._openCloseOnly && !this._valueUnknown))
|
||||
(this._canSetValue ||
|
||||
(this._openCloseOnly &&
|
||||
coverCurrentValue(this.stateObj, this.mode) !== undefined))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -412,11 +424,7 @@ export class HaStateControlCover extends LitElement {
|
||||
}
|
||||
|
||||
private _swipeAction(): CoverSwipe["action"] {
|
||||
const end =
|
||||
this.request?.mode === "position"
|
||||
? this.request.value
|
||||
: this._drawingGoal("position");
|
||||
return end >= 50 ? "close" : "open";
|
||||
return this._handleGoal(this.mode) >= 50 ? "close" : "open";
|
||||
}
|
||||
|
||||
private _startSwipe(
|
||||
@@ -424,14 +432,10 @@ export class HaStateControlCover extends LitElement {
|
||||
shape: CoverShape,
|
||||
startPointer: number
|
||||
) {
|
||||
const mode = this.mode;
|
||||
const action = this._swipeAction();
|
||||
const closing = action === "close";
|
||||
if (
|
||||
!supportsFeature(
|
||||
this.stateObj,
|
||||
closing ? CoverEntityFeature.CLOSE : CoverEntityFeature.OPEN
|
||||
)
|
||||
) {
|
||||
if (!supportsFeature(this.stateObj, OPEN_CLOSE_FEATURES[mode][action])) {
|
||||
return;
|
||||
}
|
||||
const direction = closing ? -1 : 1;
|
||||
@@ -462,13 +466,13 @@ export class HaStateControlCover extends LitElement {
|
||||
const passedHalfway = Boolean(this._drag?.swipe?.passedHalfway);
|
||||
this._setDrag(undefined);
|
||||
if (passedHalfway) {
|
||||
fireEvent(this, "cover-command", { mode: "position", action });
|
||||
fireEvent(this, "cover-command", { mode, action });
|
||||
}
|
||||
},
|
||||
tap: (e) => {
|
||||
const pointer = this._pointerValue(e, shape);
|
||||
if (pointer !== undefined && pointer >= 50 !== closing) {
|
||||
fireEvent(this, "cover-command", { mode: "position", action });
|
||||
fireEvent(this, "cover-command", { mode, action });
|
||||
}
|
||||
},
|
||||
cancel: () => this._setDrag(undefined),
|
||||
|
||||
@@ -28,12 +28,20 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
|
||||
private _startupToastKey?: string;
|
||||
|
||||
private _startupDetailsOpen = false;
|
||||
|
||||
private _disconnectedTimeout?: number;
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues<this>) {
|
||||
super.firstUpdated(changedProps);
|
||||
// Need to load in advance because when disconnected, can't dynamically load code.
|
||||
setTimeout(() => import("../managers/notification-manager"), 5000);
|
||||
this.addEventListener("dialog-closed", (ev) => {
|
||||
if (ev.detail.dialog === "dialog-startup-progress") {
|
||||
this._startupDetailsOpen = false;
|
||||
this._updateStartupProgress();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updated(changedProperties: PropertyValues<this>) {
|
||||
@@ -135,6 +143,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
// Wait until the translations are available.
|
||||
if (
|
||||
!this._startupProgressVisible ||
|
||||
this._startupDetailsOpen ||
|
||||
!this.hass!.localize("ui.startup_progress.starting")
|
||||
) {
|
||||
return;
|
||||
@@ -163,13 +172,19 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
? {
|
||||
text: { translationKey: "ui.startup_progress.details" },
|
||||
icon: mdiInformationOutline,
|
||||
keepOpen: true,
|
||||
action: () => showStartupProgressDialog(this),
|
||||
action: () => this._showStartupDetails(),
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
|
||||
// Toasts always show above dialogs, so the toast is hidden while the details are open.
|
||||
private _showStartupDetails() {
|
||||
this._startupDetailsOpen = true;
|
||||
this._startupToastKey = undefined;
|
||||
showStartupProgressDialog(this);
|
||||
}
|
||||
|
||||
// Keeps the subscription, so the completion toast still reflects late failures.
|
||||
private _hideStartupProgress() {
|
||||
this._startupProgressVisible = false;
|
||||
@@ -193,6 +208,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
);
|
||||
this._hideStartupProgress();
|
||||
this._unsubscribeBootstrapProgress();
|
||||
if (this._startupDetailsOpen) {
|
||||
return;
|
||||
}
|
||||
const issues = failed.length;
|
||||
showToast(this, {
|
||||
id: SERVER_STARTUP_TOAST_ID,
|
||||
@@ -205,7 +223,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
action: this.hass!.user?.is_admin
|
||||
? {
|
||||
text: this.hass!.localize("ui.notification_toast.details"),
|
||||
action: () => showStartupProgressDialog(this),
|
||||
action: () => this._showStartupDetails(),
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { PropertyValues } from "lit";
|
||||
import type { HASSDomEvent } from "../common/dom/fire_event";
|
||||
import { mainWindow } from "../common/dom/get_main_window";
|
||||
import { computeDomain } from "../common/entity/compute_domain";
|
||||
import { replaceCurrentUrl } from "../common/navigate";
|
||||
import {
|
||||
createMoreInfoUrl,
|
||||
@@ -12,8 +11,6 @@ import type { MoreInfoDialogParams } from "../dialogs/more-info/ha-more-info-dia
|
||||
import type { Constructor } from "../types";
|
||||
import type { HassBaseEl } from "./hass-base-mixin";
|
||||
|
||||
const LARGE_MORE_INFO_DOMAINS = ["camera", "image"];
|
||||
|
||||
declare global {
|
||||
// for fire event
|
||||
interface HASSDomEvents {
|
||||
@@ -47,13 +44,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
{
|
||||
entityId: ev.detail.entityId,
|
||||
view,
|
||||
large:
|
||||
ev.detail.large ??
|
||||
(ev.detail.entityId
|
||||
? LARGE_MORE_INFO_DOMAINS.includes(
|
||||
computeDomain(ev.detail.entityId)
|
||||
)
|
||||
: false),
|
||||
large: ev.detail.large,
|
||||
data: ev.detail.data,
|
||||
returnUrl,
|
||||
},
|
||||
|
||||
@@ -2857,6 +2857,7 @@
|
||||
"in_use": "In use",
|
||||
"connecting": "Connecting",
|
||||
"not_supported_count": "Not supported by this camera ({count})",
|
||||
"enhanced_by_cloud": "Enhanced by Home Assistant Link",
|
||||
"description": {
|
||||
"web_rtc": "Real-time video with the lowest delay, usually below a second. The video takes the most direct way from the camera to your device, which can need extra network setup when you are away from home. Needed to talk to the camera.",
|
||||
"hls": "The video is sent in short pieces through Home Assistant. It works on almost every network and device, but is a few seconds behind. Used while WebRTC connects, or when WebRTC is not available.",
|
||||
@@ -3993,7 +3994,8 @@
|
||||
"location_settings": "Location settings",
|
||||
"retention_all": "Keep all backups",
|
||||
"retention_backups": "Keep {count} {count, plural,\n one {backup}\n other {backups}\n}",
|
||||
"retention_days": "Keep {count} {count, plural,\n one {day}\n other {days}\n}"
|
||||
"retention_days": "Keep {count} {count, plural,\n one {day}\n other {days}\n}",
|
||||
"retention_inactive": "Retention paused"
|
||||
},
|
||||
"data": {
|
||||
"ha_settings": "Home Assistant settings",
|
||||
@@ -4049,7 +4051,7 @@
|
||||
"retention": "Retention",
|
||||
"custom_retention": "Custom retention",
|
||||
"custom_retention_label": "Keep only",
|
||||
"retention_description": "Based on the maximum number of backups or how many days they should be kept.",
|
||||
"retention_description": "Based on the maximum number of backups or how many days they should be kept. Only applies to automatic backups, in the locations they are stored in.",
|
||||
"retention_presets": {
|
||||
"global": "Use global settings",
|
||||
"copies_3": "3 backups",
|
||||
@@ -4324,6 +4326,7 @@
|
||||
"save_error": "Error saving configuration: {error}",
|
||||
"retention_for_this_system": "Retention for this system",
|
||||
"retention_for_location": "Retention for {location}",
|
||||
"retention_inactive": "Automatic backups aren't stored in this location, so its retention settings are paused. Backups already in this location are kept until you delete them. Retention applies again when you turn the location back on for automatic backups.",
|
||||
"not_found": "Not found",
|
||||
"not_found_description": "Location matching ''{backupId}'' not found",
|
||||
"error": "Could not fetch location details",
|
||||
@@ -4793,6 +4796,13 @@
|
||||
"add": "Add",
|
||||
"dismiss": "Dismiss",
|
||||
"dismiss_failed": "Couldn't dismiss this meter",
|
||||
"show_dismissed": "Show dismissed meters ({count})",
|
||||
"hide_dismissed": "Hide dismissed meters",
|
||||
"dismissed": "Dismissed",
|
||||
"dismissed_title": "Dismissed meters",
|
||||
"dismissed_sub": "Restore a meter to have it suggested again, or add it right away.",
|
||||
"restore": "Restore",
|
||||
"restore_failed": "Couldn't restore this meter",
|
||||
"load_failed": "Couldn't check for meters that aren't in your energy dashboard yet.",
|
||||
"slots": {
|
||||
"grid_import": "Grid consumption",
|
||||
@@ -10942,6 +10952,8 @@
|
||||
"pick_card": "Add to dashboard",
|
||||
"pick_card_title": "Which card would you like to add to {name}",
|
||||
"toggle_editor": "Toggle editor",
|
||||
"enlarge": "Enlarge",
|
||||
"shrink": "Shrink",
|
||||
"unsaved_changes": "You have unsaved changes",
|
||||
"confirm_cancel": "Are you sure you want to cancel?",
|
||||
"show_visual_editor": "Show visual editor",
|
||||
@@ -10990,6 +11002,8 @@
|
||||
"pick_badge": "Which badge would you like to add?",
|
||||
"pick_badge_title": "Which badge would you like to add to \"{name}\"?",
|
||||
"toggle_editor": "[%key:ui::panel::lovelace::editor::edit_card::toggle_editor%]",
|
||||
"enlarge": "[%key:ui::panel::lovelace::editor::edit_card::enlarge%]",
|
||||
"shrink": "[%key:ui::panel::lovelace::editor::edit_card::shrink%]",
|
||||
"unsaved_changes": "[%key:ui::panel::lovelace::editor::edit_card::unsaved_changes%]",
|
||||
"confirm_cancel": "[%key:ui::panel::lovelace::editor::edit_card::confirm_cancel%]",
|
||||
"show_visual_editor": "[%key:ui::panel::lovelace::editor::edit_card::show_visual_editor%]",
|
||||
@@ -12440,6 +12454,9 @@
|
||||
"dropdown": "[%key:ui::panel::lovelace::editor::features::types::climate-preset-modes::style_list::dropdown%]"
|
||||
}
|
||||
},
|
||||
"timer-progress": {
|
||||
"label": "Timer progress"
|
||||
},
|
||||
"fan-preset-modes": {
|
||||
"label": "Fan preset modes",
|
||||
"style": "[%key:ui::panel::lovelace::editor::features::types::climate-preset-modes::style%]",
|
||||
|
||||
@@ -177,6 +177,7 @@ exports[`generateStatisticsChartData > matches snapshot for a bar chart with sum
|
||||
"datasets": [
|
||||
{
|
||||
"animationDurationUpdate": 0,
|
||||
"barMaxWidth": 50,
|
||||
"color": "#4269d07F",
|
||||
"cursor": "default",
|
||||
"data": [
|
||||
@@ -347,6 +348,7 @@ exports[`generateStatisticsChartData > matches snapshot for a bar chart with sum
|
||||
},
|
||||
{
|
||||
"animationDurationUpdate": 0,
|
||||
"barMaxWidth": 50,
|
||||
"color": "#f4bd4a7F",
|
||||
"cursor": "default",
|
||||
"data": [
|
||||
@@ -1380,6 +1382,7 @@ exports[`generateStatisticsChartData > matches snapshot for a stacked bar chart
|
||||
"datasets": [
|
||||
{
|
||||
"animationDurationUpdate": 0,
|
||||
"barMaxWidth": 50,
|
||||
"color": "#4269d07F",
|
||||
"cursor": "default",
|
||||
"data": [
|
||||
@@ -1444,6 +1447,7 @@ exports[`generateStatisticsChartData > matches snapshot for a stacked bar chart
|
||||
},
|
||||
{
|
||||
"animationDurationUpdate": 0,
|
||||
"barMaxWidth": 50,
|
||||
"color": "#f4bd4a7F",
|
||||
"cursor": "default",
|
||||
"data": [
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { HaDialog } from "../../src/components/ha-dialog";
|
||||
import "../../src/components/ha-dialog";
|
||||
|
||||
vi.mock("@home-assistant/webawesome/dist/components/dialog/dialog", () => {
|
||||
customElements.define("wa-dialog", class extends HTMLElement {});
|
||||
return {};
|
||||
});
|
||||
|
||||
vi.mock("../../src/components/ha-dialog-header", () => {
|
||||
customElements.define("ha-dialog-header", class extends HTMLElement {});
|
||||
return {};
|
||||
});
|
||||
|
||||
vi.mock("../../src/components/ha-icon-button", () => {
|
||||
customElements.define("ha-icon-button", class extends HTMLElement {});
|
||||
return {};
|
||||
});
|
||||
|
||||
// Lit counts the test run as a server, so this never gets an observer
|
||||
vi.mock("@lit-labs/observers/resize-controller", () => ({
|
||||
ResizeController: class {
|
||||
observe = vi.fn();
|
||||
|
||||
unobserve = vi.fn();
|
||||
},
|
||||
}));
|
||||
|
||||
let host: HTMLElement | undefined;
|
||||
|
||||
afterEach(() => {
|
||||
host?.remove();
|
||||
host = undefined;
|
||||
});
|
||||
|
||||
// Shows the dialog the way wa-dialog announces it opened
|
||||
const showDialog = async (dialog: HaDialog) => {
|
||||
await dialog.updateComplete;
|
||||
dialog
|
||||
.shadowRoot!.querySelector("wa-dialog")!
|
||||
.dispatchEvent(new Event("wa-show"));
|
||||
};
|
||||
|
||||
describe("ha-dialog", () => {
|
||||
it("focuses its own autofocus child", async () => {
|
||||
host = document.createElement("ha-dialog");
|
||||
host.innerHTML = "<input /><input autofocus />";
|
||||
document.body.append(host);
|
||||
|
||||
await showDialog(host as HaDialog);
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(document.activeElement).toBe(host!.querySelector("[autofocus]"))
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["slotted in by a wrapper", "<input /><input autofocus />"],
|
||||
[
|
||||
"nested in content a wrapper slots in",
|
||||
"<input /><div><input autofocus /></div>",
|
||||
],
|
||||
])("focuses an autofocus element %s", async (_, content) => {
|
||||
// A wrapper like ha-adaptive-dialog passes its content through a slot
|
||||
host = document.createElement("div");
|
||||
host.attachShadow({ mode: "open" }).innerHTML =
|
||||
"<ha-dialog><slot></slot></ha-dialog>";
|
||||
host.innerHTML = content;
|
||||
document.body.append(host);
|
||||
|
||||
await showDialog(host.shadowRoot!.querySelector("ha-dialog")!);
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(document.activeElement).toBe(host!.querySelector("[autofocus]"))
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,12 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { BluetoothScannerState } from "../../src/data/bluetooth";
|
||||
import { isScannerStateMismatch } from "../../src/data/bluetooth";
|
||||
import {
|
||||
getBluetoothAdapters,
|
||||
isScannerStateMismatch,
|
||||
} from "../../src/data/bluetooth";
|
||||
import type { ConfigEntry } from "../../src/data/config_entries";
|
||||
import type { DeviceRegistryEntry } from "../../src/data/device/device_registry";
|
||||
|
||||
const state = (
|
||||
overrides: Partial<BluetoothScannerState>
|
||||
@@ -63,3 +68,54 @@ describe("isScannerStateMismatch", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getBluetoothAdapters", () => {
|
||||
const entry = (
|
||||
entry_id: string,
|
||||
overrides: Partial<ConfigEntry> = {}
|
||||
): ConfigEntry =>
|
||||
({
|
||||
entry_id,
|
||||
domain: "bluetooth",
|
||||
source: "user",
|
||||
disabled_by: null,
|
||||
...overrides,
|
||||
}) as ConfigEntry;
|
||||
|
||||
const device = (
|
||||
id: string,
|
||||
configEntries: string[],
|
||||
connections: [string, string][] = [["bluetooth", id]]
|
||||
): DeviceRegistryEntry =>
|
||||
({
|
||||
id,
|
||||
config_entries: configEntries,
|
||||
connections,
|
||||
}) as DeviceRegistryEntry;
|
||||
|
||||
it("only counts entries with a Bluetooth device as adapters", () => {
|
||||
const entries = [
|
||||
entry("proxy"),
|
||||
entry("ignored", { source: "ignore" }),
|
||||
entry("removed"),
|
||||
entry("disabled", { disabled_by: "user" }),
|
||||
entry("disabled-without-device", { disabled_by: "user" }),
|
||||
];
|
||||
const devices = {
|
||||
proxy: device("proxy", ["esphome", "proxy"]),
|
||||
disabled: device("disabled", ["disabled"]),
|
||||
"no-bluetooth": device("no-bluetooth", ["proxy"], [["mac", "x"]]),
|
||||
other: device("other", ["other-integration"]),
|
||||
};
|
||||
|
||||
const result = getBluetoothAdapters(devices, entries);
|
||||
|
||||
expect(result.enabledDevices.map((a) => a.device.id)).toEqual(["proxy"]);
|
||||
expect(result.disabledDevices.map((a) => a.device.id)).toEqual([
|
||||
"disabled",
|
||||
]);
|
||||
expect(result.disabledEntriesWithoutDevice.map((e) => e.entry_id)).toEqual([
|
||||
"disabled-without-device",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { CoverEntity } from "../../src/data/cover";
|
||||
import { CoverEntityFeature, coverCurrentValue } from "../../src/data/cover";
|
||||
|
||||
const TILT_FEATURES =
|
||||
CoverEntityFeature.OPEN_TILT +
|
||||
CoverEntityFeature.CLOSE_TILT +
|
||||
CoverEntityFeature.STOP_TILT;
|
||||
|
||||
const cover = (
|
||||
state: string,
|
||||
supportedFeatures: number,
|
||||
attributes: Partial<CoverEntity["attributes"]> = {}
|
||||
): CoverEntity =>
|
||||
({
|
||||
entity_id: "cover.blind",
|
||||
state,
|
||||
attributes: { supported_features: supportedFeatures, ...attributes },
|
||||
}) as CoverEntity;
|
||||
|
||||
describe("coverCurrentValue", () => {
|
||||
it("uses the state for the tilt of a tilt-only cover without a tilt position", () => {
|
||||
expect(coverCurrentValue(cover("closed", TILT_FEATURES), "tilt")).toBe(0);
|
||||
expect(coverCurrentValue(cover("opening", TILT_FEATURES), "tilt")).toBe(0);
|
||||
expect(coverCurrentValue(cover("open", TILT_FEATURES), "tilt")).toBe(100);
|
||||
expect(coverCurrentValue(cover("closing", TILT_FEATURES), "tilt")).toBe(
|
||||
100
|
||||
);
|
||||
});
|
||||
|
||||
it("has no tilt when the state of a tilt-only cover is unknown", () => {
|
||||
expect(
|
||||
coverCurrentValue(cover("unknown", TILT_FEATURES), "tilt")
|
||||
).toBeUndefined();
|
||||
expect(
|
||||
coverCurrentValue(cover("unavailable", TILT_FEATURES), "tilt")
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("prefers the reported tilt position", () => {
|
||||
expect(
|
||||
coverCurrentValue(
|
||||
cover("closed", TILT_FEATURES, { current_tilt_position: 30 }),
|
||||
"tilt"
|
||||
)
|
||||
).toBe(30);
|
||||
});
|
||||
|
||||
it("does not use the state for the tilt when the cover also moves up and down", () => {
|
||||
expect(
|
||||
coverCurrentValue(
|
||||
cover("closed", TILT_FEATURES + CoverEntityFeature.OPEN),
|
||||
"tilt"
|
||||
)
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("does not use the state for the tilt when the cover can set its tilt position", () => {
|
||||
expect(
|
||||
coverCurrentValue(
|
||||
cover("closed", TILT_FEATURES + CoverEntityFeature.SET_TILT_POSITION),
|
||||
"tilt"
|
||||
)
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
import type { EnergySuggestionInput } from "../../src/data/energy_suggestions";
|
||||
import {
|
||||
computeEnergySuggestions,
|
||||
restoreDismissedSuggestion,
|
||||
updateDismissedSuggestions,
|
||||
} from "../../src/data/energy_suggestions";
|
||||
import type { StatisticsMetaData } from "../../src/data/recorder";
|
||||
@@ -230,3 +231,11 @@ describe("updateDismissedSuggestions", () => {
|
||||
).toEqual(["sensor.kept", "sensor.new"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("restoreDismissedSuggestion", () => {
|
||||
it("removes only the restored statistic", () => {
|
||||
expect(
|
||||
restoreDismissedSuggestion(["sensor.a", "sensor.b"], "sensor.a")
|
||||
).toEqual(["sensor.b"]);
|
||||
});
|
||||
});
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
browseUrl,
|
||||
filterRepositories,
|
||||
filtersOfTab,
|
||||
paneFilterOfTab,
|
||||
marketplaceUpdateEntityIds,
|
||||
skippedUpdateRepositories,
|
||||
statusesOfTab,
|
||||
@@ -284,13 +285,6 @@ describe("browseLinkFromUrl", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("filters on no integration category for an empty one", () => {
|
||||
expect(
|
||||
browseLinkFromUrl("?integration_category=")?.filters
|
||||
.integration_category ?? []
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it("keeps what was picked for a link that says nothing about browsing", () => {
|
||||
expect(
|
||||
browseLinkFromUrl("?owner=hacs&repository=integration")
|
||||
@@ -299,11 +293,31 @@ describe("browseLinkFromUrl", () => {
|
||||
});
|
||||
|
||||
describe("filtersOfTab", () => {
|
||||
it("keeps the integration category on every tab", () => {
|
||||
it("leaves out an integration category nothing on the tab is in", () => {
|
||||
const filters = { integration_category: ["energy", "energy.solar"] };
|
||||
|
||||
expect(
|
||||
filtersOfTab({ integration_category: ["energy"] }, "installed")
|
||||
.integration_category
|
||||
filtersOfTab(filters, "installed", ["energy"]).integration_category
|
||||
).toEqual(["energy"]);
|
||||
expect(filtersOfTab(filters, "installed", []).integration_category).toEqual(
|
||||
[]
|
||||
);
|
||||
// Without the ones the tab lists, as before the repositories load
|
||||
expect(filtersOfTab(filters, "installed").integration_category).toEqual(
|
||||
filters.integration_category
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps an integration category picked on browse when the installed pane changes", () => {
|
||||
const picked = ["energy.solar", "climate"];
|
||||
|
||||
expect(
|
||||
paneFilterOfTab(picked, ["climate", "lighting"], ["lighting"])
|
||||
).toEqual(["energy.solar", "lighting"]);
|
||||
// The pane's clear button sends no value
|
||||
expect(paneFilterOfTab(picked, ["climate"], undefined)).toEqual([
|
||||
"energy.solar",
|
||||
]);
|
||||
});
|
||||
|
||||
it("only offers statuses something installed can have on the installed tab", () => {
|
||||
|
||||
@@ -274,6 +274,61 @@ it("shows what to discover on the discover tab, not the table", async () => {
|
||||
).not.toBeNull();
|
||||
});
|
||||
|
||||
it("offers the integration categories of the tab, leaving out one picked on another", async () => {
|
||||
window.history.replaceState(
|
||||
null,
|
||||
"",
|
||||
"/marketplace/browse?integration_category=energy"
|
||||
);
|
||||
const dashboard = await openDashboard([
|
||||
{
|
||||
id: "1",
|
||||
name: "One",
|
||||
category: "integration",
|
||||
installed: true,
|
||||
integration_categories: ["climate"],
|
||||
},
|
||||
{
|
||||
id: "2",
|
||||
name: "Two",
|
||||
category: "integration",
|
||||
installed: false,
|
||||
integration_categories: ["energy"],
|
||||
},
|
||||
]);
|
||||
window.history.replaceState(null, "", "/");
|
||||
const table = () =>
|
||||
dashboard.shadowRoot!.querySelector(
|
||||
"hass-tabs-subpage-data-table"
|
||||
) as unknown as { data: { id: string }[]; filters: number };
|
||||
const categoryFilter = () =>
|
||||
dashboard.shadowRoot!.querySelectorAll(
|
||||
"ha-filter-states"
|
||||
)[3] as unknown as {
|
||||
value?: string[];
|
||||
states: { value: string }[];
|
||||
};
|
||||
|
||||
expect(table().data.map((repository) => repository.id)).toEqual(["2"]);
|
||||
|
||||
dashboard.tab = "installed";
|
||||
await dashboard.updateComplete;
|
||||
|
||||
expect(categoryFilter().states.map((state) => state.value)).toEqual([
|
||||
"climate",
|
||||
]);
|
||||
expect(categoryFilter().value).toEqual([]);
|
||||
expect(table().filters).toBe(0);
|
||||
expect(table().data.map((repository) => repository.id)).toEqual(["1"]);
|
||||
|
||||
dashboard.tab = "browse";
|
||||
await dashboard.updateComplete;
|
||||
|
||||
expect(categoryFilter().value).toEqual(["energy"]);
|
||||
dashboard.remove();
|
||||
sessionStorage.clear();
|
||||
});
|
||||
|
||||
it("browses the way the link says", async () => {
|
||||
window.history.replaceState(
|
||||
null,
|
||||
|
||||
@@ -11,6 +11,8 @@ import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import { deferred } from "./dialog-host";
|
||||
import { markdownWithRepositoryContext } from "../../../src/panels/marketplace/tools/markdown";
|
||||
import type * as MarkdownModule from "../../../src/panels/marketplace/tools/markdown";
|
||||
import { getIntegrationCategoryIcons } from "../../../src/data/icons";
|
||||
import type * as IconsModule from "../../../src/data/icons";
|
||||
|
||||
// The real components need more browser than jsdom has, the page only hands
|
||||
// them properties.
|
||||
@@ -39,6 +41,10 @@ vi.mock(
|
||||
};
|
||||
}
|
||||
);
|
||||
vi.mock("../../../src/data/icons", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof IconsModule>()),
|
||||
getIntegrationCategoryIcons: vi.fn(async () => ({})),
|
||||
}));
|
||||
vi.mock("../../../src/components/chips/ha-assist-chip", () =>
|
||||
stubElement("ha-assist-chip")
|
||||
);
|
||||
@@ -212,6 +218,30 @@ describe("ha-marketplace-repository-dashboard", () => {
|
||||
expect(getInternals(page)._repository.id).toBe("2");
|
||||
});
|
||||
|
||||
it("loads the category icons once, only for repositories with categories", async () => {
|
||||
const { page } = await openRepositoryPage(
|
||||
async (repositoryId) =>
|
||||
repositoryInfo(
|
||||
repositoryId,
|
||||
repositoryId === "theme"
|
||||
? { category: "theme" }
|
||||
: { category: "integration", integration_categories: ["energy"] }
|
||||
),
|
||||
repositoryRoute("theme")
|
||||
);
|
||||
await settle(page);
|
||||
expect(getIntegrationCategoryIcons).not.toHaveBeenCalled();
|
||||
|
||||
page.route = repositoryRoute("1");
|
||||
await settle(page);
|
||||
page.route = repositoryRoute("2");
|
||||
await settle(page);
|
||||
page.reloadRepository();
|
||||
await settle(page);
|
||||
|
||||
expect(getIntegrationCategoryIcons).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("clears the error of the previous repository", async () => {
|
||||
const { page } = await openRepositoryPage(async (repositoryId) => {
|
||||
if (repositoryId === "1") {
|
||||
|
||||
Reference in new issue
Block a user