Compare commits

...

99 Commits

Author SHA1 Message Date
Bram Kragten
75c43d15e1 20231002.0 (#18102) 2023-10-02 21:43:12 +02:00
Bram Kragten
e288b003d8 Bumped version to 20231002.0 2023-10-02 21:41:37 +02:00
yousaf465
4aa8518ed6 Change Urdu language to RTL (#18063)
Co-authored-by: karwosts <32912880+karwosts@users.noreply.github.com>
2023-10-02 21:26:07 +02:00
Bram Kragten
6acbf6395c Ignore prettier styling for tooltip of disk life time (#18097) 2023-10-02 21:23:13 +02:00
Bram Kragten
2030feabf7 Only set wakeword when not in new wakewords (#18095) 2023-10-02 21:23:02 +02:00
Bram Kragten
46d1dbcb47 Dont continue debug assist run when disconnected (#18098) 2023-10-02 21:22:50 +02:00
Bram Kragten
2f6297ec17 Always deduplicate found integrations in onboarding (#18091)
always deduplicate found integrations in onboarding
2023-10-02 14:30:28 +02:00
Paul Bottein
a3400a2f9c Prevent ha-form data lost if quick data updates (#18094) 2023-10-02 11:44:43 +02:00
Kendell R
c345f41416 Factor out style data to reduce bundle size (#18077) 2023-10-02 11:18:44 +02:00
Kendell R
292cdc7621 Fix clicking on radio buttons (and improve code) (#18078) 2023-10-02 10:58:10 +02:00
dependabot[bot]
c5ba74e0b4 Bump home-assistant/wheels from 2023.09.1 to 2023.10.1 (#18088)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-02 08:54:53 +02:00
renovate[bot]
41b24de559 Update dependency chai to v4.3.10 (#18082) 2023-10-01 20:24:14 -04:00
renovate[bot]
4fe7b18161 Update dependency chai to v4.3.9 (#18074)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-30 16:17:27 -04:00
renovate[bot]
399a979c33 Update dependency glob to v10.3.10 (#18072)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-30 16:16:20 -04:00
renovate[bot]
03c5482860 Update dependency @types/mocha to v10.0.2 (#18075)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-30 16:15:30 -04:00
Franck Nijhof
a116a50604 Hide shopping list from discovered onboarding integrations (#18069) 2023-09-29 22:39:57 +02:00
renovate[bot]
0dfa292c40 Update dependency glob to v10.3.9 (#18060)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-29 13:30:08 -04:00
Bram Kragten
5914a6c1a4 Clear wake word when new engine is picked, select first wake word. by… (#18058)
* Clear wake word when new engine is picked, select first wake word. by default

* Update assist-pipeline-detail-wakeword.ts
2023-09-29 12:38:11 +02:00
Bram Kragten
8daff17d6a Change linear-progress bar background color for dark mode (#18059) 2023-09-29 10:33:26 +02:00
renovate[bot]
59bd852e7a Update dependency @octokit/rest to v20.0.2 (#18053)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-28 22:51:10 -04:00
renovate[bot]
246fe2861e Update dependency eslint-plugin-wc to v2.0.4 (#18050)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-28 14:18:22 -04:00
renovate[bot]
dbf623ada2 Update typescript-eslint monorepo to v6.7.3 (#18051)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-28 14:17:33 -04:00
renovate[bot]
c848356a6d Update dependency @types/sortablejs to v1.15.3 (#18049)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-28 14:16:08 -04:00
Paul Bottein
47022d3a04 20230928.0 (#18052) 2023-09-28 20:15:04 +02:00
Paul Bottein
d732bd4776 Bumped version to 20230928.0 2023-09-28 20:12:59 +02:00
Raman Gupta
5a5265723c Handle breaking changes as result of zwave_js lib upgrade (#18009)
* Handle breaking changes as result of zwave_js lib upgrade

* fix capitalization
2023-09-28 20:00:21 +02:00
Bram Kragten
30c6e4e35e Link to docs when no wake word engines (#18046) 2023-09-28 19:34:31 +02:00
renovate[bot]
c5f909d89f Update dependency @types/serve-handler to v6.1.2 (#18048)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-28 13:19:14 -04:00
Simon Lamon
13a691606f Migrate developer events tools to LitElement (#17869) 2023-09-28 14:58:16 +00:00
Simon Lamon
44748df3ac Make numeric_state trigger and condition translatable (#18017) 2023-09-28 14:39:57 +02:00
dependabot[bot]
4f3dc82fd9 Bump get-func-name from 2.0.0 to 2.0.2 (#18043)
Bumps [get-func-name](https://github.com/chaijs/get-func-name) from 2.0.0 to 2.0.2.
- [Release notes](https://github.com/chaijs/get-func-name/releases)
- [Commits](https://github.com/chaijs/get-func-name/commits/v2.0.2)

---
updated-dependencies:
- dependency-name: get-func-name
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-27 23:26:34 -04:00
Paul Bottein
b2e260d6ba Use initial color param for favorite color dialog (#18039)
* Use initial color param for favorite color dialog

* Select right mode if light is off
2023-09-27 16:26:16 +02:00
imgbot[bot]
7111a21173 [ImgBot] Optimize images (#18038)
Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
2023-09-27 14:31:05 +02:00
karwosts
ad51d313a1 Debug option to enable logging server calls (#17956) 2023-09-27 14:26:25 +02:00
Bram Kragten
60345f3fe8 20230926.0 (#18037) 2023-09-26 23:56:14 +02:00
Bram Kragten
956723cf15 Bumped version to 20230926.0 2023-09-26 23:51:50 +02:00
K3A
dd6a69ea03 State History Charts - Handle click to chart to open More Info for the clicked entity (#18036) 2023-09-26 21:19:11 +00:00
Bram Kragten
98bd08c9dd Update layout of hardware info (#18034) 2023-09-26 23:09:14 +02:00
karwosts
6b31c07459 Add an image fit mode to hui-image and picture-entity-card (#17959) 2023-09-26 23:08:56 +02:00
renovate[bot]
c3b41afb68 Update dependency @types/esprima to v4.0.4 (#18031)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-26 23:07:07 +02:00
renovate[bot]
46d8f2eefb Update dependency @lokalise/node-api to v12 (#18029)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-26 23:05:51 +02:00
karwosts
0ffc7b59d6 Prevent creating views with duplicate URL (#17871) 2023-09-26 22:54:27 +02:00
karwosts
74be4ae20a Enable reorder mode for choose options (#17422) 2023-09-26 22:52:20 +02:00
karwosts
5455ce2e0f Display an error message when disabling the button in devtools/service (#17519) 2023-09-26 22:49:57 +02:00
karwosts
01405d96b6 Fix too wide energy chart bars (#17787) 2023-09-26 22:49:04 +02:00
renovate[bot]
965f893a65 Update dependency @octokit/auth-oauth-device to v6.0.1 (#18033)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-26 22:44:02 +02:00
Simon Lamon
0b6813d9dc Update Add and Edit area dialog (#17711) 2023-09-26 22:41:02 +02:00
Paul Bottein
cbd424ff5a Fix aria label auth page (#18032) 2023-09-26 22:39:25 +02:00
Bram Kragten
b899e39a9e Fix markdown card template handling (#17851) 2023-09-26 22:37:27 +02:00
karwosts
49a66961e2 Fix adjust statistic dialog after a period of sensor unavailability (#17934)
* Fix adjust statistic dialog after a period of sensor unavailability

* Remove fetching an unnecessary datapoint
2023-09-26 22:00:39 +02:00
karwosts
c69fb77b62 Fix choose description when a non-list form of conditions is used (#18023) 2023-09-26 21:54:40 +02:00
Bram Kragten
d794ec3408 Update assist-pipeline-detail-wakeword.ts 2023-09-26 21:27:27 +02:00
Paul Bottein
d8c98d8f96 Move auth components from shadow DOM to light DOM (#18015) 2023-09-26 20:17:03 +02:00
karwosts
acb32ae5c8 Allow saving the light current color as a favorite (#17992) 2023-09-26 18:59:59 +02:00
Bram Kragten
c567a61dd7 Add wake word to assist pipeline settings (#18019)
* Add wake word to assist pipeline settings

* Update assist-pipeline-detail-wakeword.ts

* Add icon for wake word domain

* format state

* implement `wake_word/info` command
2023-09-26 12:17:45 -04:00
Bram Kragten
2a8d98307e Fix chart not able to setup because canvas in use (#18018)
* Fix chart not able to setup because canvas in use

* Update ha-chart-base.ts
2023-09-26 17:58:02 +02:00
Bram Kragten
5aaf0cd579 Update logo (#17964) 2023-09-26 15:33:40 +02:00
renovate[bot]
f38e4dcf54 Update dependency @octokit/plugin-retry to v6.0.1 (#18026)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-26 12:54:40 +00:00
Steve Repsher
1df1ce5423 Stop notifications for errors writing to system log (#18022) 2023-09-26 14:43:27 +02:00
Paul Bottein
a68381a4d9 Clear quick bar items with closing the quick bar dialog (#18025) 2023-09-26 14:27:27 +02:00
renovate[bot]
f7604b136e Update dependency eslint to v8.50.0 (#18021)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-25 18:35:42 -04:00
karwosts
362d950515 Ensure computeStateName returns a string type (#17928) 2023-09-25 18:11:02 +02:00
Bram Kragten
22f9dbd65d Add wake word to assist pipeline debug (#17897) 2023-09-25 17:51:12 +02:00
karwosts
579050bfc7 Add new config options for map entity markers (#17938) 2023-09-25 17:26:53 +02:00
Joost Lekkerkerker
6b33b4e656 Add label to location selector (#17402)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2023-09-25 13:38:47 +00:00
renovate[bot]
dac7c0f5fd Lock file maintenance (#17960)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2023-09-25 12:43:17 +00:00
renovate[bot]
aaceff0d23 Update dependency marked to v9 (#17914)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-25 14:13:27 +02:00
renovate[bot]
48e5cc6b63 Update dependency eslint-plugin-lit-a11y to v4 (#17143)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Steve Repsher <steverep@users.noreply.github.com>
Co-authored-by: Paul Bottein <paul.bottein@gmail.com>
2023-09-25 14:11:42 +02:00
renovate[bot]
799a0933ba Update dependency chart.js to v4.4.0 (#17736)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-25 14:11:18 +02:00
dependabot[bot]
940618f72d Bump home-assistant/wheels from 2023.04.0 to 2023.09.1 (#18011)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-25 14:10:42 +02:00
renovate[bot]
d8ff69b65d Update fullcalendar monorepo to v6.1.9 (#18007)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-25 14:08:54 +02:00
Steve Repsher
391aca6388 Improve core script and default to upgrade (#17915) 2023-09-25 14:08:30 +02:00
Simon Lamon
071d078e84 Make some triggers translatable (#17692) 2023-09-25 14:07:31 +02:00
renovate[bot]
61982bcb77 Update CodeMirror (#17996)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-25 13:23:51 +02:00
Bram Kragten
1c79fcc244 Fix translations onboarding integration (#17980) 2023-09-25 12:58:54 +02:00
dependabot[bot]
f3513e3e52 Bump actions/checkout from 4.0.0 to 4.1.0 (#18010)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-25 11:20:50 +02:00
renovate[bot]
b3b10fa2ef Update dependency eslint-plugin-wc to v2.0.3 (#17999)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-24 16:48:26 -04:00
renovate[bot]
0ffabcc055 Update dependency glob to v10.3.5 (#18000)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-24 16:44:03 -04:00
renovate[bot]
9da8499004 Update dependency eslint-plugin-wc to v2 (#17966)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-23 00:50:32 -04:00
renovate[bot]
04d1fccb87 Update formatjs monorepo (#17975)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-23 00:27:33 -04:00
renovate[bot]
fdf1eb5170 Update dependency @lokalise/node-api to v11.1.0 (#17995)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-23 00:24:25 -04:00
renovate[bot]
4e2877b035 Update vaadinWebComponents monorepo to v24.1.9 (#17976) 2023-09-22 00:45:15 +00:00
renovate[bot]
467059f515 Update dependency cropperjs to v1.6.1 (#17968) 2023-09-21 20:38:02 -04:00
renovate[bot]
e6db63bb63 Update typescript-eslint monorepo to v6.7.2 (#17982) 2023-09-21 20:33:43 -04:00
Paul Bottein
78ddec2c8c Small fixes for tile features (#17983)
* Add missing translations

* Remove unused import
2023-09-21 21:33:32 +02:00
Paul Bottein
9217d5bf40 Refactor strategy foundation (#17921) 2023-09-21 20:22:52 +02:00
Paul Bottein
90d01e4b63 Add style and preset modes options to climate preset tile feature (#17977) 2023-09-21 18:41:09 +02:00
Joost Lekkerkerker
e7960bf8c0 Make pull request template more in line with core (#17441) 2023-09-21 17:23:31 +02:00
Thomas Aldrian
bf12eaa1b3 Add climate preset tile feature (#17946)
* Add climate preset tile feature

* Minor fixes

* Formatting fixes

* Update src/panels/lovelace/create-element/create-tile-feature-element.ts

* Update src/panels/lovelace/editor/config-elements/hui-tile-card-features-editor.ts

---------

Co-authored-by: Paul Bottein <paul.bottein@gmail.com>
2023-09-21 12:27:41 +02:00
Bram Kragten
6179c75182 don't round update entity images (#17972) 2023-09-20 20:39:54 +02:00
Bram Kragten
40bb6566b8 20230911.0 (#17901) 2023-09-11 18:30:42 +02:00
Bram Kragten
db272e3e18 20230908.0 (#17866) 2023-09-08 15:56:12 +02:00
Bram Kragten
35496ead23 20230906.1 (#17838) 2023-09-06 13:47:02 +02:00
Bram Kragten
41403a5d35 20230906.0 (#17834) 2023-09-06 09:54:26 +02:00
Bram Kragten
8acf557137 20230905.0 (#17828) 2023-09-05 18:11:08 +02:00
Bram Kragten
4e62370d18 20230904.0 (#17819) 2023-09-04 19:18:58 +02:00
Bram Kragten
f90ab60354 20230901.0 (#17782) 2023-09-01 17:02:38 +02:00
Bram Kragten
d187aa0ac6 20230831.0 (#17756) 2023-08-31 14:38:24 +02:00
Bram Kragten
96597b3963 20230830.0 (#17737) 2023-08-30 15:48:10 +02:00
165 changed files with 4443 additions and 2902 deletions

View File

@@ -2,9 +2,7 @@
You are amazing! Thanks for contributing to our project!
Please, DO NOT DELETE ANY TEXT from this template! (unless instructed).
-->
## Breaking change
<!--
If your PR contains a breaking change for existing users, it is important
to tell them what breaks, how to make it work again and why we did this.
@@ -13,8 +11,8 @@
Note: Remove this section if this PR is NOT a breaking change.
-->
## Proposed change
## Proposed change
<!--
Describe the big picture of your changes here to communicate to the
maintainers why we should accept this pull request. If it fixes a bug
@@ -22,8 +20,8 @@
in the additional information section.
-->
## Type of change
## Type of change
<!--
What type of change does your PR introduce to the Home Assistant frontend?
NOTE: Please, check only 1! box!
@@ -38,7 +36,6 @@
- [ ] Code quality improvements to existing code or addition of tests
## Example configuration
<!--
Supplying a configuration snippet, makes it easier for a maintainer to test
your PR.
@@ -49,7 +46,6 @@
```
## Additional information
<!--
Details are important, and help maintainers processing your PR.
Please be sure to fill out additional details, if applicable.
@@ -60,7 +56,6 @@
- Link to documentation pull request:
## Checklist
<!--
Put an `x` in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to ask.

View File

@@ -21,7 +21,7 @@ jobs:
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
steps:
- name: Check out files from GitHub
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
with:
ref: dev
@@ -57,7 +57,7 @@ jobs:
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
steps:
- name: Check out files from GitHub
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
with:
ref: master

View File

@@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out files from GitHub
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
- name: Setup Node
uses: actions/setup-node@v3.8.1
with:
@@ -55,7 +55,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out files from GitHub
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
- name: Setup Node
uses: actions/setup-node@v3.8.1
with:
@@ -73,7 +73,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out files from GitHub
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
- name: Setup Node
uses: actions/setup-node@v3.8.1
with:
@@ -91,7 +91,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out files from GitHub
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
- name: Setup Node
uses: actions/setup-node@v3.8.1
with:

View File

@@ -23,7 +23,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.

View File

@@ -22,7 +22,7 @@ jobs:
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
steps:
- name: Check out files from GitHub
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
with:
ref: dev
@@ -58,7 +58,7 @@ jobs:
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
steps:
- name: Check out files from GitHub
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
with:
ref: master

View File

@@ -16,7 +16,7 @@ jobs:
url: ${{ steps.deploy.outputs.NETLIFY_LIVE_URL || steps.deploy.outputs.NETLIFY_URL }}
steps:
- name: Check out files from GitHub
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
- name: Setup Node
uses: actions/setup-node@v3.8.1

View File

@@ -21,7 +21,7 @@ jobs:
if: github.repository == 'home-assistant/frontend' && contains(github.event.pull_request.labels.*.name, 'needs design preview')
steps:
- name: Check out files from GitHub
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
- name: Setup Node
uses: actions/setup-node@v3.8.1

View File

@@ -20,7 +20,7 @@ jobs:
contents: write
steps:
- name: Checkout the repository
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4

View File

@@ -23,7 +23,7 @@ jobs:
contents: write # Required to upload release assets
steps:
- name: Checkout the repository
uses: actions/checkout@v4.0.0
uses: actions/checkout@v4.1.0
- name: Verify version
uses: home-assistant/actions/helpers/verify-version@master
@@ -74,7 +74,7 @@ jobs:
echo "home-assistant-frontend==$version" > ./requirements.txt
- name: Build wheels
uses: home-assistant/wheels@2023.04.0
uses: home-assistant/wheels@2023.10.1
with:
abi: cp311
tag: musllinux_1_2

View File

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

View File

@@ -1,3 +1,4 @@
CLA.md
CODE_OF_CONDUCT.md
LICENSE.md
PULL_REQUEST_TEMPLATE.md

View File

@@ -165,6 +165,7 @@ const createWebpackConfig = ({
"lit/directives/guard$": "lit/directives/guard.js",
"lit/directives/cache$": "lit/directives/cache.js",
"lit/directives/repeat$": "lit/directives/repeat.js",
"lit/directives/live$": "lit/directives/live.js",
"lit/polyfill-support$": "lit/polyfill-support.js",
"@lit-labs/virtualizer/layouts/grid":
"@lit-labs/virtualizer/layouts/grid.js",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -32,6 +32,8 @@ import { HassElement } from "../../../../src/state/hass-element";
import { castContext } from "../cast_context";
import "./hc-launch-screen";
const DEFAULT_STRATEGY = "original-states";
let resourcesLoaded = false;
@customElement("hc-main")
export class HcMain extends HassElement {
@@ -258,7 +260,7 @@ export class HcMain extends HassElement {
{
strategy: {
type: "energy",
options: { show_date_selection: true },
show_date_selection: true,
},
},
],
@@ -320,10 +322,10 @@ export class HcMain extends HassElement {
this._handleNewLovelaceConfig(
await generateLovelaceDashboardStrategy(
{
hass: this.hass!,
narrow: false,
type: DEFAULT_STRATEGY,
},
"original-states"
this.hass!,
{ narrow: false }
)
);
}

View File

@@ -8,25 +8,67 @@
"src": "/static/icons/favicon-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable any"
"purpose": "any"
},
{
"src": "/static/icons/favicon-384x384.png",
"sizes": "384x384",
"type": "image/png",
"purpose": "maskable any"
"purpose": "any"
},
{
"src": "/static/icons/favicon-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable any"
"purpose": "any"
},
{
"src": "/static/icons/favicon-1024x1024.png",
"sizes": "1024x1024",
"type": "image/png",
"purpose": "maskable any"
"purpose": "any"
},
{
"src": "/static/icons/maskable_icon-48x48.png",
"sizes": "48x48",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/static/icons/maskable_icon-72x72.png",
"sizes": "72x72",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/static/icons/maskable_icon-96x96.png",
"sizes": "96x96",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/static/icons/maskable_icon-128x128.png",
"sizes": "128x128",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/static/icons/maskable_icon-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/static/icons/maskable_icon-384x384.png",
"sizes": "384x384",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/static/icons/maskable_icon-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"lang": "en-US",

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -1,10 +1,10 @@
import { mdiHomeAssistant } from "@mdi/js";
import { css, html, LitElement, TemplateResult } from "lit";
import { customElement } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-chip";
import "../../../../src/components/ha-chip-set";
import "../../../../src/components/ha-svg-icon";
import { mdiHomeAssistant } from "../../../../src/resources/home-assistant-logo-svg";
const chips: {
icon?: string;

View File

@@ -7,7 +7,6 @@ import {
mdiDocker,
mdiExclamationThick,
mdiFlask,
mdiHomeAssistant,
mdiKey,
mdiLinkLock,
mdiNetwork,
@@ -22,7 +21,7 @@ import {
mdiPound,
mdiShield,
} from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { CSSResultGroup, LitElement, TemplateResult, css, html } from "lit";
import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import memoizeOne from "memoize-one";
@@ -40,11 +39,11 @@ import "../../../../src/components/ha-svg-icon";
import "../../../../src/components/ha-switch";
import {
AddonCapability,
fetchHassioAddonChangelog,
fetchHassioAddonInfo,
HassioAddonDetails,
HassioAddonSetOptionParams,
HassioAddonSetSecurityParams,
fetchHassioAddonChangelog,
fetchHassioAddonInfo,
installHassioAddon,
rebuildLocalAddon,
restartHassioAddon,
@@ -56,9 +55,9 @@ import {
validateHassioAddonOption,
} from "../../../../src/data/hassio/addon";
import {
HassioStats,
extractApiErrorMessage,
fetchHassioStats,
HassioStats,
} from "../../../../src/data/hassio/common";
import {
StoreAddon,
@@ -69,6 +68,7 @@ import {
showAlertDialog,
showConfirmationDialog,
} from "../../../../src/dialogs/generic/show-dialog-box";
import { mdiHomeAssistant } from "../../../../src/resources/home-assistant-logo-svg";
import { haStyle } from "../../../../src/resources/styles";
import { HomeAssistant, Route } from "../../../../src/types";
import { bytesToString } from "../../../../src/util/bytes-to-string";

View File

@@ -1,13 +1,13 @@
import { mdiFolder, mdiHomeAssistant, mdiPuzzle } from "@mdi/js";
import { mdiFolder, mdiPuzzle } from "@mdi/js";
import "@polymer/paper-input/paper-input";
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
import {
css,
CSSResultGroup,
html,
LitElement,
nothing,
TemplateResult,
css,
html,
nothing,
} from "lit";
import { customElement, property, query } from "lit/decorators";
import { atLeastVersion } from "../../../src/common/config/version";
@@ -24,6 +24,7 @@ import {
HassioPartialBackupCreateParams,
} from "../../../src/data/hassio/backup";
import { Supervisor } from "../../../src/data/supervisor/supervisor";
import { mdiHomeAssistant } from "../../../src/resources/home-assistant-logo-svg";
import {
HomeAssistant,
TranslationDict,

View File

@@ -1,5 +1,4 @@
import "@material/mwc-button";
import { mdiHomeAssistant } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
@@ -13,6 +12,7 @@ import {
HassioSupervisorInfo,
} from "../../../src/data/hassio/supervisor";
import { Supervisor } from "../../../src/data/supervisor/supervisor";
import { mdiHomeAssistant } from "../../../src/resources/home-assistant-logo-svg";
import { haStyle } from "../../../src/resources/styles";
import { HomeAssistant } from "../../../src/types";
import { hassioStyle } from "../resources/hassio-style";

View File

@@ -25,17 +25,17 @@
"license": "Apache-2.0",
"type": "module",
"dependencies": {
"@babel/runtime": "7.22.15",
"@babel/runtime": "7.23.1",
"@braintree/sanitize-url": "6.0.4",
"@codemirror/autocomplete": "6.9.1",
"@codemirror/commands": "6.2.5",
"@codemirror/language": "6.9.0",
"@codemirror/language": "6.9.1",
"@codemirror/legacy-modes": "6.3.3",
"@codemirror/search": "6.5.3",
"@codemirror/search": "6.5.4",
"@codemirror/state": "6.2.1",
"@codemirror/view": "6.19.0",
"@codemirror/view": "6.20.2",
"@egjs/hammerjs": "2.0.17",
"@formatjs/intl-datetimeformat": "6.10.2",
"@formatjs/intl-datetimeformat": "6.10.3",
"@formatjs/intl-displaynames": "6.5.2",
"@formatjs/intl-getcanonicallocales": "2.2.1",
"@formatjs/intl-listformat": "7.4.2",
@@ -43,12 +43,12 @@
"@formatjs/intl-numberformat": "8.7.2",
"@formatjs/intl-pluralrules": "5.2.6",
"@formatjs/intl-relativetimeformat": "11.2.6",
"@fullcalendar/core": "6.1.8",
"@fullcalendar/daygrid": "6.1.8",
"@fullcalendar/interaction": "6.1.8",
"@fullcalendar/list": "6.1.8",
"@fullcalendar/luxon3": "6.1.8",
"@fullcalendar/timegrid": "6.1.8",
"@fullcalendar/core": "6.1.9",
"@fullcalendar/daygrid": "6.1.9",
"@fullcalendar/interaction": "6.1.9",
"@fullcalendar/list": "6.1.9",
"@fullcalendar/luxon3": "6.1.9",
"@fullcalendar/timegrid": "6.1.9",
"@lezer/highlight": "1.1.6",
"@lit-labs/context": "0.4.1",
"@lit-labs/motion": "1.0.4",
@@ -62,6 +62,7 @@
"@material/mwc-dialog": "0.27.0",
"@material/mwc-drawer": "0.27.0",
"@material/mwc-fab": "0.27.0",
"@material/mwc-floating-label": "0.27.0",
"@material/mwc-formfield": "0.27.0",
"@material/mwc-icon-button": "0.27.0",
"@material/mwc-linear-progress": "0.27.0",
@@ -93,8 +94,8 @@
"@polymer/paper-toast": "3.0.1",
"@polymer/polymer": "3.5.1",
"@thomasloven/round-slider": "0.6.0",
"@vaadin/combo-box": "24.1.7",
"@vaadin/vaadin-themable-mixin": "24.1.7",
"@vaadin/combo-box": "24.1.9",
"@vaadin/vaadin-themable-mixin": "24.1.9",
"@vibrant/color": "3.2.1-alpha.1",
"@vibrant/core": "3.2.1-alpha.1",
"@vibrant/quantizer-mmcq": "3.2.1-alpha.1",
@@ -102,10 +103,10 @@
"@webcomponents/scoped-custom-element-registry": "0.0.9",
"@webcomponents/webcomponentsjs": "2.8.0",
"app-datepicker": "5.1.1",
"chart.js": "4.3.3",
"chart.js": "4.4.0",
"comlink": "4.4.1",
"core-js": "3.32.2",
"cropperjs": "1.6.0",
"cropperjs": "1.6.1",
"date-fns": "2.30.0",
"date-fns-tz": "2.0.0",
"deep-clone-simple": "1.1.1",
@@ -115,13 +116,13 @@
"hls.js": "1.4.12",
"home-assistant-js-websocket": "8.2.0",
"idb-keyval": "6.2.1",
"intl-messageformat": "10.5.2",
"intl-messageformat": "10.5.3",
"js-yaml": "4.1.0",
"leaflet": "1.9.4",
"leaflet-draw": "1.0.4",
"lit": "2.8.0",
"luxon": "3.4.3",
"marked": "7.0.5",
"marked": "9.0.3",
"memoize-one": "6.0.0",
"node-vibrant": "3.2.1-alpha.1",
"proxy-polyfill": "0.3.2",
@@ -153,16 +154,16 @@
"xss": "1.0.14"
},
"devDependencies": {
"@babel/core": "7.22.20",
"@babel/plugin-proposal-decorators": "7.22.15",
"@babel/core": "7.23.0",
"@babel/plugin-proposal-decorators": "7.23.0",
"@babel/plugin-transform-runtime": "7.22.15",
"@babel/preset-env": "7.22.20",
"@babel/preset-typescript": "7.22.15",
"@babel/preset-typescript": "7.23.0",
"@koa/cors": "4.0.0",
"@lokalise/node-api": "11.0.1",
"@octokit/auth-oauth-device": "6.0.0",
"@octokit/plugin-retry": "6.0.0",
"@octokit/rest": "20.0.1",
"@lokalise/node-api": "12.0.0",
"@octokit/auth-oauth-device": "6.0.1",
"@octokit/plugin-retry": "6.0.1",
"@octokit/rest": "20.0.2",
"@open-wc/dev-server-hmr": "0.1.4",
"@rollup/plugin-babel": "6.0.3",
"@rollup/plugin-commonjs": "25.0.4",
@@ -172,29 +173,29 @@
"@types/babel__plugin-transform-runtime": "7.9.3",
"@types/chromecast-caf-receiver": "6.0.10",
"@types/chromecast-caf-sender": "1.0.6",
"@types/esprima": "4.0.3",
"@types/esprima": "4.0.4",
"@types/glob": "8.1.0",
"@types/html-minifier-terser": "7.0.0",
"@types/js-yaml": "4.0.6",
"@types/leaflet": "1.9.4",
"@types/leaflet": "1.9.6",
"@types/leaflet-draw": "1.0.8",
"@types/luxon": "3.3.2",
"@types/mocha": "10.0.1",
"@types/mocha": "10.0.2",
"@types/qrcode": "1.5.2",
"@types/serve-handler": "6.1.1",
"@types/sortablejs": "1.15.2",
"@types/serve-handler": "6.1.2",
"@types/sortablejs": "1.15.3",
"@types/tar": "6.1.6",
"@types/ua-parser-js": "0.7.37",
"@types/webspeechapi": "0.0.29",
"@typescript-eslint/eslint-plugin": "6.7.0",
"@typescript-eslint/parser": "6.7.0",
"@typescript-eslint/eslint-plugin": "6.7.3",
"@typescript-eslint/parser": "6.7.3",
"@web/dev-server": "0.1.38",
"@web/dev-server-rollup": "0.4.1",
"babel-loader": "9.1.3",
"babel-plugin-template-html-minifier": "4.1.0",
"chai": "4.3.8",
"chai": "4.3.10",
"del": "7.1.0",
"eslint": "8.49.0",
"eslint": "8.50.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "17.1.0",
"eslint-config-prettier": "9.0.0",
@@ -202,13 +203,13 @@
"eslint-plugin-disable": "2.0.3",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-lit": "1.9.1",
"eslint-plugin-lit-a11y": "3.0.0",
"eslint-plugin-lit-a11y": "4.1.0",
"eslint-plugin-unused-imports": "3.0.0",
"eslint-plugin-wc": "1.5.0",
"eslint-plugin-wc": "2.0.4",
"esprima": "4.0.1",
"fancy-log": "2.0.0",
"fs-extra": "11.1.1",
"glob": "10.3.4",
"glob": "10.3.10",
"gulp": "4.0.2",
"gulp-flatmap": "1.0.2",
"gulp-json-transform": "0.4.8",

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/static/icons/tile-win-70x70.png"/>
<square150x150logo src="/static/icons/tile-win-150x150.png"/>
<wide310x150logo src="/static/icons/tile-win-310x150.png"/>
<square310x310logo src="/static/icons/tile-win-310x310.png"/>
<TileColor>#18bcf2</TileColor>
</tile>
</msapplication>
</browserconfig>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1 +1,23 @@
<svg width="16" height="16" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path fill-rule="nonzero" fill="#000" d="M9,16 L9,17 L7,17 L7,16 L1,16 L1,9 L-1,9 L8.00163907,0 L13,4.785368 L13,3 L15,3 L15,7.035368 L17,9 L15,9 L15,16 L9,16 Z M9,16 L9,13.5 C9.49775077,13.0022492 10.1813086,12.3186914 11.0506735,11.4493265 C11.1951058,11.4824829 11.3455072,11.5 11.5,11.5 C12.6045695,11.5 13.5,10.6045695 13.5,9.5 C13.5,8.3954305 12.6045695,7.5 11.5,7.5 C10.3954305,7.5 9.5,8.3954305 9.5,9.5 C9.5,9.65449279 9.5175171,9.80489423 9.55067348,9.94932652 L9,10.5 L9,7.73243561 C9.59780137,7.38662619 10,6.74028236 10,6 C10,4.8954305 9.1045695,4 8,4 C6.8954305,4 6,4.8954305 6,6 C6,6.74028236 6.40219863,7.38662619 7,7.73243561 L7,10.5 L6.44932652,9.94932652 C6.4824829,9.80489423 6.5,9.65449279 6.5,9.5 C6.5,8.3954305 5.6045695,7.5 4.5,7.5 C3.3954305,7.5 2.5,8.3954305 2.5,9.5 C2.5,10.6045695 3.3954305,11.5 4.5,11.5 C4.65352068,11.5 4.80300134,11.4827027 4.9465994,11.4499505 C5.81726201,12.3268973 6.50172888,13.0147433 7,13.5134884 L7,16 L9,16 Z M11.5,10 C11.2238576,10 11,9.77614237 11,9.5 C11,9.22385763 11.2238576,9 11.5,9 C11.7761424,9 12,9.22385763 12,9.5 C12,9.77614237 11.7761424,10 11.5,10 Z M4.5,10 C4.22385763,10 4,9.77614237 4,9.5 C4,9.22385763 4.22385763,9 4.5,9 C4.77614237,9 5,9.22385763 5,9.5 C5,9.77614237 4.77614237,10 4.5,10 Z M8,6.5 C7.72385763,6.5 7.5,6.27614237 7.5,6 C7.5,5.72385763 7.72385763,5.5 8,5.5 C8.27614237,5.5 8.5,5.72385763 8.5,6 C8.5,6.27614237 8.27614237,6.5 8,6.5 Z" id="house-small-tree"/></svg>
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="480.000000pt" height="480.000000pt" viewBox="0 0 480.000000 480.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,480.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M2313 4666 c-23 -7 -56 -23 -75 -34 -47 -30 -2059 -2048 -2095 -2102
-45 -67 -77 -135 -109 -230 l-29 -85 0 -995 0 -995 27 -51 c31 -59 93 -118
152 -145 39 -18 83 -19 1001 -19 l960 0 -406 405 c-395 395 -406 406 -433 395
-15 -5 -63 -10 -107 -10 -429 0 -566 577 -181 767 67 34 86 38 164 42 105 4
165 -13 246 -67 113 -74 175 -190 176 -327 1 -44 -3 -96 -7 -115 l-8 -35 316
-315 315 -315 0 1160 -1 1160 -51 35 c-260 177 -226 567 62 704 82 39 209 48
293 21 239 -78 354 -352 242 -575 -32 -63 -89 -125 -141 -156 l-44 -26 0 -811
0 -812 315 315 c218 217 313 320 309 330 -14 35 -16 134 -4 190 26 122 111
227 230 284 82 39 209 48 293 21 115 -38 214 -130 258 -242 19 -46 23 -78 24
-153 0 -86 -3 -101 -32 -163 -40 -84 -118 -163 -198 -202 -49 -23 -77 -29
-150 -33 -50 -2 -108 1 -130 7 l-40 11 -437 -438 -438 -437 0 -307 0 -308 998
0 c981 0 998 1 1042 21 58 26 115 81 148 144 l27 50 0 995 0 995 -33 95 c-72
209 -6 135 -1147 1278 -840 843 -1040 1037 -1082 1059 -64 31 -159 39 -220 19z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 992 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 824 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 852 B

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "home-assistant-frontend"
version = "20230911.0"
version = "20231002.0"
license = {text = "Apache-2.0"}
description = "The Home Assistant frontend"
readme = "README.md"

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Helper to start Home Assistant Core inside the devcontainer
# Stop on errors
@@ -11,11 +11,35 @@ if [ -z "${DEVCONTAINER}" ]; then
exit 1
fi
if [ -z $(which hass) ]; then
echo "Installing Home Asstant core from dev."
python3 -m pip install --upgrade \
colorlog \
git+https://github.com/home-assistant/home-assistant.git@dev
# Default to installing (or upgrading to) dev branch
coreURL="https://github.com/home-assistant/core.git"
ref="dev"
while getopts "hr:s" opt; do
case $opt in
h) # Help
echo "Usage: $0 [-h|-r <ref>|-s]"
echo -n "Install and run core at the given ref, i.e. branch, tag, or commit. The dev branch is used if no option is specified."
echo "The -s flag skips the install/upgrade, using whatever version is currently installed."
exit 0
;;
r) # Git ref
ref="${OPTARG}"
;;
s) # Skip (use current install)
ref=""
;;
*)
echo "Try $0 -h for help" >&2
exit 1
;;
esac
done
if [ -n "$ref" ]; then
echo "Installing Home Assistant core at ${ref}..."
python3 -m pip install --user --upgrade --src "$HOME/src" \
--editable "git+${coreURL}@${ref}#egg=homeassistant"
fi
if [ ! -d "${WD}/config" ]; then
@@ -30,7 +54,7 @@ logger:
homeassistant.components.frontend: debug
" >> "${WD}/config/configuration.yaml"
if [ ! -z "${HASSIO}" ]; then
if [ -n "${HASSIO}" ]; then
echo "
# frontend:
# development_repo: ${WD}
@@ -46,7 +70,7 @@ frontend:
# development_repo: ${WD}" >> "${WD}/config/configuration.yaml"
fi
if [ ! -z "${CODESPACES}" ]; then
if [ -n "${CODESPACES}" ]; then
echo "
http:
use_x_forwarded_for: true

View File

@@ -1,19 +1,12 @@
/* eslint-disable lit/prefer-static-styles */
import "@material/mwc-button";
import { genClientId } from "home-assistant-js-websocket";
import {
css,
CSSResultGroup,
html,
LitElement,
nothing,
PropertyValues,
} from "lit";
import { html, LitElement, nothing, PropertyValues } from "lit";
import { customElement, property, state } from "lit/decorators";
import { LocalizeFunc } from "../common/translations/localize";
import "../components/ha-alert";
import "../components/ha-checkbox";
import { computeInitialHaFormData } from "../components/ha-form/compute-initial-ha-form-data";
import "../components/ha-form/ha-form";
import "../components/ha-formfield";
import "../components/ha-markdown";
import { AuthProvider, autocompleteLoginFields } from "../data/auth";
@@ -21,7 +14,7 @@ import {
DataEntryFlowStep,
DataEntryFlowStepForm,
} from "../data/data_entry_flow";
import "./ha-password-manager-polyfill";
import "./ha-auth-form";
type State = "loading" | "error" | "step";
@@ -49,6 +42,10 @@ export class HaAuthFlow extends LitElement {
@state() private _storeToken = false;
createRenderRoot() {
return this;
}
willUpdate(changedProps: PropertyValues) {
super.willUpdate(changedProps);
@@ -79,13 +76,17 @@ export class HaAuthFlow extends LitElement {
protected render() {
return html`
<style>
ha-auth-flow .action {
margin: 24px 0 8px;
text-align: center;
}
ha-auth-flow .store-token {
margin-top: 10px;
margin-left: -16px;
}
</style>
<form>${this._renderForm()}</form>
<ha-password-manager-polyfill
.step=${this._step}
.stepData=${this._stepData}
@form-submitted=${this._handleSubmit}
@value-changed=${this._stepDataChanged}
></ha-password-manager-polyfill>
`;
}
@@ -128,12 +129,6 @@ export class HaAuthFlow extends LitElement {
(form as any).focus();
}
}, 100);
setTimeout(() => {
this.renderRoot.querySelector(
"ha-password-manager-polyfill"
)!.boundingRect = this.getBoundingClientRect();
}, 500);
}
private _renderForm() {
@@ -205,7 +200,7 @@ export class HaAuthFlow extends LitElement {
></ha-markdown>
`
: nothing}
<ha-form
<ha-auth-form
.data=${this._stepData}
.schema=${autocompleteLoginFields(step.data_schema)}
.error=${step.errors}
@@ -213,7 +208,7 @@ export class HaAuthFlow extends LitElement {
.computeLabel=${this._computeLabelCallback(step)}
.computeError=${this._computeErrorCallback(step)}
@value-changed=${this._stepDataChanged}
></ha-form>
></ha-auth-form>
${this.clientId === genClientId() &&
!["select_mfa_module", "mfa"].includes(step.step_id)
? html`
@@ -395,20 +390,6 @@ export class HaAuthFlow extends LitElement {
this._submitting = false;
}
}
static get styles(): CSSResultGroup {
return css`
.action {
margin: 24px 0 8px;
text-align: center;
}
/* Align with the rest of the form. */
.store-token {
margin-top: 10px;
margin-left: -16px;
}
`;
}
}
declare global {

View File

@@ -0,0 +1,77 @@
/* eslint-disable lit/prefer-static-styles */
import { TemplateResult, html } from "lit";
import { customElement } from "lit/decorators";
import { HaFormString } from "../components/ha-form/ha-form-string";
import "../components/ha-icon-button";
import "./ha-auth-textfield";
@customElement("ha-auth-form-string")
export class HaAuthFormString extends HaFormString {
protected createRenderRoot() {
return this;
}
protected render(): TemplateResult {
return html`
<style>
ha-auth-form-string {
display: block;
position: relative;
}
ha-auth-form-string[own-margin] {
margin-bottom: 5px;
}
ha-auth-form-string ha-auth-textfield {
display: block !important;
}
ha-auth-form-string ha-icon-button {
position: absolute;
top: 1em;
right: 12px;
--mdc-icon-button-size: 24px;
color: var(--secondary-text-color);
}
ha-auth-form-string ha-icon-button {
inset-inline-start: initial;
inset-inline-end: 12px;
direction: var(--direction);
}
</style>
<ha-auth-textfield
.type=${
!this.isPassword
? this.stringType
: this.unmaskedPassword
? "text"
: "password"
}
.label=${this.label}
.value=${this.data || ""}
.helper=${this.helper}
helperPersistent
.disabled=${this.disabled}
.required=${this.schema.required}
.autoValidate=${this.schema.required}
.name=${this.schema.name}
.autocomplete=${this.schema.autocomplete}
.suffix=${
this.isPassword
? // reserve some space for the icon.
html`<div style="width: 24px"></div>`
: this.schema.description?.suffix
}
.validationMessage=${this.schema.required ? "Required" : undefined}
@input=${this._valueChanged}
@change=${this._valueChanged}
></ha-auth-textfield>
${this.renderIcon()}
</ha-auth-textfield>
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"ha-auth-form-string": HaAuthFormString;
}
}

44
src/auth/ha-auth-form.ts Normal file
View File

@@ -0,0 +1,44 @@
/* eslint-disable lit/prefer-static-styles */
import { html } from "lit";
import { customElement } from "lit/decorators";
import { HaForm } from "../components/ha-form/ha-form";
import "./ha-auth-form-string";
@customElement("ha-auth-form")
export class HaAuthForm extends HaForm {
protected fieldElementName(type: string): string {
if (type === "string") {
return `ha-auth-form-${type}`;
}
return super.fieldElementName(type);
}
protected createRenderRoot() {
// attach it as soon as possible to make sure we fetch all events.
this.addValueChangedListener(this);
return this;
}
protected render() {
return html`
<style>
ha-auth-form .root > * {
display: block;
}
ha-auth-form .root > *:not([own-margin]):not(:last-child) {
margin-bottom: 24px;
}
ha-auth-form ha-alert[own-margin] {
margin-bottom: 4px;
}
</style>
${super.render()}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"ha-auth-form": HaAuthForm;
}
}

View File

@@ -0,0 +1,254 @@
/* eslint-disable lit/value-after-constraints */
/* eslint-disable lit/prefer-static-styles */
import { floatingLabel } from "@material/mwc-floating-label/mwc-floating-label-directive";
import { TemplateResult, html } from "lit";
import { customElement } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import { live } from "lit/directives/live";
import { HaTextField } from "../components/ha-textfield";
@customElement("ha-auth-textfield")
export class HaAuthTextField extends HaTextField {
protected renderLabel(): TemplateResult | string {
return !this.label
? ""
: html`
<span
.floatingLabelFoundation=${floatingLabel(
this.label
) as unknown as any}
.id=${this.name}
>${this.label}</span
>
`;
}
protected renderInput(shouldRenderHelperText: boolean): TemplateResult {
const minOrUndef = this.minLength === -1 ? undefined : this.minLength;
const maxOrUndef = this.maxLength === -1 ? undefined : this.maxLength;
const autocapitalizeOrUndef = this.autocapitalize
? (this.autocapitalize as
| "off"
| "none"
| "on"
| "sentences"
| "words"
| "characters")
: undefined;
const showValidationMessage = this.validationMessage && !this.isUiValid;
const ariaLabelledbyOrUndef = this.label ? this.name : undefined;
const ariaControlsOrUndef = shouldRenderHelperText
? "helper-text"
: undefined;
const ariaDescribedbyOrUndef =
this.focused || this.helperPersistent || showValidationMessage
? "helper-text"
: undefined;
// TODO: live() directive needs casting for lit-analyzer
// https://github.com/runem/lit-analyzer/pull/91/files
// TODO: lit-analyzer labels min/max as (number|string) instead of string
return html` <input
aria-labelledby=${ifDefined(ariaLabelledbyOrUndef)}
aria-controls=${ifDefined(ariaControlsOrUndef)}
aria-describedby=${ifDefined(ariaDescribedbyOrUndef)}
class="mdc-text-field__input"
type=${this.type}
.value=${live(this.value) as unknown as string}
?disabled=${this.disabled}
placeholder=${this.placeholder}
?required=${this.required}
?readonly=${this.readOnly}
minlength=${ifDefined(minOrUndef)}
maxlength=${ifDefined(maxOrUndef)}
pattern=${ifDefined(this.pattern ? this.pattern : undefined)}
min=${ifDefined(this.min === "" ? undefined : (this.min as number))}
max=${ifDefined(this.max === "" ? undefined : (this.max as number))}
step=${ifDefined(this.step === null ? undefined : (this.step as number))}
size=${ifDefined(this.size === null ? undefined : this.size)}
name=${ifDefined(this.name === "" ? undefined : this.name)}
inputmode=${ifDefined(this.inputMode)}
autocapitalize=${ifDefined(autocapitalizeOrUndef)}
@input=${this.handleInputChange}
@focus=${this.onInputFocus}
@blur=${this.onInputBlur}
/>`;
}
public render() {
return html`
<style>
ha-auth-textfield {
display: inline-flex;
flex-direction: column;
outline: none;
}
ha-auth-textfield:not([disabled]):hover
:not(.mdc-text-field--invalid):not(.mdc-text-field--focused)
mwc-notched-outline {
--mdc-notched-outline-border-color: var(
--mdc-text-field-outlined-hover-border-color,
rgba(0, 0, 0, 0.87)
);
}
ha-auth-textfield:not([disabled])
.mdc-text-field:not(.mdc-text-field--outlined) {
background-color: var(--mdc-text-field-fill-color, whitesmoke);
}
ha-auth-textfield:not([disabled])
.mdc-text-field.mdc-text-field--invalid
mwc-notched-outline {
--mdc-notched-outline-border-color: var(
--mdc-text-field-error-color,
var(--mdc-theme-error, #b00020)
);
}
ha-auth-textfield:not([disabled])
.mdc-text-field.mdc-text-field--invalid
+ .mdc-text-field-helper-line
.mdc-text-field-character-counter,
ha-auth-textfield:not([disabled])
.mdc-text-field.mdc-text-field--invalid
.mdc-text-field__icon {
color: var(
--mdc-text-field-error-color,
var(--mdc-theme-error, #b00020)
);
}
ha-auth-textfield:not([disabled])
.mdc-text-field:not(.mdc-text-field--invalid):not(
.mdc-text-field--focused
)
.mdc-floating-label,
ha-auth-textfield:not([disabled])
.mdc-text-field:not(.mdc-text-field--invalid):not(
.mdc-text-field--focused
)
.mdc-floating-label::after {
color: var(--mdc-text-field-label-ink-color, rgba(0, 0, 0, 0.6));
}
ha-auth-textfield:not([disabled])
.mdc-text-field.mdc-text-field--focused
mwc-notched-outline {
--mdc-notched-outline-stroke-width: 2px;
}
ha-auth-textfield:not([disabled])
.mdc-text-field.mdc-text-field--focused:not(.mdc-text-field--invalid)
mwc-notched-outline {
--mdc-notched-outline-border-color: var(
--mdc-text-field-focused-label-color,
var(--mdc-theme-primary, rgba(98, 0, 238, 0.87))
);
}
ha-auth-textfield:not([disabled])
.mdc-text-field.mdc-text-field--focused:not(.mdc-text-field--invalid)
.mdc-floating-label {
color: #6200ee;
color: var(--mdc-theme-primary, #6200ee);
}
ha-auth-textfield:not([disabled])
.mdc-text-field
.mdc-text-field__input {
color: var(--mdc-text-field-ink-color, rgba(0, 0, 0, 0.87));
}
ha-auth-textfield:not([disabled])
.mdc-text-field
.mdc-text-field__input::placeholder {
color: var(--mdc-text-field-label-ink-color, rgba(0, 0, 0, 0.6));
}
ha-auth-textfield:not([disabled])
.mdc-text-field-helper-line
.mdc-text-field-helper-text:not(
.mdc-text-field-helper-text--validation-msg
),
ha-auth-textfield:not([disabled])
.mdc-text-field-helper-line:not(.mdc-text-field--invalid)
.mdc-text-field-character-counter {
color: var(--mdc-text-field-label-ink-color, rgba(0, 0, 0, 0.6));
}
ha-auth-textfield[disabled]
.mdc-text-field:not(.mdc-text-field--outlined) {
background-color: var(--mdc-text-field-disabled-fill-color, #fafafa);
}
ha-auth-textfield[disabled]
.mdc-text-field.mdc-text-field--outlined
mwc-notched-outline {
--mdc-notched-outline-border-color: var(
--mdc-text-field-outlined-disabled-border-color,
rgba(0, 0, 0, 0.06)
);
}
ha-auth-textfield[disabled]
.mdc-text-field:not(.mdc-text-field--invalid):not(
.mdc-text-field--focused
)
.mdc-floating-label,
ha-auth-textfield[disabled]
.mdc-text-field:not(.mdc-text-field--invalid):not(
.mdc-text-field--focused
)
.mdc-floating-label::after {
color: var(--mdc-text-field-disabled-ink-color, rgba(0, 0, 0, 0.38));
}
ha-auth-textfield[disabled] .mdc-text-field .mdc-text-field__input,
ha-auth-textfield[disabled]
.mdc-text-field
.mdc-text-field__input::placeholder {
color: var(--mdc-text-field-disabled-ink-color, rgba(0, 0, 0, 0.38));
}
ha-auth-textfield[disabled]
.mdc-text-field-helper-line
.mdc-text-field-helper-text,
ha-auth-textfield[disabled]
.mdc-text-field-helper-line
.mdc-text-field-character-counter {
color: var(--mdc-text-field-disabled-ink-color, rgba(0, 0, 0, 0.38));
}
ha-auth-textfield:not([disabled])
.mdc-text-field.mdc-text-field--focused:not(.mdc-text-field--invalid)
.mdc-floating-label {
color: var(--mdc-theme-primary, #6200ee);
}
ha-auth-textfield[no-spinner] input::-webkit-outer-spin-button,
ha-auth-textfield[no-spinner] input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
ha-auth-textfield[no-spinner] input[type="number"] {
-moz-appearance: textfield;
}
</style>
${super.render()}
`;
}
protected createRenderRoot() {
// add parent style to light dom
const style = document.createElement("style");
style.textContent = HaTextField.elementStyles as unknown as string;
this.append(style);
return this;
}
}
declare global {
interface HTMLElementTagNameMap {
"ha-auth-textfield": HaAuthTextField;
}
}

View File

@@ -1,13 +1,7 @@
import punycode from "punycode";
import {
css,
CSSResultGroup,
html,
LitElement,
nothing,
PropertyValues,
} from "lit";
/* eslint-disable lit/prefer-static-styles */
import { html, LitElement, nothing, PropertyValues } from "lit";
import { customElement, property, state } from "lit/decorators";
import punycode from "punycode";
import { applyThemesOnElement } from "../common/dom/apply_themes_on_element";
import { extractSearchParamsObject } from "../common/url/search-params";
import "../components/ha-alert";
@@ -61,13 +55,27 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
protected render() {
if (this._error) {
return html`<ha-alert alert-type="error"
>${this._error} ${this.redirectUri}</ha-alert
>`;
return html`
<style>
ha-authorize ha-alert {
display: block;
margin: 16px 0;
}
</style>
<ha-alert alert-type="error"
>${this._error} ${this.redirectUri}</ha-alert
>
`;
}
if (!this._authProviders) {
return html`
<style>
ha-authorize p {
font-size: 14px;
line-height: 20px;
}
</style>
<p>${this.localize("ui.panel.page-authorize.initializing")}</p>
`;
}
@@ -79,6 +87,25 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
const app = this.clientId && this.clientId in appNames;
return html`
<style>
ha-pick-auth-provider {
display: block;
margin-top: 48px;
}
ha-auth-flow {
display: block;
margin-top: 24px;
}
ha-alert {
display: block;
margin: 16px 0;
}
p {
font-size: 14px;
line-height: 20px;
}
</style>
${!this._ownInstance
? html`<ha-alert .alertType=${app ? "info" : "warning"}>
${app
@@ -123,6 +150,10 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
`;
}
createRenderRoot() {
return this;
}
protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps);
@@ -217,25 +248,4 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
private async _handleAuthProviderPick(ev) {
this._authProvider = ev.detail;
}
static get styles(): CSSResultGroup {
return css`
ha-pick-auth-provider {
display: block;
margin-top: 48px;
}
ha-auth-flow {
display: block;
margin-top: 24px;
}
ha-alert {
display: block;
margin: 16px 0;
}
p {
font-size: 14px;
line-height: 20px;
}
`;
}
}

View File

@@ -1,172 +0,0 @@
import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { styleMap } from "lit/directives/style-map";
import { fireEvent } from "../common/dom/fire_event";
import type { HaFormSchema } from "../components/ha-form/types";
import { autocompleteLoginFields } from "../data/auth";
import type { DataEntryFlowStep } from "../data/data_entry_flow";
declare global {
interface HTMLElementTagNameMap {
"ha-password-manager-polyfill": HaPasswordManagerPolyfill;
}
interface HASSDomEvents {
"form-submitted": undefined;
}
}
const ENABLED_HANDLERS = [
"homeassistant",
"legacy_api_password",
"command_line",
];
@customElement("ha-password-manager-polyfill")
export class HaPasswordManagerPolyfill extends LitElement {
@property({ attribute: false }) public step?: DataEntryFlowStep;
@property({ attribute: false }) public stepData: any;
@property({ attribute: false }) public boundingRect?: DOMRect;
private _styleElement?: HTMLStyleElement;
public connectedCallback() {
super.connectedCallback();
this._styleElement = document.createElement("style");
this._styleElement.textContent = css`
/* Polyfill form is sized and vertically aligned with true form, then positioned offscreen
rather than hiding so it does not create a new stacking context */
.password-manager-polyfill {
position: absolute;
box-sizing: border-box;
}
/* Excluding our wrapper, move any children back on screen, including anything injected that might not already be positioned */
.password-manager-polyfill > *:not(.wrapper),
.password-manager-polyfill > .wrapper > * {
position: relative;
left: 10000px;
}
/* Size and hide our polyfill fields */
.password-manager-polyfill .underneath {
display: block;
box-sizing: border-box;
width: 100%;
padding: 0 16px;
border: 0;
z-index: -1;
height: 21px;
/* Transparency is only needed to hide during paint or in case of misalignment,
but LastPass will fail if it's 0, so we use 1% */
opacity: 0.01;
}
.password-manager-polyfill input.underneath {
height: 28px;
margin-bottom: 30.5px;
}
/* Button position is not important, but size should not be zero */
.password-manager-polyfill > input.underneath[type="submit"] {
width: 1px;
height: 1px;
margin: 0 auto;
overflow: hidden;
}
/* Ensure injected elements will be on top */
.password-manager-polyfill > *:not(.underneath, .wrapper),
.password-manager-polyfill > .wrapper > *:not(.underneath) {
isolation: isolate;
z-index: auto;
}
`.toString();
document.head.append(this._styleElement);
}
public disconnectedCallback() {
super.disconnectedCallback();
this._styleElement?.remove();
delete this._styleElement;
}
protected createRenderRoot() {
// Add under document body so the element isn't placed inside any shadow roots
return document.body;
}
protected render() {
if (
this.step &&
this.step.type === "form" &&
this.step.step_id === "init" &&
ENABLED_HANDLERS.includes(this.step.handler[0])
) {
return html`
<form
class="password-manager-polyfill"
style=${styleMap({
top: `${this.boundingRect?.y || 148}px`,
left: `calc(50% - ${
(this.boundingRect?.width || 360) / 2
}px - 10000px)`,
width: `${this.boundingRect?.width || 360}px`,
})}
action="/auth"
method="post"
@submit=${this._handleSubmit}
>
${autocompleteLoginFields(this.step.data_schema).map((input) =>
this.render_input(input)
)}
<input
type="submit"
value="Login"
class="underneath"
tabindex="-2"
aria-hidden="true"
/>
</form>
`;
}
return nothing;
}
private render_input(schema: HaFormSchema) {
const inputType = schema.name.includes("password") ? "password" : "text";
if (schema.type !== "string") {
return "";
}
return html`
<!-- Label is a sibling so it can be stacked underneath without affecting injections adjacent to input (e.g. LastPass) -->
<label for=${schema.name} class="underneath" aria-hidden="true">
${schema.name}
</label>
<!-- LastPass fails if the input is hidden directly, so we trick it and hide a wrapper instead -->
<div class="wrapper" aria-hidden="true">
<!-- LastPass fails with tabindex of -1, so we trick with -2 -->
<input
class="underneath"
tabindex="-2"
.id=${schema.name}
.name=${schema.name}
.type=${inputType}
.value=${this.stepData[schema.name] || ""}
.autocomplete=${schema.autocomplete}
@input=${this._valueChanged}
@change=${this._valueChanged}
/>
</div>
`;
}
private _handleSubmit(ev: SubmitEvent) {
ev.preventDefault();
fireEvent(this, "form-submitted");
}
private _valueChanged(ev: Event) {
const target = ev.target as HTMLInputElement;
this.stepData = { ...this.stepData, [target.id]: target.value };
fireEvent(this, "value-changed", {
value: this.stepData,
});
}
}

View File

@@ -15,6 +15,7 @@ import {
mdiCalendarClock,
mdiCarCoolantLevel,
mdiCash,
mdiChatSleep,
mdiClock,
mdiCloudUpload,
mdiCog,
@@ -31,7 +32,6 @@ import {
mdiGauge,
mdiGoogleAssistant,
mdiGoogleCirclesCommunities,
mdiHomeAssistant,
mdiHomeAutomation,
mdiImage,
mdiImageFilterFrames,
@@ -70,6 +70,8 @@ import {
mdiWifi,
} from "@mdi/js";
import { mdiHomeAssistant } from "../resources/home-assistant-logo-svg";
// Constants should be alphabetically sorted by name.
// Arrays with values should be alphabetically sorted if order doesn't matter.
// Each constant should have a description what it is supposed to be used for.
@@ -123,6 +125,7 @@ export const FIXED_DOMAIN_ICONS = {
tts: mdiSpeakerMessage,
updater: mdiCloudUpload,
vacuum: mdiRobotVacuum,
wake_word: mdiChatSleep,
zone: mdiMapMarkerRadius,
};

View File

@@ -1,5 +1,5 @@
import { ThemeVars } from "../../data/ws-themes";
import { darkStyles, derivedStyles } from "../../resources/styles";
import { darkStyles, derivedStyles } from "../../resources/styles-data";
import type { HomeAssistant } from "../../types";
import {
hex2rgb,

View File

@@ -193,6 +193,7 @@ export const computeStateDisplayFromEntityAttributes = (
"scene",
"stt",
"tts",
"wake_word",
].includes(domain) ||
(domain === "sensor" && attributes.device_class === "timestamp")
) {

View File

@@ -7,7 +7,7 @@ export const computeStateNameFromEntityAttributes = (
): string =>
attributes.friendly_name === undefined
? computeObjectId(entityId).replace(/_/g, " ")
: attributes.friendly_name || "";
: (attributes.friendly_name ?? "").toString();
export const computeStateName = (stateObj: HassEntity): string =>
computeStateNameFromEntityAttributes(stateObj.entity_id, stateObj.attributes);

View File

@@ -53,13 +53,14 @@ export class HaChartBase extends LitElement {
@state() private _hiddenDatasets: Set<number> = new Set();
public disconnectedCallback() {
this._releaseCanvas();
super.disconnectedCallback();
this._releaseCanvas();
}
public connectedCallback() {
super.connectedCallback();
if (this.hasUpdated) {
this._releaseCanvas();
this._setupChart();
}
}
@@ -110,7 +111,7 @@ export class HaChartBase extends LitElement {
return;
}
if (changedProps.has("plugins") || changedProps.has("chartType")) {
this.chart.destroy();
this._releaseCanvas();
this._setupChart();
return;
}

View File

@@ -35,6 +35,8 @@ export class StateHistoryChartLine extends LitElement {
@property({ type: Boolean }) public showNames = true;
@property({ type: Boolean }) public clickForMoreInfo = true;
@property({ attribute: false }) public startTime!: Date;
@property({ attribute: false }) public endTime!: Date;
@@ -45,6 +47,8 @@ export class StateHistoryChartLine extends LitElement {
@state() private _chartData?: ChartData<"line">;
@state() private _entityIds: string[] = [];
@state() private _chartOptions?: ChartOptions;
@state() private _yWidth = 0;
@@ -171,6 +175,25 @@ export class StateHistoryChartLine extends LitElement {
},
// @ts-expect-error
locale: numberFormatToLocale(this.hass.locale),
onClick: (e: any) => {
if (!this.clickForMoreInfo) {
return;
}
const points = e.chart.getElementsAtEventForMode(
e,
"nearest",
{ intersect: true },
true
);
if (points.length) {
const firstPoint = points[0];
fireEvent(this, "hass-more-info", {
entityId: this._entityIds[firstPoint.datasetIndex],
});
}
},
};
}
if (
@@ -191,6 +214,7 @@ export class StateHistoryChartLine extends LitElement {
const computedStyles = getComputedStyle(this);
const entityStates = this.data;
const datasets: ChartDataset<"line">[] = [];
const entityIds: string[] = [];
if (entityStates.length === 0) {
return;
}
@@ -242,6 +266,7 @@ export class StateHistoryChartLine extends LitElement {
pointRadius: 0,
data: [],
});
entityIds.push(states.entity_id);
};
if (
@@ -493,6 +518,7 @@ export class StateHistoryChartLine extends LitElement {
this._chartData = {
datasets,
};
this._entityIds = entityIds;
}
}
customElements.define("state-history-chart-line", StateHistoryChartLine);

View File

@@ -1,4 +1,5 @@
import type { ChartData, ChartDataset, ChartOptions } from "chart.js";
import { getRelativePosition } from "chart.js/helpers";
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { formatDateTimeWithSeconds } from "../../common/datetime/format_date_time";
@@ -32,6 +33,8 @@ export class StateHistoryChartTimeline extends LitElement {
@property({ type: Boolean }) public showNames = true;
@property({ type: Boolean }) public clickForMoreInfo = true;
@property({ type: Boolean }) public chunked = false;
@property({ attribute: false }) public startTime!: Date;
@@ -220,6 +223,22 @@ export class StateHistoryChartTimeline extends LitElement {
},
// @ts-expect-error
locale: numberFormatToLocale(this.hass.locale),
onClick: (e: any) => {
if (!this.clickForMoreInfo) {
return;
}
const chart = e.chart;
const canvasPosition = getRelativePosition(e, chart);
const index = Math.abs(
chart.scales.y.getValueForPixel(canvasPosition.y)
);
fireEvent(this, "hass-more-info", {
// @ts-ignore
entityId: this._chartData?.datasets[index]?.label,
});
},
};
}

View File

@@ -69,6 +69,8 @@ export class StateHistoryCharts extends LitElement {
@property({ type: Boolean }) public showNames = true;
@property({ type: Boolean }) public clickForMoreInfo = true;
@property({ type: Boolean }) public isLoadingData = false;
@state() private _computedStartTime!: Date;
@@ -181,6 +183,7 @@ export class StateHistoryCharts extends LitElement {
.paddingYAxis=${this._maxYWidth}
.names=${this.names}
.chartIndex=${index}
.clickForMoreInfo=${this.clickForMoreInfo}
@y-width-changed=${this._yWidthChanged}
></state-history-chart-line>
</div> `;
@@ -197,6 +200,7 @@ export class StateHistoryCharts extends LitElement {
.chunked=${this.virtualize}
.paddingYAxis=${this._maxYWidth}
.chartIndex=${index}
.clickForMoreInfo=${this.clickForMoreInfo}
@y-width-changed=${this._yWidthChanged}
></state-history-chart-timeline>
</div> `;

View File

@@ -131,11 +131,15 @@ export class StateBadge extends LitElement {
if (this.hass) {
imageUrl = this.hass.hassUrl(imageUrl);
}
if (computeDomain(stateObj.entity_id) === "camera") {
const domain = computeDomain(stateObj.entity_id);
if (domain === "camera") {
imageUrl = cameraUrlWithWidthHeight(imageUrl, 80, 80);
}
hostStyle.backgroundImage = `url(${imageUrl})`;
this._showIcon = false;
if (domain === "update") {
hostStyle.borderRadius = "0";
}
} else if (this.color) {
// Externally provided overriding color wins over state color
iconStyle.color = this.color;

View File

@@ -41,8 +41,6 @@ export class HaClickableListItem extends HaListItem {
height: 100%;
display: flex;
align-items: center;
padding-left: var(--mdc-list-side-padding, 20px);
padding-right: var(--mdc-list-side-padding, 20px);
overflow: hidden;
}
`,

View File

@@ -1,11 +1,13 @@
/* eslint-disable lit/prefer-static-styles */
import { mdiEye, mdiEyeOff } from "@mdi/js";
import {
css,
CSSResultGroup,
html,
LitElement,
PropertyValues,
TemplateResult,
css,
html,
nothing,
} from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
@@ -32,7 +34,7 @@ export class HaFormString extends LitElement implements HaFormElement {
@property({ type: Boolean }) public disabled = false;
@state() private _unmaskedPassword = false;
@state() protected unmaskedPassword = false;
@query("ha-textfield") private _input?: HaTextField;
@@ -43,14 +45,11 @@ export class HaFormString extends LitElement implements HaFormElement {
}
protected render(): TemplateResult {
const isPassword = MASKED_FIELDS.some((field) =>
this.schema.name.includes(field)
);
return html`
<ha-textfield
.type=${!isPassword
? this._stringType
: this._unmaskedPassword
.type=${!this.isPassword
? this.stringType
: this.unmaskedPassword
? "text"
: "password"}
.label=${this.label}
@@ -62,7 +61,7 @@ export class HaFormString extends LitElement implements HaFormElement {
.autoValidate=${this.schema.required}
.name=${this.schema.name}
.autocomplete=${this.schema.autocomplete}
.suffix=${isPassword
.suffix=${this.isPassword
? // reserve some space for the icon.
html`<div style="width: 24px"></div>`
: this.schema.description?.suffix}
@@ -70,14 +69,19 @@ export class HaFormString extends LitElement implements HaFormElement {
@input=${this._valueChanged}
@change=${this._valueChanged}
></ha-textfield>
${isPassword
? html`<ha-icon-button
toggles
.label=${`${this._unmaskedPassword ? "Hide" : "Show"} password`}
@click=${this._toggleUnmaskedPassword}
.path=${this._unmaskedPassword ? mdiEyeOff : mdiEye}
></ha-icon-button>`
: ""}
${this.renderIcon()}
`;
}
protected renderIcon() {
if (!this.isPassword) return nothing;
return html`
<ha-icon-button
toggles
.label=${`${this.unmaskedPassword ? "Hide" : "Show"} password`}
@click=${this.toggleUnmaskedPassword}
.path=${this.unmaskedPassword ? mdiEyeOff : mdiEye}
></ha-icon-button>
`;
}
@@ -87,11 +91,11 @@ export class HaFormString extends LitElement implements HaFormElement {
}
}
private _toggleUnmaskedPassword(): void {
this._unmaskedPassword = !this._unmaskedPassword;
protected toggleUnmaskedPassword(): void {
this.unmaskedPassword = !this.unmaskedPassword;
}
private _valueChanged(ev: Event): void {
protected _valueChanged(ev: Event): void {
let value: string | undefined = (ev.target as HaTextField).value;
if (this.data === value) {
return;
@@ -104,7 +108,7 @@ export class HaFormString extends LitElement implements HaFormElement {
});
}
private get _stringType(): string {
protected get stringType(): string {
if (this.schema.format) {
if (["email", "url"].includes(this.schema.format)) {
return this.schema.format;
@@ -116,6 +120,10 @@ export class HaFormString extends LitElement implements HaFormElement {
return "text";
}
protected get isPassword(): boolean {
return MASKED_FIELDS.some((field) => this.schema.name.includes(field));
}
static get styles(): CSSResultGroup {
return css`
:host {

View File

@@ -1,3 +1,4 @@
/* eslint-disable lit/prefer-static-styles */
import {
css,
CSSResultGroup,
@@ -135,7 +136,7 @@ export class HaForm extends LitElement implements HaFormElement {
.required=${item.required || false}
.context=${this._generateContext(item)}
></ha-selector>`
: dynamicElement(`ha-form-${item.type}`, {
: dynamicElement(this.fieldElementName(item.type), {
schema: item,
data: getValue(this.data, item),
label: this._computeLabel(item, this.data),
@@ -152,6 +153,10 @@ export class HaForm extends LitElement implements HaFormElement {
`;
}
protected fieldElementName(type: string): string {
return `ha-form-${type}`;
}
private _generateContext(
schema: HaFormSchema
): Record<string, any> | undefined {
@@ -169,19 +174,30 @@ export class HaForm extends LitElement implements HaFormElement {
protected createRenderRoot() {
const root = super.createRenderRoot();
// attach it as soon as possible to make sure we fetch all events.
root.addEventListener("value-changed", (ev) => {
this.addValueChangedListener(root);
return root;
}
protected addValueChangedListener(element: Element | ShadowRoot) {
element.addEventListener("value-changed", (ev) => {
ev.stopPropagation();
const schema = (ev.target as HaFormElement).schema as HaFormSchema;
if (ev.target === this) return;
const newValue = !schema.name
? ev.detail.value
: { [schema.name]: ev.detail.value };
this.data = {
...this.data,
...newValue,
};
fireEvent(this, "value-changed", {
value: { ...this.data, ...newValue },
value: this.data,
});
});
return root;
}
private _computeLabel(schema: HaFormSchema, data: HaFormDataContainer) {

View File

@@ -7,22 +7,25 @@ import { fireEvent } from "../common/dom/fire_event";
@customElement("ha-formfield")
export class HaFormfield extends FormfieldBase {
protected _labelClick() {
const input = this.input;
if (input) {
input.focus();
switch (input.tagName) {
case "HA-CHECKBOX":
case "HA-RADIO":
if ((input as any).disabled) {
break;
}
(input as any).checked = !(input as any).checked;
fireEvent(input, "change");
break;
default:
input.click();
break;
}
const input = this.input as HTMLInputElement | undefined;
if (!input) return;
input.focus();
if (input.disabled) {
return;
}
switch (input.tagName) {
case "HA-CHECKBOX":
input.checked = !input.checked;
fireEvent(input, "change");
break;
case "HA-RADIO":
input.checked = true;
fireEvent(input, "change");
break;
default:
input.click();
break;
}
}

View File

@@ -124,6 +124,17 @@ export class HaIcon extends LitElement {
return;
}
if (iconName === "home-assistant") {
const icon = (await import("../resources/home-assistant-logo-svg"))
.mdiHomeAssistant;
if (this.icon === requestedIcon) {
this._path = icon;
}
cachedIcons[iconName] = icon;
return;
}
let databaseIcon: string | undefined;
try {
databaseIcon = await getIcon(iconName);

File diff suppressed because one or more lines are too long

View File

@@ -26,6 +26,7 @@ export class HaLocationSelector extends LitElement {
protected render() {
return html`
<p>${this.label ? this.label : ""}</p>
<ha-locations-editor
class="flex"
.hass=${this.hass}
@@ -78,10 +79,13 @@ export class HaLocationSelector extends LitElement {
}
static styles = css`
:host {
ha-locations-editor {
display: block;
height: 400px;
}
p {
margin-top: 0;
}
`;
}

View File

@@ -237,8 +237,6 @@ export class HaTargetPicker extends LitElement {
: html`<span role="gridcell">
<ha-icon-button
class="expand-btn mdc-chip__icon mdc-chip__icon--trailing"
tabindex="-1"
role="button"
.label=${this.hass.localize(
"ui.components.target-picker.expand"
)}
@@ -257,8 +255,6 @@ export class HaTargetPicker extends LitElement {
<span role="gridcell">
<ha-icon-button
class="mdc-chip__icon mdc-chip__icon--trailing"
tabindex="-1"
role="button"
.label=${this.hass.localize("ui.components.target-picker.remove")}
.path=${mdiClose}
hideTooltip

View File

@@ -15,7 +15,7 @@ class HaEntityMarker extends LitElement {
protected render() {
return html`
<div
class="marker"
class="marker ${this.entityPicture ? "picture" : ""}"
style=${styleMap({ "border-color": this.entityColor })}
@click=${this._badgeTap}
>
@@ -45,7 +45,6 @@ class HaEntityMarker extends LitElement {
justify-content: center;
align-items: center;
box-sizing: border-box;
overflow: hidden;
width: 48px;
height: 48px;
font-size: var(--ha-marker-font-size, 1.5em);
@@ -54,6 +53,9 @@ class HaEntityMarker extends LitElement {
color: var(--primary-text-color);
background-color: var(--card-background-color);
}
.marker.picture {
overflow: hidden;
}
.entity-picture {
background-size: cover;
height: 100%;

View File

@@ -37,6 +37,9 @@ export interface HaMapPaths {
export interface HaMapEntity {
entity_id: string;
color: string;
label_mode?: "name" | "state";
name?: string;
focus?: boolean;
}
@customElement("ha-map")
@@ -71,6 +74,8 @@ export class HaMap extends ReactiveElement {
private _mapItems: Array<Marker | Circle> = [];
private _mapFocusItems: Array<Marker | Circle> = [];
private _mapZones: Array<Marker | Circle> = [];
private _mapPaths: Array<Polyline | CircleMarker> = [];
@@ -168,7 +173,7 @@ export class HaMap extends ReactiveElement {
return;
}
if (!this._mapItems.length && !this.layers?.length) {
if (!this._mapFocusItems.length && !this.layers?.length) {
this.leafletMap.setView(
new this.Leaflet.LatLng(
this.hass.config.latitude,
@@ -180,7 +185,9 @@ export class HaMap extends ReactiveElement {
}
let bounds = this.Leaflet.latLngBounds(
this._mapItems ? this._mapItems.map((item) => item.getLatLng()) : []
this._mapFocusItems
? this._mapFocusItems.map((item) => item.getLatLng())
: []
);
if (this.fitZones) {
@@ -324,6 +331,7 @@ export class HaMap extends ReactiveElement {
if (this._mapItems.length) {
this._mapItems.forEach((marker) => marker.remove());
this._mapItems = [];
this._mapFocusItems = [];
}
if (this._mapZones.length) {
@@ -353,7 +361,8 @@ export class HaMap extends ReactiveElement {
if (!stateObj) {
continue;
}
const title = computeStateName(stateObj);
const customTitle = typeof entity !== "string" ? entity.name : undefined;
const title = customTitle ?? computeStateName(stateObj);
const {
latitude,
longitude,
@@ -413,17 +422,20 @@ export class HaMap extends ReactiveElement {
// DRAW ENTITY
// create icon
const entityName = title
.split(" ")
.map((part) => part[0])
.join("")
.substr(0, 3);
const entityName =
typeof entity !== "string" && entity.label_mode === "state"
? this.hass.formatEntityState(stateObj)
: customTitle ??
title
.split(" ")
.map((part) => part[0])
.join("")
.substr(0, 3);
// create marker with the icon
this._mapItems.push(
Leaflet.marker([latitude, longitude], {
icon: Leaflet.divIcon({
html: `
const marker = Leaflet.marker([latitude, longitude], {
icon: Leaflet.divIcon({
html: `
<ha-entity-marker
entity-id="${getEntityId(entity)}"
entity-name="${entityName}"
@@ -437,12 +449,15 @@ export class HaMap extends ReactiveElement {
}
></ha-entity-marker>
`,
iconSize: [48, 48],
className: "",
}),
title: computeStateName(stateObj),
})
);
iconSize: [48, 48],
className: "",
}),
title: title,
});
this._mapItems.push(marker);
if (typeof entity === "string" || entity.focus !== false) {
this._mapFocusItems.push(marker);
}
// create circle around if entity has accuracy
if (gpsAccuracy) {

View File

@@ -14,6 +14,8 @@ export interface AssistPipeline {
tts_engine: string | null;
tts_language: string | null;
tts_voice: string | null;
wake_word_entity: string | null;
wake_word_id: string | null;
}
export interface AssistPipelineMutableParams {
@@ -26,6 +28,8 @@ export interface AssistPipelineMutableParams {
tts_engine: string | null;
tts_language: string | null;
tts_voice: string | null;
wake_word_entity: string | null;
wake_word_id: string | null;
}
export interface assistRunListing {
@@ -61,6 +65,19 @@ interface PipelineErrorEvent extends PipelineEventBase {
};
}
interface PipelineWakeWordStartEvent extends PipelineEventBase {
type: "wake_word-start";
data: {
engine: string;
metadata: SpeechMetadata;
};
}
interface PipelineWakeWordEndEvent extends PipelineEventBase {
type: "wake_word-end";
data: { wake_word_output: { ww_id: string; timestamp: number } };
}
interface PipelineSTTStartEvent extends PipelineEventBase {
type: "stt-start";
data: {
@@ -110,6 +127,8 @@ export type PipelineRunEvent =
| PipelineRunStartEvent
| PipelineRunEndEvent
| PipelineErrorEvent
| PipelineWakeWordStartEvent
| PipelineWakeWordEndEvent
| PipelineSTTStartEvent
| PipelineSTTEndEvent
| PipelineIntentStartEvent
@@ -126,6 +145,14 @@ export type PipelineRunOptions = (
start_stage: "stt";
input: { sample_rate: number };
}
| {
start_stage: "wake_word";
input: {
sample_rate: number;
timeout?: number;
audio_seconds_to_buffer?: number;
};
}
) & {
end_stage: "stt" | "intent" | "tts";
pipeline?: string;
@@ -135,9 +162,11 @@ export type PipelineRunOptions = (
export interface PipelineRun {
init_options?: PipelineRunOptions;
events: PipelineRunEvent[];
stage: "ready" | "stt" | "intent" | "tts" | "done" | "error";
stage: "ready" | "wake_word" | "stt" | "intent" | "tts" | "done" | "error";
run: PipelineRunStartEvent["data"];
error?: PipelineErrorEvent["data"];
wake_word?: PipelineWakeWordStartEvent["data"] &
Partial<PipelineWakeWordEndEvent["data"]> & { done: boolean };
stt?: PipelineSTTStartEvent["data"] &
Partial<PipelineSTTEndEvent["data"]> & { done: boolean };
intent?: PipelineIntentStartEvent["data"] &
@@ -167,7 +196,18 @@ export const processEvent = (
return undefined;
}
if (event.type === "stt-start") {
if (event.type === "wake_word-start") {
run = {
...run,
stage: "wake_word",
wake_word: { ...event.data, done: false },
};
} else if (event.type === "wake_word-end") {
run = {
...run,
wake_word: { ...run.wake_word!, ...event.data, done: true },
};
} else if (event.type === "stt-start") {
run = {
...run,
stage: "stt",

View File

@@ -19,6 +19,10 @@ import {
} from "./device_automation";
import { EntityRegistryEntry } from "./entity_registry";
import { FrontendLocaleData } from "./translation";
import {
formatListWithAnds,
formatListWithOrs,
} from "../common/string/format-list";
const triggerTranslationBaseKey =
"ui.panel.config.automation.editor.triggers.type";
@@ -104,11 +108,6 @@ const tryDescribeTrigger = (
return trigger.alias;
}
const disjunctionFormatter = new Intl.ListFormat("en", {
style: "long",
type: "disjunction",
});
// Event Trigger
if (trigger.platform === "event" && trigger.event_type) {
const eventTypes: string[] = [];
@@ -121,7 +120,7 @@ const tryDescribeTrigger = (
eventTypes.push(trigger.event_type);
}
const eventTypesString = disjunctionFormatter.format(eventTypes);
const eventTypesString = formatListWithOrs(hass.locale, eventTypes);
return hass.localize(
`${triggerTranslationBaseKey}.event.description.full`,
{ eventTypes: eventTypesString }
@@ -139,41 +138,54 @@ const tryDescribeTrigger = (
// Numeric State Trigger
if (trigger.platform === "numeric_state" && trigger.entity_id) {
let base = "When";
const stateObj = hass.states[trigger.entity_id];
const entity = stateObj ? computeStateName(stateObj) : trigger.entity_id;
if (trigger.attribute) {
base += ` ${computeAttributeNameDisplay(
hass.localize,
stateObj,
hass.entities,
trigger.attribute
)} from`;
const attribute = trigger.attribute
? computeAttributeNameDisplay(
hass.localize,
stateObj,
hass.entities,
trigger.attribute
)
: undefined;
const duration = trigger.for ? describeDuration(trigger.for) : undefined;
if (trigger.above && trigger.below) {
return hass.localize(
`${triggerTranslationBaseKey}.numeric_state.description.above-below`,
{
attribute: attribute,
entity: entity,
above: trigger.above,
below: trigger.below,
duration: duration,
}
);
}
base += ` ${entity} is`;
if (trigger.above !== undefined) {
base += ` above ${trigger.above}`;
if (trigger.above) {
return hass.localize(
`${triggerTranslationBaseKey}.numeric_state.description.above`,
{
attribute: attribute,
entity: entity,
above: trigger.above,
duration: duration,
}
);
}
if (trigger.below !== undefined && trigger.above !== undefined) {
base += " and";
if (trigger.below) {
return hass.localize(
`${triggerTranslationBaseKey}.numeric_state.description.below`,
{
attribute: attribute,
entity: entity,
below: trigger.below,
duration: duration,
}
);
}
if (trigger.below !== undefined) {
base += ` below ${trigger.below}`;
}
if (trigger.for) {
const duration = describeDuration(trigger.for);
if (duration) {
base += ` for ${duration}`;
}
}
return base;
}
// State Trigger
@@ -242,7 +254,7 @@ const tryDescribeTrigger = (
);
}
if (from.length !== 0) {
const fromString = disjunctionFormatter.format(from);
const fromString = formatListWithOrs(hass.locale, from);
base += ` from ${fromString}`;
}
} else {
@@ -283,7 +295,7 @@ const tryDescribeTrigger = (
);
}
if (to.length !== 0) {
const toString = disjunctionFormatter.format(to);
const toString = formatListWithOrs(hass.locale, to);
base += ` to ${toString}`;
}
} else {
@@ -356,7 +368,7 @@ const tryDescribeTrigger = (
);
return hass.localize(`${triggerTranslationBaseKey}.time.description.full`, {
time: disjunctionFormatter.format(result),
time: formatListWithOrs(hass.locale, result),
});
}
@@ -505,11 +517,12 @@ const tryDescribeTrigger = (
);
}
const entitiesString = disjunctionFormatter.format(entities);
const zonesString = disjunctionFormatter.format(zones);
return `When ${entitiesString} ${trigger.event}s ${zonesString} ${
zones.length > 1 ? "zones" : "zone"
}`;
return hass.localize(`${triggerTranslationBaseKey}.zone.description.full`, {
entity: formatListWithOrs(hass.locale, entities),
event: trigger.event.toString(),
zone: formatListWithOrs(hass.locale, zones),
numberOfZones: zones.length,
});
}
// Geo Location Trigger
@@ -540,11 +553,15 @@ const tryDescribeTrigger = (
);
}
const sourcesString = disjunctionFormatter.format(sources);
const zonesString = disjunctionFormatter.format(zones);
return `When ${sourcesString} ${trigger.event}s ${zonesString} ${
zones.length > 1 ? "zones" : "zone"
}`;
return hass.localize(
`${triggerTranslationBaseKey}.geo_location.description.full`,
{
source: formatListWithOrs(hass.locale, sources),
event: trigger.event.toString(),
zone: formatListWithOrs(hass.locale, zones),
numberOfZones: zones.length,
}
);
}
// MQTT Trigger
@@ -583,7 +600,8 @@ const tryDescribeTrigger = (
return hass.localize(
`${triggerTranslationBaseKey}.conversation.description.full`,
{
sentence: disjunctionFormatter.format(
sentence: formatListWithOrs(
hass.locale,
ensureArray(trigger.command).map((cmd) => `'${cmd}'`)
),
}
@@ -592,7 +610,9 @@ const tryDescribeTrigger = (
// Persistent Notification Trigger
if (trigger.platform === "persistent_notification") {
return "When a persistent notification is updated";
return hass.localize(
`${triggerTranslationBaseKey}.persistent_notification.description.full`
);
}
// Device Trigger
@@ -650,15 +670,6 @@ const tryDescribeCondition = (
return condition.alias;
}
const conjunctionFormatter = new Intl.ListFormat("en", {
style: "long",
type: "conjunction",
});
const disjunctionFormatter = new Intl.ListFormat("en", {
style: "long",
type: "disjunction",
});
if (!condition.condition) {
const shorthands: Array<"and" | "or" | "not"> = ["and", "or", "not"];
for (const key of shorthands) {
@@ -756,8 +767,8 @@ const tryDescribeCondition = (
if (entities.length !== 0) {
const entitiesString =
condition.match === "any"
? disjunctionFormatter.format(entities)
: conjunctionFormatter.format(entities);
? formatListWithOrs(hass.locale, entities)
: formatListWithAnds(hass.locale, entities);
base += ` ${entitiesString} ${
condition.entity_id.length > 1 ? "are" : "is"
}`;
@@ -812,7 +823,7 @@ const tryDescribeCondition = (
states.push("a state");
}
const statesString = disjunctionFormatter.format(states);
const statesString = formatListWithOrs(hass.locale, states);
base += ` ${statesString}`;
if (condition.for) {
@@ -827,29 +838,49 @@ const tryDescribeCondition = (
// Numeric State Condition
if (condition.condition === "numeric_state" && condition.entity_id) {
let base = "Confirm";
const stateObj = hass.states[condition.entity_id];
const entity = stateObj ? computeStateName(stateObj) : condition.entity_id;
if ("attribute" in condition) {
base += ` ${condition.attribute} from`;
const attribute = condition.attribute
? computeAttributeNameDisplay(
hass.localize,
stateObj,
hass.entities,
condition.attribute
)
: undefined;
if (condition.above && condition.below) {
return hass.localize(
`${conditionsTranslationBaseKey}.numeric_state.description.above-below`,
{
attribute: attribute,
entity: entity,
above: condition.above,
below: condition.below,
}
);
}
base += ` ${entity} is`;
if ("above" in condition) {
base += ` above ${condition.above}`;
if (condition.above) {
return hass.localize(
`${conditionsTranslationBaseKey}.numeric_state.description.above`,
{
attribute: attribute,
entity: entity,
above: condition.above,
}
);
}
if ("below" in condition && "above" in condition) {
base += " and";
if (condition.below) {
return hass.localize(
`${conditionsTranslationBaseKey}.numeric_state.description.below`,
{
attribute: attribute,
entity: entity,
below: condition.below,
}
);
}
if ("below" in condition) {
base += ` below ${condition.below}`;
}
return base;
}
// Time condition
@@ -902,7 +933,7 @@ const tryDescribeCondition = (
`ui.panel.config.automation.editor.conditions.type.time.weekdays.${d}`
)
);
result += " day is " + disjunctionFormatter.format(localizedDays);
result += " day is " + formatListWithOrs(hass.locale, localizedDays);
}
return result;
@@ -981,8 +1012,8 @@ const tryDescribeCondition = (
);
}
const entitiesString = disjunctionFormatter.format(entities);
const zonesString = disjunctionFormatter.format(zones);
const entitiesString = formatListWithOrs(hass.locale, entities);
const zonesString = formatListWithOrs(hass.locale, zones);
return hass.localize(
`${conditionsTranslationBaseKey}.zone.description.full`,
{

View File

@@ -17,12 +17,14 @@ export interface LovelacePanelConfig {
mode: "yaml" | "storage";
}
export type LovelaceStrategyConfig = {
type: string;
[key: string]: any;
};
export interface LovelaceConfig {
title?: string;
strategy?: {
type: string;
options?: Record<string, unknown>;
};
strategy?: LovelaceStrategyConfig;
views: LovelaceViewConfig[];
background?: string;
}
@@ -81,10 +83,7 @@ export interface LovelaceViewConfig {
index?: number;
title?: string;
type?: string;
strategy?: {
type: string;
options?: Record<string, unknown>;
};
strategy?: LovelaceStrategyConfig;
badges?: Array<string | LovelaceBadgeConfig>;
cards?: LovelaceCardConfig[];
path?: string;

View File

@@ -5,7 +5,6 @@ import {
mdiCodeBraces,
mdiDevices,
mdiGestureDoubleTap,
mdiHomeAssistant,
mdiMapMarker,
mdiMapMarkerRadius,
mdiMessageAlert,
@@ -18,6 +17,8 @@ import {
mdiWebhook,
} from "@mdi/js";
import { mdiHomeAssistant } from "../resources/home-assistant-logo-svg";
export const TRIGGER_TYPES = {
calendar: mdiCalendar,
device: mdiDevices,

12
src/data/wake_word.ts Normal file
View File

@@ -0,0 +1,12 @@
import type { HomeAssistant } from "../types";
export interface WakeWord {
id: string;
name: string;
}
export const fetchWakeWordInfo = (hass: HomeAssistant, entity_id: string) =>
hass.callWS<{ wake_words: WakeWord[] }>({
type: "wake_word/info",
entity_id,
});

View File

@@ -192,7 +192,7 @@ export interface ZWaveJSController {
supported_function_types: number[];
suc_node_id: number;
supports_timers: boolean;
is_heal_network_active: boolean;
is_rebuilding_routes: boolean;
inclusion_state: InclusionState;
nodes: ZWaveJSNodeStatus[];
}
@@ -278,9 +278,9 @@ export interface ZWaveJSRefreshNodeStatusMessage {
stage?: string;
}
export interface ZWaveJSHealNetworkStatusMessage {
export interface ZWaveJSRebuildRoutesStatusMessage {
event: string;
heal_node_status: { [key: number]: string };
rebuild_routes_status: { [key: number]: string };
}
export interface ZWaveJSControllerStatisticsUpdatedMessage {
@@ -651,12 +651,12 @@ export const reinterviewZwaveNode = (
}
);
export const healZwaveNode = (
export const rebuildZwaveNodeRoutes = (
hass: HomeAssistant,
device_id: string
): Promise<boolean> =>
hass.callWS({
type: "zwave_js/heal_node",
type: "zwave_js/rebuild_node_routes",
device_id,
});
@@ -673,33 +673,33 @@ export const removeFailedZwaveNode = (
}
);
export const healZwaveNetwork = (
export const rebuildZwaveNetworkRoutes = (
hass: HomeAssistant,
entry_id: string
): Promise<UnsubscribeFunc> =>
hass.callWS({
type: "zwave_js/begin_healing_network",
type: "zwave_js/begin_rebuilding_routes",
entry_id,
});
export const stopHealZwaveNetwork = (
export const stopRebuildingZwaveNetworkRoutes = (
hass: HomeAssistant,
entry_id: string
): Promise<UnsubscribeFunc> =>
hass.callWS({
type: "zwave_js/stop_healing_network",
type: "zwave_js/stop_rebuilding_routes",
entry_id,
});
export const subscribeHealZwaveNetworkProgress = (
export const subscribeRebuildZwaveNetworkRoutesProgress = (
hass: HomeAssistant,
entry_id: string,
callbackFunction: (message: ZWaveJSHealNetworkStatusMessage) => void
callbackFunction: (message: ZWaveJSRebuildRoutesStatusMessage) => void
): Promise<UnsubscribeFunc> =>
hass.connection.subscribeMessage(
(message: any) => callbackFunction(message),
{
type: "zwave_js/subscribe_heal_network_progress",
type: "zwave_js/subscribe_rebuild_routes_progress",
entry_id,
}
);

View File

@@ -1,137 +0,0 @@
import "@material/mwc-button/mwc-button";
import { CSSResultGroup, LitElement, css, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import "../../components/ha-alert";
import "../../components/ha-dialog";
import { haStyle, haStyleDialog } from "../../resources/styles";
import { HomeAssistant } from "../../types";
import { AliasesDialogParams } from "./show-dialog-aliases";
import "../../components/ha-aliases-editor";
@customElement("dialog-aliases")
class DialogAliases extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@state() private _error?: string;
@state() private _params?: AliasesDialogParams;
@state() private _aliases!: string[];
@state() private _submitting = false;
public async showDialog(params: AliasesDialogParams): Promise<void> {
this._params = params;
this._error = undefined;
this._aliases =
this._params.aliases?.length > 0
? [...this._params.aliases].sort()
: [""];
await this.updateComplete;
}
public closeDialog(): void {
this._error = "";
this._params = undefined;
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render() {
if (!this._params) {
return nothing;
}
return html`
<ha-dialog
open
@closed=${this.closeDialog}
.heading=${this.hass.localize("ui.dialogs.aliases.heading", {
name: this._params.name,
})}
>
<div>
${this._error
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
: ""}
<ha-aliases-editor
.hass=${this.hass}
.aliases=${this._aliases}
@value-changed=${this._aliasesChanged}
></ha-aliases-editor>
</div>
<mwc-button
slot="secondaryAction"
@click=${this.closeDialog}
.disabled=${this._submitting}
>
${this.hass.localize("ui.common.cancel")}
</mwc-button>
<mwc-button
slot="primaryAction"
@click=${this._updateAliases}
.disabled=${this._submitting}
>
${this.hass.localize("ui.dialogs.aliases.save")}
</mwc-button>
</ha-dialog>
`;
}
private _aliasesChanged(ev: CustomEvent): void {
this._aliases = ev.detail.value;
}
private async _updateAliases(): Promise<void> {
this._submitting = true;
const noEmptyAliases = this._aliases
.map((alias) => alias.trim())
.filter((alias) => alias);
try {
await this._params!.updateAliases(noEmptyAliases);
this.closeDialog();
} catch (err: any) {
this._error =
err.message || this.hass.localize("ui.dialogs.aliases.unknown_error");
} finally {
this._submitting = false;
}
}
static get styles(): CSSResultGroup {
return [
haStyle,
haStyleDialog,
css`
.row {
margin-bottom: 8px;
}
ha-textfield {
display: block;
}
ha-icon-button {
display: block;
}
mwc-button {
margin-left: 8px;
}
#alias_input {
margin-top: 8px;
}
.alias {
border: 1px solid var(--divider-color);
border-radius: 4px;
margin-top: 4px;
--mdc-icon-button-size: 24px;
}
`,
];
}
}
declare global {
interface HTMLElementTagNameMap {
"dialog-aliases": DialogAliases;
}
}

View File

@@ -1,20 +0,0 @@
import { fireEvent } from "../../common/dom/fire_event";
export interface AliasesDialogParams {
name: string;
aliases: string[];
updateAliases: (aliases: string[]) => Promise<unknown>;
}
export const loadAliasesDialog = () => import("./dialog-aliases");
export const showAliasesDialog = (
element: HTMLElement,
aliasesParams: AliasesDialogParams
): void => {
fireEvent(element, "show-dialog", {
dialogTag: "dialog-aliases",
dialogImport: loadAliasesDialog,
dialogParams: aliasesParams,
});
};

View File

@@ -53,8 +53,8 @@ class DialogLightColorFavorite extends LitElement {
): Promise<void> {
this._entry = dialogParams.entry;
this._dialogParams = dialogParams;
this._updateModes(dialogParams.defaultMode);
await this.updateComplete;
this._color = dialogParams.initialColor ?? this._computeCurrentColor();
this._updateModes();
}
public closeDialog(): void {
@@ -64,7 +64,7 @@ class DialogLightColorFavorite extends LitElement {
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
private _updateModes(defaultMode?: LightPickerMode) {
private _updateModes() {
const supportsTemp = lightSupportsColorMode(
this.stateObj!,
LightColorMode.COLOR_TEMP
@@ -81,13 +81,40 @@ class DialogLightColorFavorite extends LitElement {
}
this._modes = modes;
this._mode =
defaultMode ??
(this.stateObj!.attributes.color_mode
? this.stateObj!.attributes.color_mode === LightColorMode.COLOR_TEMP
? LightColorMode.COLOR_TEMP
: "color"
: this._modes[0]);
if (this._color) {
this._mode = "color_temp_kelvin" in this._color ? "color_temp" : "color";
} else {
this._mode = this._modes[0];
}
}
private _computeCurrentColor() {
const attributes = this.stateObj!.attributes;
const color_mode = attributes.color_mode;
let currentColor: LightColor | undefined;
if (color_mode === LightColorMode.XY) {
// XY color not supported for favorites. Try to grab the hs or rgb instead.
if (attributes.hs_color) {
currentColor = { hs_color: attributes.hs_color };
} else if (attributes.rgb_color) {
currentColor = { rgb_color: attributes.rgb_color };
}
} else if (
color_mode === LightColorMode.COLOR_TEMP &&
attributes.color_temp_kelvin
) {
currentColor = {
color_temp_kelvin: attributes.color_temp_kelvin,
};
} else if (attributes[color_mode + "_color"]) {
currentColor = {
[color_mode + "_color"]: attributes[color_mode + "_color"],
} as LightColor;
}
return currentColor;
}
private _colorChanged(ev: CustomEvent) {
@@ -198,7 +225,10 @@ class DialogLightColorFavorite extends LitElement {
<ha-button slot="secondaryAction" dialogAction="cancel">
${this.hass.localize("ui.common.cancel")}
</ha-button>
<ha-button slot="primaryAction" @click=${this._save}
<ha-button
slot="primaryAction"
@click=${this._save}
.disabled=${!this._color}
>${this.hass.localize("ui.common.save")}</ha-button
>
</ha-dialog>

View File

@@ -1,12 +1,12 @@
import { mdiCheck, mdiMinus, mdiPlus } from "@mdi/js";
import {
css,
CSSResultGroup,
html,
LitElement,
nothing,
PropertyValues,
TemplateResult,
css,
html,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
@@ -19,18 +19,17 @@ import {
updateEntityRegistryEntry,
} from "../../../../data/entity_registry";
import {
computeDefaultFavoriteColors,
LightColor,
LightEntity,
computeDefaultFavoriteColors,
} from "../../../../data/light";
import { actionHandler } from "../../../../panels/lovelace/common/directives/action-handler-directive";
import {
loadSortable,
SortableInstance,
loadSortable,
} from "../../../../resources/sortable.ondemand";
import { HomeAssistant } from "../../../../types";
import { showConfirmationDialog } from "../../../generic/show-dialog-box";
import type { LightPickerMode } from "./dialog-light-color-favorite";
import "./ha-favorite-color-button";
import { showLightColorFavoriteDialog } from "./show-dialog-light-color-favorite";
@@ -155,13 +154,9 @@ export class HaMoreInfoLightFavoriteColors extends LitElement {
// Make sure the current favorite color is set
fireEvent(this, "favorite-color-edit-started");
await this._apply(index);
const defaultMode: LightPickerMode =
"color_temp_kelvin" in this._favoriteColors[index]
? "color_temp"
: "color";
const color = await showLightColorFavoriteDialog(this, {
entry: this.entry!,
defaultMode,
initialColor: this._favoriteColors[index],
title: this.hass.localize(
"ui.dialogs.more_info_control.light.favorite_color.edit_title"
),

View File

@@ -1,12 +1,11 @@
import { fireEvent } from "../../../../common/dom/fire_event";
import { ExtEntityRegistryEntry } from "../../../../data/entity_registry";
import { LightColor } from "../../../../data/light";
import type { LightPickerMode } from "./dialog-light-color-favorite";
export interface LightColorFavoriteDialogParams {
entry: ExtEntityRegistryEntry;
title: string;
defaultMode?: LightPickerMode;
initialColor?: LightColor;
submit?: (color?: LightColor) => void;
cancel?: () => void;
}

View File

@@ -99,6 +99,7 @@ export class MoreInfoHistory extends LitElement {
.historyData=${this._stateHistory}
.isLoadingData=${!this._stateHistory}
.showNames=${false}
.clickForMoreInfo=${false}
></state-history-charts>`}`
: ""}`;
}

View File

@@ -119,6 +119,8 @@ export class QuickBar extends LitElement {
this._focusSet = false;
this._filter = "";
this._search = "";
this._entityItems = undefined;
this._commandItems = undefined;
fireEvent(this, "dialog-closed", { dialog: this.localName });
}

View File

@@ -271,6 +271,7 @@ export const provideHass = (
},
dockedSidebar: "auto",
vibrate: true,
debugConnection: false,
suspendWhenHidden: false,
moreInfoEntityId: null as any,
// @ts-ignore

View File

@@ -10,33 +10,50 @@
max-width: 360px;
margin: 0 auto;
}
.header {
font-size: 1.96em;
display: flex;
align-items: center;
justify-content: center;
font-weight: 300;
height: 73px;
}
.header img {
margin-right: 16px;
.logomark {
fill: #F2F4F9;
}
.wordmark {
fill: #1D2126;
}
@media (prefers-color-scheme: dark) {
html {
background-color: #111111;
color: #e1e1e1;
}
.wordmark {
fill: #F2F4F9;
}
}
</style>
</head>
<body>
<div class="content">
<div class="header">
<img src="/static/icons/favicon-192x192.png" height="52" alt="" />
Home Assistant
<svg viewBox="0 0 1945 401" xmlns="http://www.w3.org/2000/svg">
<path d="M360 304.813C360 313.063 353.25 319.813 345 319.813H135C126.75 319.813 120 313.063 120 304.813V214.813C120 206.563 124.77 195.043 130.61 189.203L229.39 90.423C235.22 84.593 244.77 84.593 250.6 90.423L349.39 189.213C355.22 195.043 360 206.573 360 214.823V304.823V304.813Z" class="logomark"/>
<path d="M349.39 189.203L250.61 90.423C244.78 84.593 235.23 84.593 229.4 90.423L130.61 189.203C124.78 195.033 120 206.563 120 214.813V304.813C120 313.063 126.75 319.813 135 319.813H227.27L186.64 279.183C184.55 279.903 182.32 280.313 180 280.313C168.7 280.313 159.5 271.113 159.5 259.813C159.5 248.513 168.7 239.313 180 239.313C191.3 239.313 200.5 248.513 200.5 259.813C200.5 262.143 200.09 264.373 199.37 266.463L231 298.093V182.213C224.2 178.873 219.5 171.893 219.5 163.823C219.5 152.523 228.7 143.323 240 143.323C251.3 143.323 260.5 152.523 260.5 163.823C260.5 171.893 255.8 178.873 249 182.213V263.483L280.46 232.023C279.84 230.063 279.5 227.983 279.5 225.823C279.5 214.523 288.7 205.323 300 205.323C311.3 205.323 320.5 214.523 320.5 225.823C320.5 237.123 311.3 246.323 300 246.323C297.5 246.323 295.12 245.853 292.91 245.033L249 288.943V319.823H345C353.25 319.823 360 313.073 360 304.823V214.823C360 206.573 355.23 195.053 349.39 189.213V189.203Z" fill="#18BCF2"/>
<path d="M440.04 126.606H464.8V187.606L529.16 187.806V126.606H554.16V272.606H529.16V209.826L464.8 209.626V272.626H440L440.04 126.606Z" class="wordmark"/>
<path d="M626.8 171.236C641.9 171.236 654.203 176.086 663.71 185.786C673.217 195.486 677.97 207.956 677.97 223.196C677.97 238.363 673.217 250.796 663.71 260.496C654.203 270.196 641.9 275.046 626.8 275.046C611.56 275.046 599.19 270.196 589.69 260.496C580.19 250.796 575.437 238.363 575.43 223.196C575.43 207.863 580.183 195.38 589.69 185.746C599.197 176.113 611.567 171.276 626.8 171.236ZM626.8 253.756C634.873 253.756 641.433 250.91 646.48 245.216C651.527 239.523 654.047 232.116 654.04 222.996C654.04 213.89 651.52 206.516 646.48 200.876C641.44 195.236 634.88 192.423 626.8 192.436C618.533 192.436 611.867 195.25 606.8 200.876C601.733 206.503 599.193 213.876 599.18 222.996C599.18 232.116 601.72 239.523 606.8 245.216C611.88 250.91 618.547 253.756 626.8 253.756Z" class="wordmark"/>
<path d="M846.68 209.826V272.616H823.68V213.426C823.68 206.6 821.923 201.266 818.41 197.426C814.897 193.586 810.11 191.663 804.05 191.656C797.61 191.656 792.467 193.756 788.62 197.956C784.773 202.156 782.853 208.033 782.86 215.586V272.586H759.67V213.426C759.67 206.6 757.96 201.266 754.54 197.426C751.12 193.586 746.383 191.663 740.33 191.656C733.89 191.656 728.717 193.756 724.81 197.956C720.903 202.156 718.95 208.033 718.95 215.586V272.586H695.32V173.976H717.32L718.1 183.446C723.833 175.046 733.167 170.846 746.1 170.846C753.653 170.846 760.197 172.41 765.73 175.536C771.258 178.659 775.662 183.441 778.32 189.206C780.708 183.505 784.932 178.765 790.32 175.736C795.88 172.476 802.503 170.846 810.19 170.846C821.39 170.846 830.277 174.296 836.85 181.196C843.423 188.096 846.7 197.64 846.68 209.826Z" class="wordmark"/>
<path d="M961.28 231.986H885.7C886.48 239.406 889.28 245.073 894.1 248.986C898.92 252.9 905.04 254.846 912.46 254.826C924.5 254.826 932.93 249.826 937.75 239.826L957.48 247.636C953.937 256.093 947.799 263.206 939.95 267.946C931.95 272.84 922.787 275.283 912.46 275.276C897.873 275.276 886.04 270.506 876.96 260.966C867.88 251.426 863.337 238.91 863.33 223.416C863.33 207.923 867.907 195.326 877.06 185.626C886.213 175.926 898.173 171.076 912.94 171.076C927.46 171.076 939.147 175.86 948 185.426C956.853 194.993 961.28 207.593 961.28 223.226V231.986ZM886.09 215.376H937.26C936.8 207.376 934.377 201.273 929.99 197.066C925.603 192.86 919.693 190.78 912.26 190.826C904.927 190.826 898.927 192.956 894.26 197.216C889.593 201.476 886.87 207.53 886.09 215.376Z" class="wordmark"/>
<path d="M1113.53 238.626H1057.97L1045.97 272.626H1020.38L1073.11 126.626H1098.7L1151.53 272.626H1125.36L1113.53 238.626ZM1106.31 217.626L1085.9 159.226L1065.29 217.626H1106.31Z" class="wordmark"/>
<path d="M1197.86 256.196C1202.74 256.196 1206.6 255.236 1209.43 253.316C1210.82 252.385 1211.94 251.108 1212.69 249.61C1213.43 248.113 1213.78 246.447 1213.68 244.776C1213.68 239.51 1210.13 235.993 1203.04 234.226L1189.46 230.616C1170.79 225.536 1161.46 215.933 1161.46 201.806C1161.46 192.76 1164.75 185.37 1171.32 179.636C1177.89 173.903 1186.75 171.04 1197.88 171.046C1207.84 171.046 1216.17 173.323 1222.88 177.876C1226.12 179.984 1228.89 182.737 1231.01 185.963C1233.14 189.19 1234.57 192.82 1235.23 196.626L1214.04 201.626C1213.86 199.944 1213.33 198.317 1212.48 196.854C1211.63 195.391 1210.48 194.124 1209.11 193.136C1206.04 190.98 1202.36 189.881 1198.61 190.006C1194.38 190.006 1190.96 191.066 1188.36 193.186C1187.11 194.159 1186.1 195.412 1185.42 196.845C1184.74 198.278 1184.41 199.851 1184.45 201.436C1184.42 202.719 1184.67 203.994 1185.17 205.173C1185.68 206.353 1186.43 207.411 1187.38 208.276C1189.34 210.096 1192.37 211.56 1196.46 212.666L1209.84 215.986C1218.76 218.4 1225.56 222.046 1230.25 226.926C1232.56 229.322 1234.36 232.152 1235.57 235.253C1236.77 238.353 1237.34 241.662 1237.25 244.986C1237.25 254.24 1233.77 261.596 1226.8 267.056C1219.83 272.516 1210.23 275.253 1197.99 275.266C1186.66 275.266 1177.57 272.776 1170.74 267.796C1167.44 265.455 1164.65 262.454 1162.57 258.982C1160.48 255.51 1159.14 251.643 1158.63 247.626L1180.21 243.816C1180.34 245.633 1180.88 247.398 1181.78 248.978C1182.69 250.559 1183.94 251.915 1185.44 252.946C1188.6 255.116 1192.72 256.196 1197.86 256.196Z" class="wordmark"/>
<path d="M1287.46 256.196C1292.35 256.196 1296.2 255.196 1299.04 253.316C1300.43 252.383 1301.55 251.104 1302.29 249.607C1303.03 248.11 1303.37 246.445 1303.28 244.776C1303.28 239.51 1299.73 235.993 1292.64 234.226L1279.07 230.616C1260.4 225.536 1251.07 215.933 1251.07 201.806C1251.07 192.76 1254.36 185.37 1260.93 179.636C1267.5 173.903 1276.36 171.04 1287.49 171.046C1297.45 171.046 1305.78 173.323 1312.49 177.876C1315.73 179.985 1318.5 182.739 1320.62 185.964C1322.75 189.19 1324.19 192.82 1324.85 196.626L1303.65 201.626C1303.47 199.944 1302.94 198.317 1302.09 196.854C1301.24 195.391 1300.09 194.124 1298.72 193.136C1295.65 190.98 1291.97 189.881 1288.22 190.006C1283.99 190.006 1280.57 191.066 1277.97 193.186C1276.72 194.16 1275.71 195.414 1275.03 196.846C1274.36 198.279 1274.02 199.851 1274.06 201.436C1274.03 202.719 1274.28 203.994 1274.79 205.173C1275.29 206.353 1276.04 207.411 1276.99 208.276C1278.99 210.096 1281.99 211.556 1286.08 212.666L1299.46 215.986C1308.37 218.4 1315.17 222.046 1319.87 226.926C1322.17 229.323 1323.98 232.154 1325.18 235.254C1326.38 238.354 1326.96 241.662 1326.87 244.986C1326.87 254.24 1323.39 261.596 1316.42 267.056C1309.45 272.516 1299.85 275.253 1287.61 275.266C1276.28 275.266 1267.19 272.776 1260.36 267.796C1257.06 265.455 1254.27 262.454 1252.19 258.982C1250.1 255.51 1248.76 251.643 1248.25 247.626L1269.84 243.816C1269.97 245.633 1270.5 247.397 1271.41 248.978C1272.31 250.558 1273.56 251.915 1275.06 252.946C1278.2 255.116 1282.32 256.196 1287.46 256.196Z" class="wordmark"/>
<path d="M1341.91 139.826C1341.88 137.852 1342.24 135.891 1342.97 134.059C1343.71 132.227 1344.81 130.562 1346.2 129.163C1347.6 127.764 1349.26 126.659 1351.09 125.914C1352.92 125.169 1354.88 124.799 1356.85 124.826C1358.81 124.796 1360.75 125.171 1362.56 125.926C1364.36 126.681 1366 127.802 1367.35 129.216C1370.14 132.026 1371.71 135.826 1371.71 139.786C1371.71 143.747 1370.14 147.546 1367.35 150.356C1366 151.786 1364.38 152.921 1362.57 153.687C1360.76 154.453 1358.81 154.834 1356.85 154.806C1354.88 154.832 1352.93 154.45 1351.11 153.684C1349.29 152.918 1347.66 151.785 1346.3 150.356C1344.9 148.988 1343.78 147.35 1343.03 145.54C1342.27 143.731 1341.89 141.787 1341.91 139.826ZM1368.67 174.006V272.636H1345.03V173.976L1368.67 174.006Z" class="wordmark"/>
<path d="M1425.85 256.196C1430.73 256.196 1434.59 255.236 1437.42 253.316C1438.81 252.384 1439.93 251.106 1440.68 249.609C1441.42 248.112 1441.76 246.446 1441.67 244.776C1441.67 239.51 1438.12 235.993 1431.02 234.226L1417.45 230.616C1398.78 225.536 1389.45 215.933 1389.45 201.806C1389.45 192.76 1392.74 185.37 1399.31 179.636C1405.88 173.903 1414.74 171.04 1425.88 171.046C1435.84 171.046 1444.17 173.323 1450.88 177.876C1454.11 179.987 1456.88 182.741 1459.01 185.967C1461.13 189.193 1462.57 192.821 1463.23 196.626L1442.04 201.626C1441.86 199.944 1441.33 198.317 1440.48 196.854C1439.63 195.391 1438.48 194.124 1437.11 193.136C1434.04 190.982 1430.36 189.884 1426.61 190.006C1422.38 190.006 1418.96 191.066 1416.35 193.186C1415.1 194.161 1414.1 195.415 1413.42 196.848C1412.74 198.281 1412.41 199.852 1412.45 201.436C1412.42 202.719 1412.67 203.994 1413.17 205.173C1413.68 206.353 1414.43 207.411 1415.38 208.276C1417.33 210.096 1420.36 211.56 1424.46 212.666L1437.84 215.986C1446.76 218.4 1453.56 222.046 1458.25 226.926C1460.56 229.322 1462.36 232.152 1463.57 235.253C1464.77 238.353 1465.34 241.662 1465.25 244.986C1465.25 254.24 1461.77 261.596 1454.8 267.056C1447.83 272.516 1438.23 275.253 1425.99 275.266C1414.66 275.266 1405.58 272.776 1398.75 267.796C1395.44 265.458 1392.66 262.458 1390.57 258.985C1388.49 255.513 1387.15 251.645 1386.64 247.626L1408.22 243.816C1408.35 245.633 1408.88 247.397 1409.79 248.978C1410.69 250.558 1411.94 251.915 1413.44 252.946C1416.58 255.116 1420.7 256.196 1425.85 256.196Z" class="wordmark"/>
<path d="M1535.86 272.606C1530.23 273.964 1524.46 274.718 1518.67 274.856C1508.71 274.856 1500.95 272.12 1495.38 266.646C1489.81 261.173 1487.03 253.036 1487.03 242.236V193.996H1471.89V173.996H1487.03V143.216H1510.47V173.976H1533.22V193.976H1510.47V237.976C1510.47 248.643 1514.6 253.976 1522.87 253.976C1526.29 253.833 1529.67 253.14 1532.87 251.926L1535.86 272.606Z" class="wordmark"/>
<path d="M1615.01 272.606C1614.16 268.914 1613.6 265.158 1613.35 261.376C1610.28 265.78 1606.08 269.273 1601.19 271.486C1595.48 274.09 1589.26 275.375 1582.98 275.246C1572.17 275.246 1563.5 272.366 1556.98 266.606C1550.46 260.846 1547.21 253.05 1547.22 243.216C1547.22 233.576 1550.43 226.04 1556.84 220.606C1563.25 215.173 1572.02 212.453 1583.15 212.446H1612.8V208.646C1612.8 202.46 1610.99 197.836 1607.38 194.776C1603.77 191.716 1598.71 190.186 1592.2 190.186C1580.68 190.186 1572.41 195.003 1567.39 204.636L1550.21 194.576C1558.54 178.89 1572.96 171.046 1593.47 171.046C1605.9 171.046 1616.08 174.236 1624.03 180.616C1631.98 186.996 1635.98 197.38 1636.03 211.766V251.026C1636.03 262.153 1636.61 269.346 1637.78 272.606H1615.01ZM1613.01 228.756H1588.69C1583.16 228.756 1578.87 230.026 1575.8 232.566C1574.28 233.837 1573.08 235.441 1572.28 237.254C1571.48 239.066 1571.12 241.039 1571.21 243.016C1571.21 247.636 1572.77 251.153 1575.9 253.566C1579.03 255.976 1583.48 257.176 1589.28 257.176C1596.24 257.176 1601.94 254.98 1606.37 250.586C1610.8 246.193 1613.02 239.666 1613.01 231.006V228.756Z" class="wordmark"/>
<path d="M1749.53 211.766V272.606H1726V216.826C1726 207.446 1723.79 201.033 1719.36 197.586C1715.18 194.155 1709.92 192.323 1704.51 192.416C1701.37 192.323 1698.24 192.853 1695.31 193.975C1692.38 195.098 1689.69 196.791 1687.42 198.956C1682.87 203.316 1680.6 209.533 1680.59 217.606V272.606H1656.96V173.976H1679.12L1679.9 184.616C1682.96 180.236 1687.19 176.803 1692.11 174.706C1697.6 172.234 1703.57 170.986 1709.59 171.046C1722.35 171.046 1732.2 174.576 1739.13 181.636C1746.06 188.696 1749.53 198.74 1749.53 211.766Z" class="wordmark"/>
<path d="M1824.98 272.606C1819.35 273.952 1813.59 274.696 1807.8 274.826C1797.84 274.826 1790.08 272.09 1784.51 266.616C1778.94 261.143 1776.16 253.006 1776.16 242.206V193.996H1761.02V173.996H1776.16V143.216H1799.59V173.976H1822.35V193.976H1799.59V237.976C1799.59 248.643 1803.73 253.976 1812 253.976C1815.42 253.833 1818.8 253.14 1822 251.926L1824.98 272.606Z" class="wordmark"/>
</svg>
</div>
<ha-authorize><p>Initializing</p></ha-authorize>
<ha-authorize></ha-authorize>
</div>
<%= renderTemplate("_js_base.html.template") %>
<%= renderTemplate("_preload_roboto.html.template") %>

File diff suppressed because one or more lines are too long

View File

@@ -15,7 +15,6 @@ import { stringCompare } from "../common/string/compare";
import { LocalizeFunc } from "../common/translations/localize";
import { ConfigEntry, subscribeConfigEntries } from "../data/config_entries";
import { subscribeConfigFlowInProgress } from "../data/config_flow";
import { DataEntryFlowProgress } from "../data/data_entry_flow";
import { domainToName } from "../data/integration";
import { scanUSBDevices } from "../data/usb";
import { SubscribeMixin } from "../mixins/subscribe-mixin";
@@ -24,12 +23,13 @@ import "./integration-badge";
import { onBoardingStyles } from "./styles";
const HIDDEN_DOMAINS = new Set([
"google_translate",
"hassio",
"met",
"radio_browser",
"rpi_power",
"shopping_list",
"sun",
"google_translate",
]);
@customElement("onboarding-integrations")
@@ -40,32 +40,34 @@ class OnboardingIntegrations extends SubscribeMixin(LitElement) {
@state() private _entries: ConfigEntry[] = [];
@state() private _discovered?: DataEntryFlowProgress[];
@state() private _discoveredDomains?: Set<string>;
public hassSubscribe(): Array<UnsubscribeFunc | Promise<UnsubscribeFunc>> {
return [
subscribeConfigFlowInProgress(this.hass, (flows) => {
this._discovered = flows;
const integrations: Set<string> = new Set();
for (const flow of flows) {
// To render title placeholders
if (flow.context.title_placeholders) {
integrations.add(flow.handler);
}
}
this.hass.loadBackendTranslation("title", Array.from(integrations));
this._discoveredDomains = new Set(
flows
.filter((flow) => !HIDDEN_DOMAINS.has(flow.handler))
.map((flow) => flow.handler)
);
this.hass.loadBackendTranslation(
"title",
Array.from(this._discoveredDomains)
);
}),
subscribeConfigEntries(
this.hass,
(messages) => {
let fullUpdate = false;
const newEntries: ConfigEntry[] = [];
const integrations: Set<string> = new Set();
messages.forEach((message) => {
if (message.type === null || message.type === "added") {
if (HIDDEN_DOMAINS.has(message.entry.domain)) {
return;
}
newEntries.push(message.entry);
integrations.add(message.entry.domain);
if (message.type === null) {
fullUpdate = true;
}
@@ -86,6 +88,7 @@ class OnboardingIntegrations extends SubscribeMixin(LitElement) {
if (!newEntries.length && !fullUpdate) {
return;
}
this.hass.loadBackendTranslation("title", Array.from(integrations));
const existingEntries = fullUpdate ? [] : this._entries;
this._entries = [...existingEntries!, ...newEntries];
},
@@ -95,41 +98,27 @@ class OnboardingIntegrations extends SubscribeMixin(LitElement) {
}
protected render() {
if (!this._discovered) {
if (!this._discoveredDomains) {
return nothing;
}
// Render discovered and existing entries together sorted by localized title.
const entries: Array<[string, string]> = this._entries.map((entry) => [
entry.domain,
domainToName(this.hass.localize, entry.domain),
]);
const discovered: Array<[string, string]> = this._discovered.map((flow) => [
flow.handler,
domainToName(this.hass.localize, flow.handler),
]);
let domains = [...entries, ...discovered].sort((a, b) =>
let uniqueDomains: Set<string> = new Set();
this._entries.forEach((entry) => {
uniqueDomains.add(entry.domain);
});
uniqueDomains = new Set([...uniqueDomains, ...this._discoveredDomains]);
let domains: Array<[string, string]> = [];
for (const domain of uniqueDomains.values()) {
domains.push([domain, domainToName(this.hass.localize, domain)]);
}
domains = domains.sort((a, b) =>
stringCompare(a[0], b[0], this.hass.locale.language)
);
const foundDevices = domains.length;
const foundIntegrations = domains.length;
if (domains.length > 12) {
const uniqueDomains: Set<string> = new Set();
domains.forEach(([domain]) => {
uniqueDomains.add(domain);
});
if (uniqueDomains.size < domains.length) {
domains = domains.filter(([domain]) => {
if (uniqueDomains.has(domain)) {
uniqueDomains.delete(domain);
return true;
}
return false;
});
}
if (domains.length > 12) {
domains = domains.slice(0, 11);
}
domains = domains.slice(0, 11);
}
return html`
@@ -150,11 +139,11 @@ class OnboardingIntegrations extends SubscribeMixin(LitElement) {
.darkOptimizedIcon=${this.hass.themes?.darkMode}
></integration-badge>`
)}
${foundDevices > domains.length
${foundIntegrations > domains.length
? html`<div class="more">
${this.onboardingLocalize(
"ui.panel.page-onboarding.integration.more_integrations",
{ count: foundDevices - domains.length }
{ count: foundIntegrations - domains.length }
)}
</div>`
: nothing}

View File

@@ -1,21 +1,19 @@
import "@material/mwc-button";
import "@material/mwc-list/mwc-list";
import { mdiPencil } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { property, state } from "lit/decorators";
import { fireEvent } from "../../../common/dom/fire_event";
import { stringCompare } from "../../../common/string/compare";
import "../../../components/ha-alert";
import { createCloseHeading } from "../../../components/ha-dialog";
import "../../../components/ha-picture-upload";
import type { HaPictureUpload } from "../../../components/ha-picture-upload";
import "../../../components/ha-textfield";
import { AreaRegistryEntryMutableParams } from "../../../data/area_registry";
import { showAliasesDialog } from "../../../dialogs/aliases/show-dialog-aliases";
import { CropOptions } from "../../../dialogs/image-cropper-dialog/show-image-cropper-dialog";
import { ValueChangedEvent, HomeAssistant } from "../../../types";
import { haStyleDialog } from "../../../resources/styles";
import { AreaRegistryDetailDialogParams } from "./show-dialog-area-registry-detail";
import "../../../components/ha-aliases-editor";
const cropOptions: CropOptions = {
round: false,
@@ -69,8 +67,8 @@ class DialogAreaDetail extends LitElement {
.heading=${createCloseHeading(
this.hass,
entry
? entry.name
: this.hass.localize("ui.panel.config.areas.editor.default_name")
? this.hass.localize("ui.panel.config.areas.editor.update_area")
: this.hass.localize("ui.panel.config.areas.editor.create_area")
)}
>
<div>
@@ -80,14 +78,16 @@ class DialogAreaDetail extends LitElement {
<div class="form">
${entry
? html`
<div>
${this.hass.localize(
"ui.panel.config.areas.editor.area_id"
)}:
${entry.area_id}
</div>
<ha-settings-row>
<span slot="heading">
${this.hass.localize(
"ui.panel.config.areas.editor.area_id"
)}
</span>
<span slot="description"> ${entry.area_id} </span>
</ha-settings-row>
`
: ""}
: nothing}
<ha-textfield
.value=${this._name}
@@ -108,75 +108,40 @@ class DialogAreaDetail extends LitElement {
@change=${this._pictureChanged}
></ha-picture-upload>
<div class="label">
<h3 class="header">
${this.hass.localize(
"ui.panel.config.areas.editor.aliases_section"
)}
</div>
<mwc-list class="aliases" @action=${this._handleAliasesClicked}>
<mwc-list-item .twoline=${this._aliases.length > 0} hasMeta>
<span>
${this._aliases.length > 0
? this.hass.localize(
"ui.panel.config.areas.editor.configured_aliases",
{ count: this._aliases.length }
)
: this.hass.localize(
"ui.panel.config.areas.editor.no_aliases"
)}
</span>
<span slot="secondary">
${[...this._aliases]
.sort((a, b) =>
stringCompare(a, b, this.hass.locale.language)
)
.join(", ")}
</span>
<ha-svg-icon slot="meta" .path=${mdiPencil}></ha-svg-icon>
</mwc-list-item>
</mwc-list>
<div class="secondary">
</h3>
<p class="description">
${this.hass.localize(
"ui.panel.config.areas.editor.aliases_description"
)}
</div>
</p>
<ha-aliases-editor
.hass=${this.hass}
.aliases=${this._aliases}
@value-changed=${this._aliasesChanged}
></ha-aliases-editor>
</div>
</div>
${entry
? html`
<mwc-button
slot="secondaryAction"
class="warning"
@click=${this._deleteEntry}
.disabled=${this._submitting}
>
${this.hass.localize("ui.panel.config.areas.editor.delete")}
</mwc-button>
`
: nothing}
<mwc-button slot="primaryAction" @click=${this.closeDialog}>
${this.hass.localize("ui.common.cancel")}
</mwc-button>
<mwc-button
slot="primaryAction"
@click=${this._updateEntry}
.disabled=${nameInvalid || this._submitting}
>
${entry
? this.hass.localize("ui.panel.config.areas.editor.update")
: this.hass.localize("ui.panel.config.areas.editor.create")}
? this.hass.localize("ui.common.save")
: this.hass.localize("ui.common.add")}
</mwc-button>
</ha-dialog>
`;
}
private _handleAliasesClicked() {
showAliasesDialog(this, {
name: this._name,
aliases: this._aliases,
updateAliases: async (aliases: string[]) => {
this._aliases = aliases;
},
});
}
private _isNameValid() {
return this._name.trim() !== "";
}
@@ -214,15 +179,8 @@ class DialogAreaDetail extends LitElement {
}
}
private async _deleteEntry() {
this._submitting = true;
try {
if (await this._params!.removeEntry!()) {
this.closeDialog();
}
} finally {
this._submitting = false;
}
private _aliasesChanged(ev: CustomEvent): void {
this._aliases = ev.detail.value;
}
static get styles(): CSSResultGroup {

View File

@@ -1,6 +1,6 @@
import "@material/mwc-button";
import "@material/mwc-list";
import { mdiImagePlus, mdiPencil } from "@mdi/js";
import { mdiDelete, mdiDotsVertical, mdiImagePlus, mdiPencil } from "@mdi/js";
import {
HassEntity,
UnsubscribeFunc,
@@ -246,13 +246,32 @@ class HaConfigAreaPage extends SubscribeMixin(LitElement) {
.narrow=${this.narrow}
.header=${area.name}
>
<ha-icon-button
.path=${mdiPencil}
.entry=${area}
@click=${this._showSettings}
slot="toolbar-icon"
.label=${this.hass.localize("ui.panel.config.areas.edit_settings")}
></ha-icon-button>
<ha-button-menu slot="toolbar-icon">
<ha-icon-button
slot="trigger"
.label=${this.hass.localize("ui.common.menu")}
.path=${mdiDotsVertical}
></ha-icon-button>
<mwc-list-item
graphic="icon"
.entry=${area}
@click=${this._showSettings}
>
${this.hass.localize("ui.panel.config.areas.edit_settings")}
<ha-svg-icon slot="graphic" .path=${mdiPencil}> </ha-svg-icon>
</mwc-list-item>
<mwc-list-item
class="warning"
graphic="icon"
@click=${this._deleteConfirm}
>
${this.hass.localize("ui.panel.config.areas.editor.delete")}
<ha-svg-icon class="warning" slot="graphic" .path=${mdiDelete}>
</ha-svg-icon>
</mwc-list-item>
</ha-button-menu>
<div class="container">
<div class="column">
@@ -634,31 +653,25 @@ class HaConfigAreaPage extends SubscribeMixin(LitElement) {
entry,
updateEntry: async (values) =>
updateAreaRegistryEntry(this.hass!, entry!.area_id, values),
removeEntry: async () => {
if (
!(await showConfirmationDialog(this, {
title: this.hass.localize(
"ui.panel.config.areas.delete.confirmation_title",
{ name: entry!.name }
),
text: this.hass.localize(
"ui.panel.config.areas.delete.confirmation_text"
),
dismissText: this.hass.localize("ui.common.cancel"),
confirmText: this.hass.localize("ui.common.delete"),
destructive: true,
}))
) {
return false;
}
});
}
try {
await deleteAreaRegistryEntry(this.hass!, entry!.area_id);
afterNextRender(() => history.back());
return true;
} catch (err: any) {
return false;
}
private async _deleteConfirm() {
const area = this._area(this.areaId, this._areas);
showConfirmationDialog(this, {
title: this.hass.localize(
"ui.panel.config.areas.delete.confirmation_title",
{ name: area!.name }
),
text: this.hass.localize(
"ui.panel.config.areas.delete.confirmation_text"
),
dismissText: this.hass.localize("ui.common.cancel"),
confirmText: this.hass.localize("ui.common.delete"),
destructive: true,
confirm: async () => {
await deleteAreaRegistryEntry(this.hass!, area!.area_id);
afterNextRender(() => history.back());
},
});
}

View File

@@ -10,7 +10,6 @@ export interface AreaRegistryDetailDialogParams {
updateEntry?: (
updates: Partial<AreaRegistryEntryMutableParams>
) => Promise<unknown>;
removeEntry?: () => Promise<boolean>;
}
export const loadAreaRegistryDetailDialog = () =>

View File

@@ -1,7 +1,13 @@
import { consume } from "@lit-labs/context";
import { mdiDelete, mdiPlus } from "@mdi/js";
import type { SortableEvent } from "sortablejs";
import { mdiDelete, mdiPlus, mdiArrowUp, mdiArrowDown, mdiDrag } from "@mdi/js";
import { CSSResultGroup, LitElement, PropertyValues, css, html } from "lit";
import { customElement, property, state } from "lit/decorators";
import { repeat } from "lit/directives/repeat";
import {
loadSortable,
SortableInstance,
} from "../../../../../resources/sortable.ondemand";
import { ensureArray } from "../../../../../common/array/ensure-array";
import { fireEvent } from "../../../../../common/dom/fire_event";
import "../../../../../components/ha-button";
@@ -14,6 +20,7 @@ import { ActionElement } from "../ha-automation-action-row";
import { describeCondition } from "../../../../../data/automation_i18n";
import { fullEntitiesContext } from "../../../../../data/context";
import { EntityRegistryEntry } from "../../../../../data/entity_registry";
import { sortableStyles } from "../../../../../resources/ha-sortable-style";
@customElement("ha-automation-action-choose")
export class HaChooseAction extends LitElement implements ActionElement {
@@ -27,81 +34,49 @@ export class HaChooseAction extends LitElement implements ActionElement {
@state() private _showDefault = false;
@state() private expandedUpdateFlag = false;
@state() private _expandedStates: boolean[] = [];
@state()
@consume({ context: fullEntitiesContext, subscribe: true })
_entityReg!: EntityRegistryEntry[];
private _expandLast = false;
private _sortable?: SortableInstance;
public static get defaultConfig() {
return { choose: [{ conditions: [], sequence: [] }] };
}
protected willUpdate(changedProperties: PropertyValues) {
if (!changedProperties.has("action")) {
return;
}
const oldCnt =
changedProperties.get("action") === undefined ||
changedProperties.get("action").choose === undefined
? 0
: ensureArray(changedProperties.get("action").choose).length;
const newCnt = this.action.choose
? ensureArray(this.action.choose).length
: 0;
if (newCnt === oldCnt + 1) {
this.expand(newCnt - 1);
}
}
private expand(i: number) {
this.updateComplete.then(() => {
this.shadowRoot!.querySelectorAll("ha-expansion-panel")[i].expanded =
true;
this.expandedUpdateFlag = !this.expandedUpdateFlag;
});
}
private isExpanded(i: number) {
const nodes = this.shadowRoot!.querySelectorAll("ha-expansion-panel");
if (nodes[i]) {
return nodes[i].expanded;
}
return false;
}
private _expandedChanged() {
this.expandedUpdateFlag = !this.expandedUpdateFlag;
private _expandedChanged(ev) {
this._expandedStates = this._expandedStates.concat();
this._expandedStates[ev.target!.index] = ev.detail.expanded;
}
private _getDescription(option, idx: number) {
if (option.alias) {
return option.alias;
}
if (this.isExpanded(idx)) {
if (this._expandedStates[idx]) {
return "";
}
if (!option.conditions || option.conditions.length === 0) {
const conditions = ensureArray(option.conditions);
if (!conditions || conditions.length === 0) {
return this.hass.localize(
"ui.panel.config.automation.editor.actions.type.choose.no_conditions"
);
}
let str = "";
if (typeof option.conditions[0] === "string") {
str += option.conditions[0];
if (typeof conditions[0] === "string") {
str += conditions[0];
} else {
str += describeCondition(
option.conditions[0],
this.hass,
this._entityReg
);
str += describeCondition(conditions[0], this.hass, this._entityReg);
}
if (option.conditions.length > 1) {
if (conditions.length > 1) {
str += this.hass.localize(
"ui.panel.config.automation.editor.actions.type.choose.option_description_additional",
"numberOfAdditionalConditions",
option.conditions.length - 1
conditions.length - 1
);
}
return str;
@@ -111,67 +86,100 @@ export class HaChooseAction extends LitElement implements ActionElement {
const action = this.action;
return html`
${(action.choose ? ensureArray(action.choose) : []).map(
(option, idx) =>
html`<ha-card>
<ha-expansion-panel
leftChevron
@expanded-changed=${this._expandedChanged}
>
<h3 slot="header">
${this.hass.localize(
"ui.panel.config.automation.editor.actions.type.choose.option",
"number",
idx + 1
)}:
${this._getDescription(option, idx)}
</h3>
<ha-icon-button
slot="icons"
.idx=${idx}
.disabled=${this.disabled}
@click=${this._removeOption}
.label=${this.hass.localize(
"ui.panel.config.automation.editor.actions.type.choose.remove_option"
)}
.path=${mdiDelete}
></ha-icon-button>
<div class="card-content">
<h4>
<div class="options">
${repeat(
action.choose ? ensureArray(action.choose) : [],
(option) => option,
(option, idx) =>
html`<ha-card>
<ha-expansion-panel
.index=${idx}
leftChevron
@expanded-changed=${this._expandedChanged}
>
<h3 slot="header">
${this.hass.localize(
"ui.panel.config.automation.editor.actions.type.choose.conditions"
"ui.panel.config.automation.editor.actions.type.choose.option",
"number",
idx + 1
)}:
</h4>
<ha-automation-condition
nested
.conditions=${ensureArray<string | Condition>(
option.conditions
)}
.reOrderMode=${this.reOrderMode}
.disabled=${this.disabled}
.hass=${this.hass}
.idx=${idx}
@value-changed=${this._conditionChanged}
></ha-automation-condition>
<h4>
${this.hass.localize(
"ui.panel.config.automation.editor.actions.type.choose.sequence"
)}:
</h4>
<ha-automation-action
nested
.actions=${ensureArray(option.sequence) || []}
.reOrderMode=${this.reOrderMode}
.disabled=${this.disabled}
.hass=${this.hass}
.idx=${idx}
@value-changed=${this._actionChanged}
></ha-automation-action>
</div>
</ha-expansion-panel>
</ha-card>`
)}
${this._getDescription(option, idx)}
</h3>
${this.reOrderMode
? html`
<ha-icon-button
.index=${idx}
slot="icons"
.label=${this.hass.localize(
"ui.panel.config.automation.editor.move_up"
)}
.path=${mdiArrowUp}
@click=${this._moveUp}
.disabled=${idx === 0}
></ha-icon-button>
<ha-icon-button
.index=${idx}
slot="icons"
.label=${this.hass.localize(
"ui.panel.config.automation.editor.move_down"
)}
.path=${mdiArrowDown}
@click=${this._moveDown}
.disabled=${idx ===
ensureArray(this.action.choose).length - 1}
></ha-icon-button>
<div class="handle" slot="icons">
<ha-svg-icon .path=${mdiDrag}></ha-svg-icon>
</div>
`
: html`
<ha-icon-button
slot="icons"
.idx=${idx}
.disabled=${this.disabled}
@click=${this._removeOption}
.label=${this.hass.localize(
"ui.panel.config.automation.editor.actions.type.choose.remove_option"
)}
.path=${mdiDelete}
></ha-icon-button>
`}
<div class="card-content">
<h4>
${this.hass.localize(
"ui.panel.config.automation.editor.actions.type.choose.conditions"
)}:
</h4>
<ha-automation-condition
nested
.conditions=${ensureArray<string | Condition>(
option.conditions
)}
.reOrderMode=${this.reOrderMode}
.disabled=${this.disabled}
.hass=${this.hass}
.idx=${idx}
@value-changed=${this._conditionChanged}
></ha-automation-condition>
<h4>
${this.hass.localize(
"ui.panel.config.automation.editor.actions.type.choose.sequence"
)}:
</h4>
<ha-automation-action
nested
.actions=${ensureArray(option.sequence) || []}
.reOrderMode=${this.reOrderMode}
.disabled=${this.disabled}
.hass=${this.hass}
.idx=${idx}
@value-changed=${this._actionChanged}
></ha-automation-action>
</div>
</ha-expansion-panel>
</ha-card>`
)}
</div>
<ha-button
outlined
.label=${this.hass.localize(
@@ -212,6 +220,30 @@ export class HaChooseAction extends LitElement implements ActionElement {
`;
}
protected firstUpdated() {
ensureArray(this.action.choose).forEach(() =>
this._expandedStates.push(false)
);
}
protected updated(changedProps: PropertyValues) {
super.updated(changedProps);
if (changedProps.has("reOrderMode")) {
if (this.reOrderMode) {
this._createSortable();
} else {
this._destroySortable();
}
}
if (this._expandLast) {
const nodes = this.shadowRoot!.querySelectorAll("ha-expansion-panel");
nodes[nodes.length - 1].expanded = true;
this._expandLast = false;
}
}
private _addDefault() {
this._showDefault = true;
}
@@ -250,6 +282,38 @@ export class HaChooseAction extends LitElement implements ActionElement {
fireEvent(this, "value-changed", {
value: { ...this.action, choose },
});
this._expandLast = true;
this._expandedStates[choose.length - 1] = true;
}
private _moveUp(ev) {
const index = (ev.target as any).index;
const newIndex = index - 1;
this._move(index, newIndex);
}
private _moveDown(ev) {
const index = (ev.target as any).index;
const newIndex = index + 1;
this._move(index, newIndex);
}
private _dragged(ev: SortableEvent): void {
if (ev.oldIndex === ev.newIndex) return;
this._move(ev.oldIndex!, ev.newIndex!);
}
private _move(index: number, newIndex: number) {
const options = ensureArray(this.action.choose)!.concat();
const item = options.splice(index, 1)[0];
options.splice(newIndex, 0, item);
const expanded = this._expandedStates.splice(index, 1)[0];
this._expandedStates.splice(newIndex, 0, expanded);
fireEvent(this, "value-changed", {
value: { ...this.action, choose: options },
});
}
private _removeOption(ev: CustomEvent) {
@@ -258,6 +322,7 @@ export class HaChooseAction extends LitElement implements ActionElement {
? [...ensureArray(this.action.choose)]
: [];
choose.splice(index, 1);
this._expandedStates.splice(index, 1);
fireEvent(this, "value-changed", {
value: { ...this.action, choose },
});
@@ -274,9 +339,37 @@ export class HaChooseAction extends LitElement implements ActionElement {
});
}
private async _createSortable() {
const Sortable = await loadSortable();
this._sortable = new Sortable(this.shadowRoot!.querySelector(".options")!, {
animation: 150,
fallbackClass: "sortable-fallback",
handle: ".handle",
onChoose: (evt: SortableEvent) => {
(evt.item as any).placeholder =
document.createComment("sort-placeholder");
evt.item.after((evt.item as any).placeholder);
},
onEnd: (evt: SortableEvent) => {
// put back in original location
if ((evt.item as any).placeholder) {
(evt.item as any).placeholder.replaceWith(evt.item);
delete (evt.item as any).placeholder;
}
this._dragged(evt);
},
});
}
private _destroySortable() {
this._sortable?.destroy();
this._sortable = undefined;
}
static get styles(): CSSResultGroup {
return [
haStyle,
sortableStyles,
css`
ha-card {
margin: 0 0 16px 0;
@@ -295,8 +388,6 @@ export class HaChooseAction extends LitElement implements ActionElement {
font-weight: inherit;
}
ha-icon-button {
position: absolute;
right: 0;
inset-inline-start: initial;
inset-inline-end: 0;
direction: var(--direction);
@@ -310,6 +401,14 @@ export class HaChooseAction extends LitElement implements ActionElement {
.card-content {
padding: 0 16px 16px 16px;
}
.handle {
cursor: move;
padding: 12px;
}
.handle ha-svg-icon {
pointer-events: none;
height: 24px;
}
`,
];
}

View File

@@ -2,12 +2,11 @@ import "@material/mwc-list/mwc-list";
import {
mdiAccount,
mdiFile,
mdiHomeAssistant,
mdiOpenInNew,
mdiPencilOutline,
mdiWeb,
} from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { CSSResultGroup, LitElement, css, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../../common/dom/fire_event";
@@ -18,16 +17,17 @@ import "../../../components/ha-icon-next";
import "../../../components/ha-list-item";
import "../../../components/ha-tip";
import { showAutomationEditor } from "../../../data/automation";
import { showScriptEditor } from "../../../data/script";
import {
Blueprint,
BlueprintDomain,
Blueprints,
BlueprintSourceType,
Blueprints,
fetchBlueprints,
getBlueprintSourceType,
} from "../../../data/blueprint";
import { showScriptEditor } from "../../../data/script";
import { HassDialog } from "../../../dialogs/make-dialog-manager";
import { mdiHomeAssistant } from "../../../resources/home-assistant-logo-svg";
import { haStyle, haStyleDialog } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url";

View File

@@ -86,7 +86,7 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) {
return html`
<ha-list-item
twoline
graphic="avatar"
graphic="medium"
class=${entity.attributes.skipped_version ? "skipped" : ""}
.entity_id=${entity.entity_id}
.hasMeta=${!this.narrow}
@@ -156,6 +156,9 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) {
.skipped {
background: var(--secondary-background-color);
}
ha-list-item {
--mdc-list-item-graphic-size: 40px;
}
ha-icon-next {
color: var(--secondary-text-color);
height: 24px;

View File

@@ -15,7 +15,7 @@ import {
} from "../../../../../../data/zwave_js";
import { showConfirmationDialog } from "../../../../../../dialogs/generic/show-dialog-box";
import type { HomeAssistant } from "../../../../../../types";
import { showZWaveJSHealNodeDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-heal-node";
import { showZWaveJSRebuildNodeRoutesDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-rebuild-node-routes";
import { showZWaveJSNodeStatisticsDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-node-statistics";
import { showZWaveJSReinterviewNodeDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-reinterview-node";
import { showZWaveJSRemoveFailedNodeDialog } from "../../../../integrations/integration-panels/zwave_js/show-dialog-zwave_js-remove-failed-node";
@@ -69,10 +69,12 @@ export const getZwaveDeviceActions = async (
}),
},
{
label: hass.localize("ui.panel.config.zwave_js.device_info.heal_node"),
label: hass.localize(
"ui.panel.config.zwave_js.device_info.rebuild_routes"
),
icon: mdiHospitalBox,
action: () =>
showZWaveJSHealNodeDialog(el, {
showZWaveJSRebuildNodeRoutesDialog(el, {
device,
}),
},

View File

@@ -5,7 +5,6 @@ import type { ChartOptions } from "chart.js";
import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { css, html, LitElement, nothing, PropertyValues } from "lit";
import { customElement, property, state } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import { numberFormatToLocale } from "../../../common/number/format_number";
import { round } from "../../../common/number/round";
@@ -283,53 +282,43 @@ class HaConfigHardware extends SubscribeMixin(LitElement) {
? html`
<ha-card outlined>
<div class="card-content">
<mwc-list>
<ha-list-item
noninteractive
graphic=${ifDefined(imageURL ? "medium" : undefined)}
.twoline=${Boolean(boardId)}
>
${imageURL
? html`<img alt="" slot="graphic" src=${imageURL} />`
: ""}
<span class="primary-text">
${boardName ||
this.hass.localize(
"ui.panel.config.hardware.generic_hardware"
)}
</span>
${boardId
? html`
<span class="secondary-text" slot="secondary"
>${boardId}</span
>
`
: ""}
</ha-list-item>
${documentationURL
? html`
<ha-clickable-list-item
.href=${documentationURL}
openNewTab
twoline
hasMeta
>
<span
>${this.hass.localize(
"ui.panel.config.hardware.documentation"
)}</span
>
<span slot="secondary"
>${this.hass.localize(
"ui.panel.config.hardware.documentation_description"
)}</span
>
<ha-icon-next slot="meta"></ha-icon-next>
</ha-clickable-list-item>
`
${imageURL ? html`<img alt="" src=${imageURL} />` : ""}
<div class="board-info">
<p class="primary-text">
${boardName ||
this.hass.localize(
"ui.panel.config.hardware.generic_hardware"
)}
</p>
${boardId
? html`<p class="secondary-text">${boardId}</p>`
: ""}
</mwc-list>
</div>
</div>
${documentationURL
? html`
<mwc-list>
<ha-clickable-list-item
.href=${documentationURL}
openNewTab
twoline
hasMeta
>
<span
>${this.hass.localize(
"ui.panel.config.hardware.documentation"
)}</span
>
<span slot="secondary"
>${this.hass.localize(
"ui.panel.config.hardware.documentation_description"
)}</span
>
<ha-icon-next slot="meta"></ha-icon-next>
</ha-clickable-list-item>
</mwc-list>
`
: ""}
${boardConfigEntries.length ||
isComponentLoaded(this.hass, "hassio")
? html`<div class="card-actions">
@@ -500,6 +489,8 @@ class HaConfigHardware extends SubscribeMixin(LitElement) {
padding: 28px 20px 0;
max-width: 1040px;
margin: 0 auto;
--mdc-list-side-padding: 24px;
--mdc-list-vertical-padding: 0;
}
ha-card {
max-width: 600px;
@@ -516,12 +507,21 @@ class HaConfigHardware extends SubscribeMixin(LitElement) {
flex-direction: column;
padding: 16px;
}
.card-content img {
max-width: 300px;
margin: auto;
}
.board-info {
text-align: center;
}
.primary-text {
font-size: 16px;
margin: 0;
}
.secondary-text {
font-size: 14px;
margin-bottom: 0;
color: var(--secondary-text-color);
}
.header {

View File

@@ -4,22 +4,22 @@ import {
mdiFileDocument,
mdiHandsPray,
mdiHelp,
mdiHomeAssistant,
mdiNewspaperVariant,
mdiTshirtCrew,
} from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { CSSResultGroup, LitElement, TemplateResult, css, html } from "lit";
import { property, state } from "lit/decorators";
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import "../../../components/ha-card";
import "../../../components/ha-clickable-list-item";
import "../../../components/ha-logo-svg";
import {
fetchHassioHassOsInfo,
HassioHassOSInfo,
fetchHassioHassOsInfo,
} from "../../../data/hassio/host";
import { fetchHassioInfo, HassioInfo } from "../../../data/hassio/supervisor";
import { HassioInfo, fetchHassioInfo } from "../../../data/hassio/supervisor";
import "../../../layouts/hass-subpage";
import { mdiHomeAssistant } from "../../../resources/home-assistant-logo-svg";
import { haStyle } from "../../../resources/styles";
import type { HomeAssistant, Route } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url";

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