Compare commits

..

270 Commits

Author SHA1 Message Date
Paul Bottein
0c86219358 Use bottom sheet 2025-04-08 15:20:19 +02:00
Paul Bottein
868f24eb9f Add basic dialog 2025-04-04 17:25:29 +02:00
Paul Bottein
e271989cee Add missing translations for areas strategy (#24905) 2025-04-03 14:02:27 +02:00
Paul Bottein
ca223f9d73 Refresh dashboard strategy when registries changed (#24902)
* Refresh dashboard strategy when registries changed

* Display toast before refreshing dashboard

* Apply suggestions
2025-04-03 10:10:11 +00:00
renovate[bot]
8fb1cf35ad Update Yarn to v4.8.1 (#24894)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-02 15:14:30 +03:00
karwosts
9f59be492e Render autogenerated step descriptions in trace path viewer (#24886) 2025-04-02 14:04:34 +03:00
Alex Gustafsson
8429d114a8 Improve toggle button for disabled combo boxes (#24843) 2025-04-01 19:07:34 +02:00
Bram Kragten
4fbc155f8b Use md list in config navigation (#24885) 2025-04-01 18:11:29 +02:00
Bram Kragten
cd39e2d0f2 Developer tools action fixes (#24876) 2025-04-01 13:18:04 +03:00
Paul Bottein
a23f57256c Add ellipsis for more info breadcrumb (#24882) 2025-04-01 13:11:13 +03:00
renovate[bot]
c279efaa99 Update dependency @codemirror/view to v6.36.5 (#24881)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-01 13:08:04 +03:00
karwosts
c4389ec119 Fix condition rendering in trace choose node (#24878) 2025-04-01 10:07:25 +02:00
Clemens Brauers
50d632f8d4 Add area and category as columns in automation, scenes and scripts (#24874)
Add area and category as optional columns in automation, scenes and scripts

Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
2025-04-01 06:56:02 +00:00
Petar Petrov
dba2fba828 Revert "Update rspack monorepo to v1.3.0" (#24879)
Revert "Update rspack monorepo to v1.3.0 (#24862)"

This reverts commit 8a2ab2eab4.
2025-04-01 06:29:14 +00:00
dependabot[bot]
3890afddb9 Bump vite from 6.2.3 to 6.2.4 (#24873)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.3 to 6.2.4.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.2.4/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.2.4/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-31 20:51:13 +02:00
Norbert Rittel
76f187ee2c Properly sentence-case "assistant" / "pipeline" (#24872) 2025-03-31 19:31:00 +02:00
Bram Kragten
488b54cf19 Fix add zwave device my link (#24871) 2025-03-31 17:01:15 +03:00
Bram Kragten
29d2c29af3 fix spinner in tts try dialog (#24867) 2025-03-31 15:06:15 +02:00
renovate[bot]
a2f9101a9f Update Yarn to v4.8.0 (#24863)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-31 16:04:51 +03:00
Paul Bottein
7893eba7a7 Handle date range shift during daylight saving time days (#24868) 2025-03-31 14:58:26 +02:00
Paul Bottein
94ced8af32 Add interactions for weather card editor (#24864) 2025-03-31 14:19:00 +02:00
Paul Bottein
c4b5882b2d Force clock card to display time LTR (#24865) 2025-03-31 14:18:39 +02:00
Bram Kragten
6e8bac2e58 Take lang into account when search existing pipeline (#24866)
* Take lang into account when search existing pipeline

* Simplify logic
2025-03-31 14:18:20 +02:00
renovate[bot]
8a2ab2eab4 Update rspack monorepo to v1.3.0 (#24862)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-31 13:14:34 +02:00
karwosts
c7e5be185d Bar charts start from 0 (#24854) 2025-03-31 12:13:03 +02:00
dependabot[bot]
e98721aa76 Bump home-assistant/wheels from 2025.02.0 to 2025.03.0 (#24860)
Bumps [home-assistant/wheels](https://github.com/home-assistant/wheels) from 2025.02.0 to 2025.03.0.
- [Release notes](https://github.com/home-assistant/wheels/releases)
- [Commits](https://github.com/home-assistant/wheels/compare/2025.02.0...2025.03.0)

---
updated-dependencies:
- dependency-name: home-assistant/wheels
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-31 09:10:57 +02:00
renovate[bot]
4c8d661c63 Update dependency @rsdoctor/rspack-plugin to v1.0.1 (#24853)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-30 15:57:18 +02:00
renovate[bot]
b7c60ffc74 Update dependency @material/web to v2.3.0 (#24850)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-30 09:08:38 +02:00
Jan-Philipp Benecke
db6c728cd6 Fix inner border radius for disabled bar in automation/script rows (#24840) 2025-03-29 09:54:09 +01:00
renovate[bot]
34f8335a9d Update dependency @formatjs/intl-datetimeformat to v6.18.0 (#24841)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-29 08:23:21 +01:00
renovate[bot]
ecf5068bd0 Update dependency luxon to v3.6.0 (#24837)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-28 23:48:40 +01:00
Bram Kragten
0a2a2b8a70 Name local pipeline based on local or full choice (#24835) 2025-03-28 18:29:47 +01:00
Paul Bottein
52f4fe6bc0 Only use button for breadcrumb for admin users (#24836) 2025-03-28 13:03:56 -04:00
Bram Kragten
a781bca94b Update lang support text in voice wizard (#24834) 2025-03-28 16:04:48 +00:00
Paul Bottein
63b44c25f8 Remove add-on word in satellite wizard translations for state (#24832) 2025-03-28 15:01:09 +00:00
Eloy Rodriguez
b96319703a Add title and time zone to clock card (#24818)
* Add title and time zone to clock card

* Small changes to the spacing and text sizing of the clock card

* Update translations to use dropdown labels from profile configuration

* Use similar approach as #24819 for setting automatic time zone

* Update hui-clock-card.ts

---------

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2025-03-28 14:32:50 +00:00
Paul Bottein
9e686190f6 More info breadcrumb clickable (#24830)
* Make more info breadcrum clickable

* css adjustements
2025-03-28 15:26:09 +01:00
Darren Griffin
5ca7b1d508 Fix default time_format option. Fixes #24798 (#24819)
* Fix default time_format option. Fixes #24798

* Update en.json

* Update src/translations/en.json

---------

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2025-03-28 14:13:50 +00:00
Bram Kragten
7c1d74c6c3 Update voice-assistant-setup-step-local.ts 2025-03-28 15:01:08 +01:00
Bram Kragten
d257f667c1 Update text voice wizard install addons step (#24829) 2025-03-28 13:06:54 +00:00
Paulus Schoutsen
842a064682 Hide backup from default dashboard (#24828) 2025-03-28 12:55:39 +00:00
Bram Kragten
3d8e146582 Fix voice flow (#24825)
* Fix voice flow

* Apply suggestions from code review

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2025-03-28 12:53:08 +00:00
Paulus Schoutsen
78e8bd4305 Do not play pre-announce sound when testing voice on satellite (#24827) 2025-03-28 08:40:57 -04:00
Paul Bottein
0152a79bd5 Add hold and double tap action in the UI for every card that supports it. (#24824)
* Add double tap action to button card UI editor

* Add double tap action to light card UI editor

* Add hold action and double tap action to gauge card UI editor

* Add hold action and double tap action to picture glance card UI editor

* Add hold action and double tap action to picture card UI editor

* Add hold action and double tap action to entity card UI editor

* Add hold action and double tap action to elements
2025-03-28 13:12:07 +01:00
Paul Bottein
f5bb72f067 Add scroll restoration when using back navigation in dashboard (#24822)
Add scroll restoration when using back navigation with subviews
2025-03-28 12:07:42 +01:00
Alex Gustafsson
9ca6a886f5 Fix hide clear icon of entity picker (#24821) 2025-03-28 08:04:40 +00:00
renovate[bot]
f39011f8f4 Update dependency sinon to v20 (#24810)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-28 09:49:00 +02:00
puddly
8b190867e3 Show hardware integrations in the integration list (#24820)
Show hardware integrations in the frontend
2025-03-28 08:25:07 +02:00
renovate[bot]
321b15a270 Update dependency typescript-eslint to v8.28.0 (#24806)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-27 19:44:12 +01:00
renovate[bot]
6ba235d540 Update babel monorepo to v7.27.0 (#24807)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-27 19:43:54 +01:00
renovate[bot]
e34fd8161c Update dependency sinon to v19.0.5 (#24809)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-27 19:43:38 +01:00
Paul Bottein
084cda8218 Fix dashboard strategy (#24808) 2025-03-27 18:09:46 +00:00
Paul Bottein
f06a0fa34c Fallback to state name when the entry doesn't have name (#24805) 2025-03-27 18:51:08 +01:00
Paul Bottein
750c59399b Set the max number of columns to 3 for area dashboard (#24802)
* Set the max number of columns to 4 for area dashboard

* Set it to 3
2025-03-27 16:39:47 +01:00
Paul Bottein
a6a17cd70c Add loading state to area strategy (#24803) 2025-03-27 15:37:32 +00:00
karwosts
de1c6a5178 Energy device settings fixes (#24801) 2025-03-27 16:30:17 +01:00
Bram Kragten
04c3cd7d68 Align behavior of template selector with text selector (#24796) 2025-03-27 13:53:35 +01:00
Paul Bottein
17ef74d680 Fix take control of the dashboard (#24800) 2025-03-27 13:33:52 +01:00
Paul Bottein
098c6a2567 Remove fixed height in ha tile info (#24787)
Remove unused height in ha tile info
2025-03-27 11:10:45 +01:00
Paul Bottein
899288ae43 Revert "Restore scroll position when using back navigation in dashboard" (#24795)
Revert "Restore scroll position when using back navigation in dashboard (#24777)"

This reverts commit 9cfcd21a93.
2025-03-27 11:10:23 +01:00
Paul Bottein
a9823f30e3 Fix more info for disabled entities (#24789) 2025-03-27 08:49:25 +02:00
Bram Kragten
97966805fa Fix typo in Arithmetic (#24786)
Fix type in Arithmetic
2025-03-26 16:13:11 +01:00
Bram Kragten
615b228827 Merge branch 'rc' into dev 2025-03-26 15:46:47 +01:00
Bram Kragten
1819c04c27 Bumped version to 20250326.0 2025-03-26 15:46:00 +01:00
Darren Griffin
05e303d771 Add simple clock card (#24599)
* Initial clock card

* Tidy clock card and change stub config

* Change fallback to 'nothing'

* Update src/panels/lovelace/cards/types.ts

Co-authored-by: Paul Bottein <paul.bottein@gmail.com>

* Update src/panels/lovelace/cards/hui-clock-card.ts

Co-authored-by: Paul Bottein <paul.bottein@gmail.com>

* Update src/panels/lovelace/cards/hui-clock-card.ts

Co-authored-by: Paul Bottein <paul.bottein@gmail.com>

* Added cardSize and gridOptions. Fixed invalid time type

* Improve font sizes

* Fix default case handling

* Move interval outside class

* WIP improvements

* Various improvements

* Improve date instantiation and display

* Reintroduce localized time format

* Swap to uusing key for time_format translation

* Add fallback for initial load

* Final fixes

* Update clock card description

* Update src/panels/lovelace/cards/types.ts

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Tidy up

* Present css better

* Change default sizing to small

* Set default data

* Change to grid, rework typography alignment

* Update hui-clock-card.ts

* Update hui-clock-card.ts

---------

Co-authored-by: Paul Bottein <paul.bottein@gmail.com>
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2025-03-26 14:45:36 +00:00
Paul Bottein
53bb8251fa Separate entity, device and area name in more info dialog header (#21951)
* Separate entity, device and area name in more info dialog header

* Use has_entity_name

* Separate entity, device and area name in entity picker

* Fix entity name with has entity name

* Fix compute entity name

* Add full name

* Add floor

* Improve code quality

* Use compute entity name in device entities card

* Use context functions

* Remove floor

* Use state name provided by backend

* Use breadcrumb for more info

* Revert entity picker changes

* Use new logic in device page

* Use breadcrumb

* Use join directive

* Add comments

* Use secondary text color

* Update compute_entity_name.ts

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Remove html join

* Improve computeDeviceNameDisplay

* Fallback to original name

* Simplify more info logic

* Include breadcrumb for child view (voice assistant)

---------

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2025-03-26 13:58:34 +00:00
Bram Kragten
f6467a35db Update voice wizard (#24750)
* Update pipeline step, add option for speech-to-phrase addon

* adjust to core changes

* Update conversation.ts

* Update voice-assistant-setup-step-pipeline.ts

* Update voice-assistant-setup-dialog.ts

* review
2025-03-26 14:05:51 +01:00
renovate[bot]
7cc6397324 Update dependency @types/leaflet to v1.9.17 (#24784)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-26 12:45:52 +00:00
renovate[bot]
f6e3e312bb Update dependency @rsdoctor/rspack-plugin to v1 (#24724)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-26 13:40:18 +01:00
Bram Kragten
be1e1ff9fc Statistics: Add support for mean type (#24758)
* Statistics: Add support for mean type

* update

* update enum

* Update en.json
2025-03-26 14:35:38 +02:00
ildar170975
2717e1e6cb Remove "filterable" from "created_at", "modified_at", "battery_entity" from data tables (#24766)
* remove "filterable" from "created_at" & "modified_at"

* remove "filterable" from "created_at", "modified_at", "battery"

* remove "filterable" from "created_at" & "modified_at"
2025-03-26 11:32:14 +01:00
ildar170975
2e9f72867f Add hidden "entity_id" column to "Settings -> Automations" (#24769)
* add hidden "entity_id" column

* Apply suggestions from code review

---------

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2025-03-26 10:30:08 +00:00
Jonathan Hanson
ff6b318fc9 style changes to the zigbee graph, without touching the physics (#24697) 2025-03-26 11:08:44 +01:00
Bram Kragten
386b8ba747 Move compatibility to static polyfill handling (#24775)
* Move compatibility to static polyfill handling

* Move compatibility to static polyfill handling

* Prettier
2025-03-26 11:38:53 +02:00
Bram Kragten
e27b97abc0 Update ha-config-helpers.ts 2025-03-26 10:20:55 +01:00
karwosts
772a2658cb Allow passing data as template in devtools/action (#24737) 2025-03-26 10:13:06 +01:00
Paul Bottein
1a076061da Add optional interaction for cards (hold, double tap) in the UI (#24754) 2025-03-26 09:42:10 +01:00
Bram Kragten
1cb71ed379 Dont show quality scale for custom integrations (#24783) 2025-03-26 07:46:43 +00:00
Simon Lamon
fb11c21518 Fix device config tooltips (#24780)
* Device config tooltips

* Update src/panels/config/devices/ha-config-device-page.ts

Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>

---------

Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
2025-03-26 09:32:14 +02:00
Paul Bottein
9cfcd21a93 Restore scroll position when using back navigation in dashboard (#24777)
Restore scroll position when using backup navigation in dashboard
2025-03-26 09:21:04 +02:00
renovate[bot]
e3f5e921d6 Update formatjs monorepo (#24781)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-26 08:36:33 +02:00
dependabot[bot]
df4e81be75 Bump vite from 6.2.2 to 6.2.3 (#24776)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.2 to 6.2.3.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.2.3/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.2.3/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-25 17:38:58 +02:00
ildar170975
1519e1b90c ha-dialog-import-blueprint: add "enlarge" (#24734)
* add enlarge

* removed unused "createCloseHeading"

* restore deleted "import" line

* import ha-dialog-header
2025-03-25 16:51:54 +02:00
Wendelin
4c8b7a30f4 fix cloud login mfa inProgress (#24773) 2025-03-25 14:56:30 +01:00
ildar170975
1e513281f4 dev-tools-template: allow "select" for whole right panel (except header) (#24713)
developer-tools-template: allow "select" for whole right panel (except header)
2025-03-25 15:32:30 +02:00
renovate[bot]
3c28764264 Update dependency eslint to v9.23.0 (#24764)
* Update dependency eslint to v9.23.0

* lint fix

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
2025-03-25 13:19:53 +00:00
renovate[bot]
82be98dad6 Update dependency @bundle-stats/plugin-webpack-filter to v4.19.1 (#24763)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-25 14:58:53 +02:00
ildar170975
3320cf1880 Add "label_mode = attribute" for Map card (#24708)
* add "label_mode = attribute"

* add "label_mode = atribute"

* added "label_mode = attribute"

* add "attribute" property

* add "attribute" property to GeoLocationSourceConfig

* add "attribute" property

* add "attribute" in _getSourceEntities

* check for entity.attribute !== undefined

* prettier
2025-03-25 14:57:53 +02:00
ildar170975
f7cb83482a computeAttributeValueDisplay: process "undefined" like "null" (#24712)
treat "undefined" as "null"
2025-03-25 14:54:22 +02:00
ildar170975
a9ddaf1bd7 Dev tools -> yaml: use "pre" instead of "span" for "validate-log" (#24722)
* use "pre" instead of "span" for "validate-log"

* prettier

* prettier

* remove "Important" for margin

* remove line-breakes

* prettier

* prettier

* prettier-ignore

* prettier

* prettier
2025-03-25 12:18:19 +00:00
Bram Kragten
eb7923fa49 Fix selector filtering for entity not in state machine (#24772) 2025-03-25 10:26:34 +01:00
Paul Bottein
2ae70e9b54 Improve strategy editor (#24757)
* Add cancel and delete button

* Implement delete

* Reset gui mode when closing
2025-03-24 18:57:10 +01:00
Bram Kragten
3857c53b7f Use ha-md-button-menu in tabs subpage data table (#24738) 2025-03-24 18:56:58 +01:00
Bram Kragten
620fb6375e Save login after onboarding (#24759) 2025-03-24 17:58:07 +01:00
Bram Kragten
e18f853f7e Fix state display mixin (#24760) 2025-03-24 17:57:52 +01:00
Bram Kragten
bbe549fa86 Process expandable initial data also for none required expandables (#24733)
* Process expandable initial data also for none required expandables

* Update compute-initial-ha-form-data.ts

* check required fields of sections too when submitting
2025-03-24 17:31:06 +02:00
ildar170975
586a137037 Device page: use different prompts for "device = enabled" & "device = disabled" cases (#24739)
* prompts for enabled & disabled devices

* add different prompts for "device = enabled" & "device = disabled"

* prettier

* prettier

* prettier

* prettier

* prettier

* prettier
2025-03-24 17:25:28 +02:00
ildar170975
60010c82bd ha-config-devices-dashboard: add "disabled" column (#24730)
add "disabled" column
2025-03-24 15:36:44 +01:00
ildar170975
d77f962087 dialog-media-player-browse: fix height (#24731) 2025-03-24 15:21:49 +01:00
karwosts
4c952c191a Fix hui-energy-compare-card (#24711)
* Fix hui-energy-compare-card

* rename var
2025-03-24 15:14:18 +01:00
Clay Benson
e0fbd3cd1f Add hold and double tap actions in hui-entity-heading-badge (#24707)
* feat: Add support for hold and double tap actions in hui-entity-heading-badge

* fix: Add hold_action and double_tap_action to config struct and interactions to allow GUI editor to work for badge interactions

* chore: Remove hold and double_tap from UI editor schema on entity heading badge editor
2025-03-24 13:19:41 +00:00
karwosts
9f05f4df50 Short-format numbers in energy-distribution-card (#24716) 2025-03-24 12:43:11 +01:00
karwosts
6fbc7b2efe Support for hierarchy of individual energy devices (#23185)
* Support for hierarchy of individual energy devices

* better config ui

* replace parent_stat w included_in_stat

* semi-working

* update order suffix in id when hidden changes

* rollback some ordering changes, update strings

* Remove hidden tracking, add untracked label to name.

* Update dialog-energy-device-settings.ts

* Change sort algorithm
2025-03-24 13:39:19 +02:00
ildar170975
8dab7c598e Logbook card: fix height in Panel view (#24745)
* fix height in Panel

* Update src/panels/lovelace/cards/hui-logbook-card.ts

Co-authored-by: Paul Bottein <paul.bottein@gmail.com>

* prettier

---------

Co-authored-by: Paul Bottein <paul.bottein@gmail.com>
2025-03-24 09:43:47 +00:00
Wendelin
b24f185d62 Update tsparticles to use new repo (#24688) 2025-03-24 09:26:51 +00:00
ildar170975
dc5bb899d2 fix validate-condition: unavailable -> unknown (#24749)
unavailable -> unknown
2025-03-24 09:36:05 +01:00
Paulus Schoutsen
420477e416 Show cameras on 2 rows in areas strategy (#24743)
Show cameras on 2 rows in areas
2025-03-24 08:38:53 +01:00
dependabot[bot]
cd9faf7d67 Bump actions/cache from 4.2.2 to 4.2.3 (#24748)
Bumps [actions/cache](https://github.com/actions/cache) from 4.2.2 to 4.2.3.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4.2.2...v4.2.3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-24 08:55:04 +02:00
dependabot[bot]
852207a5f5 Bump actions/upload-artifact from 4.6.1 to 4.6.2 (#24747)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.1 to 4.6.2.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4.6.1...v4.6.2)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-24 08:54:25 +02:00
renovate[bot]
1f705c07b2 Update dependency typescript-eslint to v8.27.0 (#24735)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-24 06:30:09 +01:00
renovate[bot]
39ee84b54e Update dependency @lokalise/node-api to v14.2.0 (#24741)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-24 06:29:46 +01:00
renovate[bot]
de402e7c1a Update dependency sinon to v19.0.4 (#24729)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-22 17:45:23 +01:00
renovate[bot]
9b74cdebc2 Update dependency sinon to v19.0.3 (#24727)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-22 17:22:42 +01:00
renovate[bot]
ebe8e54046 Update dependency @babel/helper-define-polyfill-provider to v0.6.4 (#24726)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-22 17:22:25 +01:00
renovate[bot]
2bac7455cc Update dependency eslint-plugin-lit to v2 (#24719)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-22 07:16:06 +01:00
renovate[bot]
3cbeef070a Update dependency eslint-plugin-wc to v3 (#24723)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-22 07:15:29 +01:00
renovate[bot]
bae0c232be Update octokit monorepo (#24718)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-22 07:14:54 +01:00
renovate[bot]
e65b5ae91e Lock file maintenance (#24684)
* Lock file maintenance

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-20 20:45:01 +01:00
Petar Petrov
4a166b6c23 Fix race condition when saving url config (#24687)
* Fix race condition when saving url config

* use SubscribeMixin
2025-03-20 19:54:02 +01:00
Paul Bottein
fe17bb89eb Area strategy fixes (#24700)
* Add missing water heater domain and change lights icon

* Rename areas view to areas overview view

* Use same max columns for area view and overview

* Use large section when only one section
2025-03-20 19:09:51 +01:00
Marc Mueller
888b2472df Remove old setuptools keys from metadata (#24702) 2025-03-20 19:07:26 +01:00
Marc Mueller
ef7f499364 Update project metadata for PEP 639 (#24701) 2025-03-20 17:43:44 +01:00
renovate[bot]
5d9a53dcd5 Update vitest monorepo to v3.0.9 (#24703)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-20 14:24:57 +01:00
Paul Bottein
7ce166e40f Area dashboard improvement (#24690)
* Add more domains in the areas dashboard and strip area name from the entity name

* Display cover without device classes

* Remove useless test
2025-03-19 23:19:58 +01:00
Paul Bottein
2c0c48106d Add entities filtering and reordering for areas strategy dashboard (#24677)
* Add entities editor

* Save entities per domain and area

* Use hidden and reorder logic in dashboard

* Add overview hidden logic

* Don't use icon for nav

* Remove overview hidden

* Change default text

* Fix icons

* Rename config properties
2025-03-19 21:11:46 +01:00
Wendelin
0e8be25a60 Rename last_non_idle_event to last_action_event (#24691) 2025-03-19 17:28:44 +01:00
ildar170975
27379c98df history-graph: do not set "max-width" for a single legend item (#24683)
* do not set "max-width" for a single legend item

* prettier
2025-03-19 08:46:14 +02:00
Wendelin
4076e5655a Add HA Cloud login to onboarding (#24485)
* Add ha cloud login to onboarding

* Add view for no cloud backup available

* Add logout and forgot pw

* Improve styling

* Fix bug to open cloud backup after login

* Remove callback from catch in transform methods

* Remove unused variable

* Fix lint

* Add new onboarding restore design

* Fix lint

* Change back button style

* Update header styles

* Style onboarding left aligned

* Remove unused imports

* Fix imports

* Fix multi factor cloud auth

* Fix prettier

* Edit onboarding translations

* Revert gulp change

* Improve cloud login component

* Fix no-cloud-backup naming

* fix types

* Use cloud login function directly

* Fix eslint

* Hide restore picker when there is nothing to select

* Fix eslint
2025-03-18 15:24:04 +01:00
ildar170975
858b8b90d8 integrations-startup-time: set "border-radius: 0" for "img" (#24679)
set "border-radius: 0" for "img"
2025-03-18 15:47:13 +02:00
Guy Taggar
d61c771e35 Add shoelace z-index value (#24669)
* Add shoelace z-index value

* Update src/components/ha-tooltip.ts

---------

Co-authored-by: Wendelin <12148533+wendevlin@users.noreply.github.com>
2025-03-18 09:26:57 +01:00
ildar170975
ddbf57d541 developer-tools-template: allow "select" for ha-alert (#24674)
added "user-select: text" for ha-alert
2025-03-18 09:54:15 +02:00
karwosts
a5b7bb8391 Fix behavior of select dropdowns when options change (#24603)
* Fix behavior of select dropdowns when options change

* new approach

* memoize
2025-03-17 22:11:37 +01:00
Simon Lamon
5803ab68c2 Fix energy units (#24672) 2025-03-17 22:07:27 +01:00
Paul Bottein
64b9104199 Add area dashboard settings (#24619)
* Add hidden and order settings

* Share path logic

* Add editor to sort and filter areas

* Remove unused form

* Add areas strategy in the dashboard picker

* Move display editor

* Fix min width

* Add leading icon slot to expansion panel

* Fix left chevron icon with dynamic property

* Use area display in original state strategy

* Rename selector

* Rename to area_display

* Remove ha-expansion-panel changes

* Remove expanded

* Fix rebase

* Display all entities in the areas strategy overview (#24663)

* Don't use subgroup

* Add all entities in the overview

* Add tile card features for area view
2025-03-17 22:04:01 +01:00
renovate[bot]
7aaea37db7 Update dependency ua-parser-js to v2.0.3 (#24671)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-17 20:47:05 +01:00
Paul Bottein
3c11323ea4 Add leading icon slot to expansion panel and fix left-chevron property (#24635)
* Add leading icon slot to expansion panel and fix left chevron

* Update components
2025-03-17 20:23:20 +01:00
Paul Bottein
4f7d5053ec Add computeStateName fallback to tile card and badges (#24666) 2025-03-17 14:06:53 +00:00
Matěj 'Horm' Horák
7009482057 Show hide create option in todo card editor (#24643)
Show hide create option in todo editor
2025-03-17 15:00:35 +01:00
renovate[bot]
d1090e8ad3 Update vaadinWebComponents monorepo to v24.7.0 (#24664)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-17 14:50:15 +01:00
Wendelin
06b969f6b6 Fix translations transform build errors (#24631)
Let gulp handle transform errors
2025-03-17 14:02:41 +01:00
renovate[bot]
d8b6de2afd Update vaadinWebComponents monorepo to v24.6.7 (#24661)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-17 09:00:09 +00:00
Wendelin
dfd5e80436 Fix update list item spinner (#24660) 2025-03-17 09:50:55 +01:00
Petar Petrov
9d4df46d5f Fix for 0 values in line chart tooltip (#24658) 2025-03-17 09:49:31 +01:00
dependabot[bot]
5f4cb9e3c1 Bump actions/setup-node from 4.2.0 to 4.3.0 (#24656) 2025-03-17 08:27:41 +01:00
dependabot[bot]
96e6169b8d Bump relative-ci/agent-action from 2.1.14 to 2.2.0 (#24657) 2025-03-17 08:20:48 +01:00
renovate[bot]
0906d7aa5a Update CodeMirror (#24652)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-17 08:52:13 +02:00
karwosts
02fce1f40a Save preferred energy period in localStorage (#24654) 2025-03-17 08:36:31 +02:00
karwosts
05aa55bfb9 Fix describing device conditions in trace viewer (#24645) 2025-03-16 09:14:40 +01:00
karwosts
d4717f1293 Handle short form hex colors in conversion functions (#24642)
* Handle short form hex colors in conversion functions

* drop alpha codes
2025-03-16 09:13:13 +01:00
renovate[bot]
f6a7e40d4a Update dependency lint-staged to v15.5.0 (#24644)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-16 09:10:08 +01:00
renovate[bot]
d73e677bea Update dependency @lokalise/node-api to v14.1.0 (#24638)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-15 08:51:53 +01:00
renovate[bot]
356b74607a Update dependency @shoelace-style/shoelace to v2.20.1 (#24637)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-15 08:51:32 +01:00
renovate[bot]
8cb248223d Update babel monorepo to v7.26.10 (#24636)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-15 08:51:16 +01:00
renovate[bot]
24eed2e5fa Update rspack monorepo to v1.2.8 (#24632)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-14 17:49:15 +01:00
karwosts
c8a21a7a2f Restore +/- buttons on featureless thermostat (#24634)
* Restore +/- buttons on featureless thermostat

* Update hui-humidifier-card.ts

* Update hui-thermostat-card.ts
2025-03-14 16:30:19 +01:00
Petar Petrov
54cc096b1a Backup/Restore NVM in Z-WaveJS dashboard (#24277)
* Backup/Restore NVM in Z-WaveJS dashboard

* update API

* Handle file with HTTP

* MVP with 2 buttons

* format

* improve naming

* text tweak

* migrate to ha-progress-ring

* handle download errors

* fix restore progress
2025-03-14 15:17:29 +01:00
Jan-Philipp Benecke
49b1198cb7 Add yaml option to disable iFrame sandbox to embed PDFs (#24620)
* Add yaml option to disable iFrame sandbox to embed PDFs

* Apply suggestions from code review

Co-authored-by: Wendelin <12148533+wendevlin@users.noreply.github.com>

---------

Co-authored-by: Wendelin <12148533+wendevlin@users.noreply.github.com>
2025-03-14 13:45:22 +01:00
karwosts
91e9836423 Fix accessibility in add helper dialog (#24627) 2025-03-14 11:15:59 +01:00
Wendelin
6aa2a576b3 Revert "Unified safe area (insets) for Android and iOS" (#24629)
Revert "Unified safe area (insets) for Android and iOS (#23811)"

This reverts commit ee10f9080d.
2025-03-14 11:03:50 +01:00
Norbert Rittel
9712f04662 Fix short_weekdays::sun in Backup settings (#24628)
Fix short `short_weekdays::sun`

"So" is for us Germans, for English we better use "Su" here. :-)
2025-03-14 10:01:31 +01:00
renovate[bot]
731a9a2e07 Update dependency typescript-eslint to v8.26.1 (#24625)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-14 09:50:34 +01:00
Simon Lamon
d42bd36a3e Fix logbook keeps loading (#24351)
* Logbook loading

* Redo typing

* small fixes

* async/sync fixes
2025-03-13 17:18:24 +01:00
Wendelin
28c355812c Add shoelace loading spinner component (#24525)
* Add loading spinner component

* Update some spinners

* Update some spinners

* Update indeterminate to ha-spinner

* add ha-spinner-delayed

* Remove ha-circular-progress component

* Update demo/src/custom-cards/ha-demo-card.ts

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Fix gallery

* Update set size

* Add ha-fade-in

* Remove wrong testing conditions

* Remove size number option

---------

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2025-03-13 17:05:51 +01:00
Paul Bottein
e09dbb474b Add foundation for areas dashboard strategy (#24582)
* Add entity filter section strategy

* Rename parameters

* Add group support

* Add empty state

* Add area strategy

* Remove title

* Fix heading

* Add areas dashboard and views

* Use satisfies

* Remove unnecessary array copy

* Only define set if needed

* Sort area by name

* Fix sorting

* Use entity id

* Don't use section strategy in view

* Simplify view

* Remove section related changes
2025-03-13 17:03:35 +01:00
Grzegorz Libiszewski
ee10f9080d Unified safe area (insets) for Android and iOS (#23811)
* feat: Introduce new css variables for safe area

* feat: Replace all safe area env with variable

* fix: CR fix move from derived styles to styles and rename
2025-03-13 10:20:54 +02:00
renovate[bot]
4f9ec622bf Update dependency @babel/runtime to v7.26.10 [SECURITY] (#24615)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-13 07:40:28 +00:00
renovate[bot]
dba269f2a3 Update dependency @bundle-stats/plugin-webpack-filter to v4.19.0 (#24605)
* Update dependency @bundle-stats/plugin-webpack-filter to v4.19.0

* fix build

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
2025-03-13 07:30:35 +00:00
Bram Kragten
46c9af75fd Bumped version to 20250312.0 2025-03-12 18:53:49 +01:00
karwosts
df934cfed9 Energy self sufficiency gauge needs grid consumption (#24606) 2025-03-12 18:53:22 +01:00
Wendelin
e871dc8151 Increase core start seconds (#24604) 2025-03-12 18:53:21 +01:00
karwosts
69026cbecf Energy self sufficiency gauge needs grid consumption (#24606) 2025-03-12 18:06:31 +01:00
Bram Kragten
dda7de3301 Fix issues with develop and serve (#24602)
* fix issues with develop and serve

* fix get image data, use hassUrl

* save picture-upload

* Update bundje.cjs

* Prettier

* Fix profile picture in dev serve mode

* person badge too

---------

Co-authored-by: Wendelin <w@pe8.at>
2025-03-12 16:59:40 +01:00
Wendelin
1e000d2740 Increase core start seconds (#24604) 2025-03-12 16:19:42 +01:00
Paulus Schoutsen
1d747c0901 Simplify CO2Signal check (#24566)
* Simplify CO2Signal check

* Remove more references.

* Update energy.ts
2025-03-12 08:31:12 +02:00
Norbert Rittel
8ef769559f Use proper capitalization for "WPA-PSK" (#24597)
This abbreviation is consistently referred to using upper-case letters (Wikipedia, e.g.)
2025-03-11 19:22:32 +01:00
karwosts
e141b4dbee Disable energy distribution animation if prefers-reduced-motion is set (#24581)
* Disable energy distribution animation if prefers-reduced-motion is set

* Move check to willUpdate. Remove circle circumference animation
2025-03-11 14:57:43 +01:00
puddly
d0545fe827 Update ZHA device websocket API types (#24087)
* Expose routing status from ZHA websocket API

* Clean up types a little bit

* Lint
2025-03-11 15:00:12 +02:00
renovate[bot]
4ef3a25479 Update dependency eslint to v9.22.0 (#24593)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-11 09:47:19 +02:00
Paul Bottein
616c1fda81 Rename entity filter to entity domain filter (#24587) 2025-03-10 13:34:15 -04:00
Paul Bottein
e8805be561 Perform action in slider and switch if it's a long press (#24579) 2025-03-10 15:30:29 +01:00
Darren Griffin
1b6d2ac08e Make element-preview sticky (#24580) 2025-03-10 14:07:29 +01:00
renovate[bot]
de4a8a0a72 Update dependency eslint-config-prettier to v10.1.1 (#24578)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-10 11:46:03 +01:00
Paulus Schoutsen
58dd778b3d Add some type checking to demo (#24567) 2025-03-10 11:24:57 +01:00
karwosts
a4cdb294b1 Fix some issues with energy period update scheduling (#24563) 2025-03-10 08:46:05 +02:00
karwosts
07c4296771 Show statistics in history card on first load (#24554)
* Show statistics in history card on first load

* unnecessary line
2025-03-10 08:36:17 +02:00
renovate[bot]
95a99c7857 Update dependency terser-webpack-plugin to v5.3.14 (#24571)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-10 08:33:11 +02:00
pisanvs
fee215fe96 Add missing margin to protection mode alert in addon info panel. (#24490)
* Add missing margin to protection mode alert in addon info panel.

* Only apply on the top level

Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>

---------

Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
2025-03-10 06:29:17 +00:00
renovate[bot]
5e9341bf4e Update vitest monorepo to v3.0.8 (#24573)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-10 08:19:02 +02:00
renovate[bot]
58b7c76b90 Update dependency terser-webpack-plugin to v5.3.13 (#24564)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-08 21:32:23 +01:00
Paulus Schoutsen
6ed26407be Update country picker dialog in onboarding (#24551)
* Update country picker dialog in onboarding

* Handle if language has no locale

* Don't fall back to NL
2025-03-08 14:40:22 +00:00
dependabot[bot]
1ac0092d4e Bump axios from 1.7.9 to 1.8.2 (#24552)
Bumps [axios](https://github.com/axios/axios) from 1.7.9 to 1.8.2.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.7.9...v1.8.2)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-07 19:37:07 +01:00
renovate[bot]
a4e8ea366a Update dependency @lokalise/node-api to v14 (#24547)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-07 18:18:04 +01:00
renovate[bot]
fe70355dde Update dependency typescript-eslint to v8.26.0 (#24533)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-06 19:40:01 +01:00
renovate[bot]
01f07f6476 Update rspack monorepo to v1.2.7 (#24531)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-06 18:49:15 +01:00
Bram Kragten
9ef72e4afc Bumped version to 20250306.0 2025-03-06 15:57:06 +01:00
Paul Bottein
022ef982ca Only recreate stack editor when the type or index change (#24530) 2025-03-06 15:56:10 +01:00
Petar Petrov
f132a32fd4 Ignore excessive keydown events in charts (#24523)
* Ignore excessive keydown events in charts

* lint
2025-03-06 15:56:09 +01:00
Petar Petrov
782df0473c Fix height of chart legend (#24519) 2025-03-06 15:56:08 +01:00
Wendelin
690cd47945 Landingpage add core checks before show errors (#24493)
* Check core only if supervisor or observer is unresponsive

* Improve core check

* Revert test code

* Remove unused prop

* Combine network info with core check

* Combine ping and network info

* Add 30 sec timeout before show errors

* Update landing-page/src/ha-landing-page.ts

* Assume supervisor update on failed ping

* Fix typo
2025-03-06 15:56:07 +01:00
Paul Bottein
8fe55b9bc0 Only recreate stack editor when the type or index change (#24530) 2025-03-06 15:55:20 +01:00
renovate[bot]
913fdfd0eb Update dependency @codemirror/view to v6.36.4 (#24524)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-06 14:25:34 +02:00
Wendelin
c97916bea4 Landingpage add core checks before show errors (#24493)
* Check core only if supervisor or observer is unresponsive

* Improve core check

* Revert test code

* Remove unused prop

* Combine network info with core check

* Combine ping and network info

* Add 30 sec timeout before show errors

* Update landing-page/src/ha-landing-page.ts

* Assume supervisor update on failed ping

* Fix typo
2025-03-06 11:33:33 +01:00
Petar Petrov
cdfe4b53bf Ignore excessive keydown events in charts (#24523)
* Ignore excessive keydown events in charts

* lint
2025-03-06 11:30:17 +01:00
renovate[bot]
75edc5132b Update dependency prettier to v3.5.3 (#24521) 2025-03-06 07:37:43 +01:00
Petar Petrov
c79164992b Fix height of chart legend (#24519) 2025-03-05 14:05:01 +01:00
Bram Kragten
68960ba03d Bumped version to 20250305.0 2025-03-05 11:08:52 +01:00
Paul Bottein
c3a60a9c3f Remove touch action none for toggle feature (#24514) 2025-03-05 11:06:28 +01:00
karwosts
4783720aaa No integer validation on ha-form-float (#24501) 2025-03-05 11:06:27 +01:00
Petar Petrov
d55b806ce5 Set chart axis pointer line to --info-color (#24494) 2025-03-05 11:06:26 +01:00
Petar Petrov
e2ff8ce302 Tweak legend expand/collapse button (#24484)
* Tweak legend expand/collapse button

* Revert "Tweak legend expand/collapse button"

This reverts commit 5eafdad781.

* update UX
2025-03-05 11:06:25 +01:00
karwosts
b26bc1dcf0 Remember hidden energy devices from storage (#24470)
* Remember hidden devices from storage

* remove accidental

* typing fix
2025-03-05 11:06:24 +01:00
Paul Bottein
76b03d3a40 Correctly parse number state for numeric input card feature (#24453) 2025-03-05 11:06:23 +01:00
Petar Petrov
c581d6d028 Set chart axis pointer line to --info-color (#24494) 2025-03-05 11:04:56 +01:00
karwosts
d899711a48 Remember hidden energy devices from storage (#24470)
* Remember hidden devices from storage

* remove accidental

* typing fix
2025-03-05 11:38:13 +02:00
Paul Bottein
b7be74e722 Remove touch action none for toggle feature (#24514) 2025-03-05 10:25:00 +01:00
karwosts
e53961d395 No integer validation on ha-form-float (#24501) 2025-03-05 09:20:18 +01:00
Paulus Schoutsen
03b08fefb7 Support continue conversation in Assist dialog (#24511) 2025-03-05 09:11:29 +02:00
Jan-Philipp Benecke
79374f6052 Show script description in the more info dialog (#24507)
* Show script description in the more info dialog

* Use markdown
2025-03-05 09:07:47 +02:00
Stefan Agner
ba19849182 Avoid URL and email fields getting masked in add-on config view (#24509)
* Avoid URL and email fields getting masked in add-on config view

The backend will set "format" for add-on config options of type
"password", "url" and "email", to exactly these three values. Only
"password" fields should be masked though.

* lint

---------

Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
2025-03-05 06:56:34 +00:00
renovate[bot]
48338e0886 Update Yarn to v4.7.0 (#24503)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-04 18:43:13 +01:00
renovate[bot]
3b87fc84a9 Update dependency core-js to v3.41.0 (#24504)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-04 18:42:43 +01:00
J. Nick Koston
61effc3f70 Add panel to show Bluetooth connection overview (#24463)
* Add panel to show Bluetooth connection overview

* tweak

* migrate to ha-button
2025-03-04 18:29:15 +01:00
Petar Petrov
e5b460c259 Tweak legend expand/collapse button (#24484)
* Tweak legend expand/collapse button

* Revert "Tweak legend expand/collapse button"

This reverts commit 5eafdad781.

* update UX
2025-03-04 14:51:54 +01:00
Joakim Sørensen
7a56731f56 Remove brackets (#24497) 2025-03-04 15:20:16 +02:00
Joakim Sørensen
bfe20d3760 Include name and version in already connected dialog if present (#24492)
* Include name and version in already connected dialog if present

* lint

* Apply suggestions from code review

* move
2025-03-04 11:39:29 +02:00
Paul Bottein
5a37087231 Use fire-event for copy, cut and duplicate (#24486)
* Add event for duplicate

* Update new events in card option and card edit mode

* Add copy event
2025-03-04 11:14:22 +02:00
renovate[bot]
dbe5bffe22 Update dependency babel-loader to v10 (#24472)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-04 09:05:30 +02:00
renovate[bot]
62da09d045 Update dependency typescript to v5.8.2 (#24487) 2025-03-03 18:11:07 +01:00
Wendelin
75d7676b36 No capitalization for quick bar commands (#24481)
Remove forces capitalization for quick bar commands
2025-03-03 12:53:36 +01:00
renovate[bot]
0bea89db91 Update vaadinWebComponents monorepo to v24.6.6 (#24482)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-03 12:53:17 +01:00
Logan Rosen
7ad759dd95 Fix inconsistent color picker height across browsers (#24476)
Closes #24475
2025-03-03 11:17:46 +01:00
Bram Kragten
5377c9e75d Update currency for Zambia (#24480) 2025-03-03 11:00:50 +01:00
dependabot[bot]
bf206aa12b Bump home-assistant/wheels from 2024.11.0 to 2025.02.0 (#24478) 2025-03-03 08:16:03 +01:00
dependabot[bot]
73669e27f4 Bump actions/cache from 4.2.1 to 4.2.2 (#24479) 2025-03-03 08:13:18 +01:00
karwosts
1b5f4d3432 Add model_id filter to device selector (#23746)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2025-03-02 21:37:22 +01:00
renovate[bot]
49379b49d0 Update dependency terser-webpack-plugin to v5.3.12 (#24468)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-02 14:36:26 +01:00
renovate[bot]
2827421c9f Update dependency @webcomponents/scoped-custom-element-registry to v0.0.10 (#24465)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-02 09:39:12 +01:00
renovate[bot]
1a5a183410 Update dependency eslint-config-prettier to v10.0.2 (#24462)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-01 20:04:57 +01:00
renovate[bot]
88a1de9aaf Update dependency @codemirror/search to v6.5.10 (#24459)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-01 12:33:54 +01:00
renovate[bot]
4ad64ce2c8 Update dependency @bundle-stats/plugin-webpack-filter to v4.18.3 (#24458)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-01 12:10:05 +02:00
renovate[bot]
3f1ca32d13 Update dependency element-internals-polyfill to v3.0.1 (#24457)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-28 23:24:20 +01:00
renovate[bot]
a6f7ee6b28 Update rspack monorepo to v1.2.6 (#24448)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-28 20:17:13 +01:00
Paul Bottein
0294198fba Correctly parse number state for numeric input card feature (#24453) 2025-02-28 16:46:53 +01:00
Norbert Rittel
ed6659ad8f More info panel: Replace "Dismiss dialog" tooltip with "Close info" (#24449)
* More info panel: Replace "Dismiss dialog" tooltip with "Close info"

Dismiss should only be used for closing dialogs like notifications that cannot be reopened.

Therefore the "Dismiss dialog" tooltip for the More info dialog is misleading, especially in translations that might emphasize the destructive meaning of "dismiss".

Matching the "Back to info" tooltip shown to return to the initial view from the entity settings this is changed to "Close info".

* use common close

---------

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2025-02-28 15:06:03 +00:00
Paul Bottein
f1d04e5178 Add support for toggle card feature for automation domain (#24452) 2025-02-28 15:01:33 +00:00
Paul Bottein
807e87fce0 Use card text align variable for header text alignment (#24451)
Use card text align variable for header text aligment
2025-02-28 15:52:40 +01:00
Bram Kragten
cafab61727 Align common dialog translations (#24450) 2025-02-28 15:51:06 +01:00
karwosts
88e6906b6b More height fixes in devtools/statistics (#24438)
* More height fixes in devtools/statistics

* fix selection bar
2025-02-28 14:07:00 +01:00
Paul Bottein
ebc1259e39 Fix control number buttons height (#24441) 2025-02-28 14:05:14 +01:00
J. Nick Koston
c1f2e6d82b Small fixes for Bluetooth device info (#24436)
* Add missing service uuids to Bluetooth device info

Service UUIDs are different from Service data because
they do not have any data attached to them. I only
discovered that they were missing in the UI because
of helping a user troubleshoot of device, and we could
not find the Service UUID

* fix mapping

* fix mapping

* fix mapping

* tweaks
2025-02-28 10:03:15 +02:00
karwosts
ef964fd23e Change label on BT advertisement timestamp (#24439) 2025-02-28 08:04:02 +01:00
renovate[bot]
13105c2d6f Update dependency typescript-eslint to v8.25.0 (#24434)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-27 20:43:33 +01:00
renovate[bot]
5b9262487d Update vitest monorepo to v3.0.7 (#24433)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-27 20:43:04 +01:00
renovate[bot]
4ec6e324f8 Update dependency element-internals-polyfill to v3 (#24364)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-27 20:42:16 +01:00
Paul Bottein
20f385e053 Use border color for focus state of button and select in dashboard (#24429) 2025-02-27 20:36:41 +01:00
Paul Bottein
dd441f882b Allow the card features buttons to be smaller if needed (#24431) 2025-02-27 19:30:15 +01:00
Bram Kragten
3a1d371b0b Don't show no config flow message when source = system (#24425)
dont show no config flow message when source = system
2025-02-27 16:15:42 +01:00
Paul Bottein
8848911b34 Use switch and add support for light, fan and valve (#24426)
* Use switch and add support for light and fan

* Add icon per domains
2025-02-27 15:35:12 +01:00
Paul Bottein
51193cf441 Reverse the order of all modes features and toggle (#24420)
Reverse the order of all modes features
2025-02-27 13:08:42 +01:00
Paul Bottein
a5b7f2466e Fix select box radio click on firefox (#24422) 2025-02-27 13:08:16 +01:00
Paul Bottein
3d9bde548d Don't show features settings if none is compatible (#24419) 2025-02-27 13:07:50 +01:00
Wendelin
dfa98a4ba8 Translate state in entity table (#24417) 2025-02-27 12:20:38 +01:00
Paul Bottein
20fe5b1b71 Fix header hidden when no badges (#24423) 2025-02-27 12:09:12 +01:00
Paul Bottein
9250ecb16f Add features position description in tile card editor (#24421) 2025-02-27 12:08:36 +01:00
Jan-Philipp Benecke
e21d1399ea Swap button positions of toggle feature (#24416) 2025-02-27 10:46:29 +01:00
Jan-Philipp Benecke
5dded38ccc Swap default positions of increment and decrement in counter actions feature (#24418) 2025-02-27 10:46:01 +01:00
renovate[bot]
54cc8f025c Update dependency barcode-detector to v3.0.1 (#24407)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-27 07:54:00 +02:00
karwosts
0d215e65cd Remove duplicate translation key (#24414)
Update en.json
2025-02-27 07:46:54 +02:00
Paulus Schoutsen
f9824a3b3b Remove unused domain in history check (#24406) 2025-02-26 17:59:02 +01:00
Wendelin
197c9219bd Fix energy gauge tooltip (#24404) 2025-02-26 15:27:09 +01:00
434 changed files with 11857 additions and 6580 deletions

View File

@@ -26,7 +26,7 @@ jobs:
ref: dev
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn
@@ -62,7 +62,7 @@ jobs:
ref: master
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn

View File

@@ -26,7 +26,7 @@ jobs:
- name: Check out files from GitHub
uses: actions/checkout@v4.2.2
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn
@@ -37,7 +37,7 @@ jobs:
- name: Build resources
run: ./node_modules/.bin/gulp gen-icons-json build-translations build-locale-data gather-gallery-pages
- name: Setup lint cache
uses: actions/cache@v4.2.1
uses: actions/cache@v4.2.3
with:
path: |
node_modules/.cache/prettier
@@ -60,7 +60,7 @@ jobs:
- name: Check out files from GitHub
uses: actions/checkout@v4.2.2
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn
@@ -78,7 +78,7 @@ jobs:
- name: Check out files from GitHub
uses: actions/checkout@v4.2.2
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn
@@ -89,7 +89,7 @@ jobs:
env:
IS_TEST: "true"
- name: Upload bundle stats
uses: actions/upload-artifact@v4.6.1
uses: actions/upload-artifact@v4.6.2
with:
name: frontend-bundle-stats
path: build/stats/*.json
@@ -102,7 +102,7 @@ jobs:
- name: Check out files from GitHub
uses: actions/checkout@v4.2.2
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn
@@ -113,7 +113,7 @@ jobs:
env:
IS_TEST: "true"
- name: Upload bundle stats
uses: actions/upload-artifact@v4.6.1
uses: actions/upload-artifact@v4.6.2
with:
name: supervisor-bundle-stats
path: build/stats/*.json

View File

@@ -27,7 +27,7 @@ jobs:
ref: dev
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn
@@ -63,7 +63,7 @@ jobs:
ref: master
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn

View File

@@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v4.2.2
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn

View File

@@ -24,7 +24,7 @@ jobs:
uses: actions/checkout@v4.2.2
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn

View File

@@ -28,7 +28,7 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn
@@ -57,14 +57,14 @@ jobs:
run: tar -czvf translations.tar.gz translations
- name: Upload build artifacts
uses: actions/upload-artifact@v4.6.1
uses: actions/upload-artifact@v4.6.2
with:
name: wheels
path: dist/home_assistant_frontend*.whl
if-no-files-found: error
- name: Upload translations
uses: actions/upload-artifact@v4.6.1
uses: actions/upload-artifact@v4.6.2
with:
name: translations
path: translations.tar.gz

View File

@@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Send bundle stats and build information to RelativeCI
uses: relative-ci/agent-action@v2.1.14
uses: relative-ci/agent-action@v2.2.0
with:
key: ${{ secrets[format('RELATIVE_CI_KEY_{0}_{1}', matrix.bundle, matrix.build)] }}
token: ${{ github.token }}

View File

@@ -34,7 +34,7 @@ jobs:
uses: home-assistant/actions/helpers/verify-version@master
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn
@@ -74,7 +74,7 @@ jobs:
echo "home-assistant-frontend==$version" > ./requirements.txt
- name: Build wheels
uses: home-assistant/wheels@2024.11.0
uses: home-assistant/wheels@2025.03.0
with:
abi: cp313
tag: musllinux_1_2
@@ -92,7 +92,7 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v4.2.2
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn
@@ -121,7 +121,7 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v4.2.2
- name: Setup Node
uses: actions/setup-node@v4.2.0
uses: actions/setup-node@v4.3.0
with:
node-version-file: ".nvmrc"
cache: yarn

File diff suppressed because one or more lines are too long

View File

@@ -6,4 +6,4 @@ enableGlobalCache: false
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-4.6.0.cjs
yarnPath: .yarn/releases/yarn-4.8.1.cjs

View File

@@ -18,7 +18,7 @@ module.exports.sourceMapURL = () => {
module.exports.ignorePackages = () => [];
// Files from NPM packages that we should replace with empty file
module.exports.emptyPackages = ({ latestBuild, isHassioBuild }) =>
module.exports.emptyPackages = ({ isHassioBuild }) =>
[
// Contains all color definitions for all material color sets.
// We don't use it
@@ -28,12 +28,6 @@ module.exports.emptyPackages = ({ latestBuild, isHassioBuild }) =>
require.resolve("@polymer/font-roboto/roboto.js"),
require.resolve("@vaadin/vaadin-material-styles/typography.js"),
require.resolve("@vaadin/vaadin-material-styles/font-icons.js"),
// Compatibility not needed for latest builds
latestBuild &&
// wrapped in require.resolve so it blows up if file no longer exists
require.resolve(
path.resolve(paths.polymer_dir, "src/resources/compatibility.ts")
),
// Icons in supervisor conflict with icons in HA so we don't load.
isHassioBuild &&
require.resolve(
@@ -55,7 +49,7 @@ module.exports.definedVars = ({ isProdBuild, latestBuild, defineOverlay }) => ({
__STATIC_PATH__: "/static/",
__HASS_URL__: `\`${
"HASS_URL" in process.env
? process.env["HASS_URL"]
? process.env.HASS_URL
: "${location.protocol}//${location.host}"
}\``,
"process.env.NODE_ENV": JSON.stringify(

View File

@@ -56,6 +56,7 @@ const getCommonTemplateVars = () => {
);
return {
modernRegex: compileRegex(browserRegexes.concat(haMacOSRegex)).toString(),
hassUrl: process.env.HASS_URL || "",
};
};

View File

@@ -59,6 +59,11 @@ function copyPolyfills(staticDir) {
npmPath("@webcomponents/webcomponentsjs/webcomponents-bundle.js.map"),
staticPath("polyfills/")
);
// Lit polyfill support
fs.copySync(
npmPath("lit/polyfill-support.js"),
path.join(staticPath("polyfills/"), "lit-polyfill-support.js")
);
// dialog-polyfill css
copyFileDir(

View File

@@ -40,20 +40,17 @@ class CustomJSON extends Transform {
this._reviver = reviver;
}
// eslint-disable-next-line @typescript-eslint/naming-convention
async _transform(file, _, callback) {
try {
let obj = JSON.parse(file.contents.toString(), this._reviver);
if (this._func) obj = this._func(obj, file.path);
for (const [outObj, dir] of Array.isArray(obj) ? obj : [[obj, ""]]) {
const outFile = file.clone({ contents: false });
outFile.contents = Buffer.from(JSON.stringify(outObj));
outFile.dirname += `/${dir}`;
this.push(outFile);
}
callback(null);
} catch (err) {
callback(err);
let obj = JSON.parse(file.contents.toString(), this._reviver);
if (this._func) obj = this._func(obj, file.path);
for (const [outObj, dir] of Array.isArray(obj) ? obj : [[obj, ""]]) {
const outFile = file.clone({ contents: false });
outFile.contents = Buffer.from(JSON.stringify(outObj));
outFile.dirname += `/${dir}`;
this.push(outFile);
}
callback(null);
}
}
@@ -68,25 +65,19 @@ class MergeJSON extends Transform {
this._reviver = reviver;
}
// eslint-disable-next-line @typescript-eslint/naming-convention
async _transform(file, _, callback) {
try {
this._objects.push(JSON.parse(file.contents.toString(), this._reviver));
if (!this._outFile) this._outFile = file.clone({ contents: false });
callback(null);
} catch (err) {
callback(err);
}
this._objects.push(JSON.parse(file.contents.toString(), this._reviver));
if (!this._outFile) this._outFile = file.clone({ contents: false });
callback(null);
}
// eslint-disable-next-line @typescript-eslint/naming-convention
async _flush(callback) {
try {
const mergedObj = merge(this._startObj, ...this._objects);
this._outFile.contents = Buffer.from(JSON.stringify(mergedObj));
this._outFile.stem = this._stem;
callback(null, this._outFile);
} catch (err) {
callback(err);
}
const mergedObj = merge(this._startObj, ...this._objects);
this._outFile.contents = Buffer.from(JSON.stringify(mergedObj));
this._outFile.stem = this._stem;
callback(null, this._outFile);
}
}

View File

@@ -1,12 +1,17 @@
const { existsSync } = require("fs");
const path = require("path");
const rspack = require("@rspack/core");
// eslint-disable-next-line @typescript-eslint/naming-convention
const { RsdoctorRspackPlugin } = require("@rsdoctor/rspack-plugin");
// eslint-disable-next-line @typescript-eslint/naming-convention
const { StatsWriterPlugin } = require("webpack-stats-plugin");
const filterStats = require("@bundle-stats/plugin-webpack-filter").default;
const filterStats = require("@bundle-stats/plugin-webpack-filter");
// eslint-disable-next-line @typescript-eslint/naming-convention
const TerserPlugin = require("terser-webpack-plugin");
// eslint-disable-next-line @typescript-eslint/naming-convention
const { WebpackManifestPlugin } = require("rspack-manifest-plugin");
const log = require("fancy-log");
// eslint-disable-next-line @typescript-eslint/naming-convention
const WebpackBar = require("webpackbar/rspack");
const paths = require("./paths.cjs");
const bundle = require("./bundle.cjs");
@@ -155,9 +160,7 @@ const createRspackConfig = ({
},
}),
new rspack.NormalModuleReplacementPlugin(
new RegExp(
bundle.emptyPackages({ latestBuild, isHassioBuild }).join("|")
),
new RegExp(bundle.emptyPackages({ isHassioBuild }).join("|")),
path.resolve(paths.polymer_dir, "src/util/empty.js")
),
!isProdBuild && new LogStartCompilePlugin(),
@@ -192,6 +195,7 @@ const createRspackConfig = ({
"lit/directives/if-defined$": "lit/directives/if-defined.js",
"lit/directives/guard$": "lit/directives/guard.js",
"lit/directives/cache$": "lit/directives/cache.js",
"lit/directives/join$": "lit/directives/join.js",
"lit/directives/repeat$": "lit/directives/repeat.js",
"lit/directives/live$": "lit/directives/live.js",
"lit/directives/keyed$": "lit/directives/keyed.js",

View File

@@ -309,7 +309,7 @@ export class HcMain extends HassElement {
"../../../../src/panels/lovelace/strategies/get-strategy"
);
const config = await generateLovelaceDashboardStrategy(
rawConfig.strategy,
rawConfig,
this.hass!
);
this._handleNewLovelaceConfig(config);
@@ -351,10 +351,7 @@ export class HcMain extends HassElement {
"../../../../src/panels/lovelace/strategies/get-strategy"
);
this._handleNewLovelaceConfig(
await generateLovelaceDashboardStrategy(
DEFAULT_CONFIG.strategy,
this.hass!
)
await generateLovelaceDashboardStrategy(DEFAULT_CONFIG, this.hass!)
);
}

View File

@@ -5,7 +5,7 @@ import { until } from "lit/directives/until";
import { fireEvent } from "../../../src/common/dom/fire_event";
import "../../../src/components/ha-card";
import "../../../src/components/ha-button";
import "../../../src/components/ha-circular-progress";
import "../../../src/components/ha-spinner";
import type { LovelaceCardConfig } from "../../../src/data/lovelace/config/card";
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
import type {
@@ -44,9 +44,7 @@ export class HADemoCard extends LitElement implements LovelaceCard {
<div class="picker">
<div class="label">
${this._switching
? html`
<ha-circular-progress indeterminate></ha-circular-progress>
`
? html`<ha-spinner></ha-spinner>`
: until(
selectedDemoConfig.then(
(conf) => html`

View File

@@ -1,5 +1,3 @@
// Compat needs to be first import
import "../../src/resources/compatibility";
import { customElement } from "lit/decorators";
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
import { navigate } from "../../src/common/navigate";

View File

@@ -1,9 +1,10 @@
import type { validateConfig } from "../../../src/data/config";
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
export const mockConfig = (hass: MockHomeAssistant) => {
hass.mockWS("validate_config", () => ({
actions: { valid: true },
conditions: { valid: true },
triggers: { valid: true },
hass.mockWS<typeof validateConfig>("validate_config", () => ({
actions: { valid: true, error: null },
conditions: { valid: true, error: null },
triggers: { valid: true, error: null },
}));
};

View File

@@ -1,20 +1,26 @@
import type { getConfigEntries } from "../../../src/data/config_entries";
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
export const mockConfigEntries = (hass: MockHomeAssistant) => {
hass.mockWS("config_entries/get", () => ({
entry_id: "co2signal",
domain: "co2signal",
title: "Electricity Maps",
source: "user",
state: "loaded",
supports_options: false,
supports_remove_device: false,
supports_unload: true,
supports_reconfigure: true,
supported_subentry_types: {},
pref_disable_new_entities: false,
pref_disable_polling: false,
disabled_by: null,
reason: null,
}));
hass.mockWS<typeof getConfigEntries>("config_entries/get", () => [
{
entry_id: "mock-entry-co2signal",
domain: "co2signal",
title: "Electricity Maps",
source: "user",
state: "loaded",
supports_options: false,
supports_remove_device: false,
supports_unload: true,
supports_reconfigure: true,
supported_subentry_types: {},
pref_disable_new_entities: false,
pref_disable_polling: false,
disabled_by: null,
reason: null,
num_subentries: 0,
error_reason_translation_key: null,
error_reason_translation_placeholders: null,
},
]);
};

View File

@@ -1,63 +0,0 @@
import type { TemplateResult } from "lit";
import { html, css, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../../src/components/ha-bar";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-circular-progress";
import "@material/web/progress/circular-progress";
import type { HomeAssistant } from "../../../../src/types";
@customElement("demo-components-ha-circular-progress")
export class DemoHaCircularProgress extends LitElement {
@property({ attribute: false }) hass!: HomeAssistant;
protected render(): TemplateResult {
return html`<ha-card header="Basic circular progress">
<div class="card-content">
<ha-circular-progress indeterminate></ha-circular-progress></div
></ha-card>
<ha-card header="Different circular progress sizes">
<div class="card-content">
<ha-circular-progress
indeterminate
size="tiny"
></ha-circular-progress>
<ha-circular-progress
indeterminate
size="small"
></ha-circular-progress>
<ha-circular-progress
indeterminate
size="medium"
></ha-circular-progress>
<ha-circular-progress
indeterminate
size="large"
></ha-circular-progress></div
></ha-card>
<ha-card header="Circular progress with an aria-label">
<div class="card-content">
<ha-circular-progress
indeterminate
aria-label="Doing something..."
></ha-circular-progress>
<ha-circular-progress
indeterminate
.ariaLabel=${"Doing something..."}
></ha-circular-progress></div
></ha-card>`;
}
static styles = css`
ha-card {
max-width: 600px;
margin: 24px auto;
}
`;
}
declare global {
interface HTMLElementTagNameMap {
"demo-components-ha-circular-progress": DemoHaCircularProgress;
}
}

View File

@@ -1,4 +1,4 @@
import { mdiPacMan } from "@mdi/js";
import { mdiLightbulbOn, mdiPacMan } from "@mdi/js";
import type { TemplateResult } from "lit";
import { css, html, LitElement } from "lit";
import { customElement } from "lit/decorators";
@@ -125,6 +125,23 @@ const SAMPLES: {
`;
},
},
{
template(slot, leftChevron) {
return html`
<ha-expansion-panel
slot=${slot}
.leftChevron=${leftChevron}
header="Attr Header with actions"
>
<ha-svg-icon
slot="leading-icon"
.path=${mdiLightbulbOn}
></ha-svg-icon>
${SHORT_TEXT}
</ha-expansion-panel>
`;
},
},
];
@customElement("demo-components-ha-expansion-panel")

View File

@@ -1,4 +1,4 @@
---
title: Circular Progress
title: Spinner
subtitle: Can be used to indicate an ongoing task.
---

View File

@@ -0,0 +1,44 @@
import type { TemplateResult } from "lit";
import { html, css, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../../src/components/ha-bar";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-spinner";
import type { HomeAssistant } from "../../../../src/types";
@customElement("demo-components-ha-spinner")
export class DemoHaSpinner extends LitElement {
@property({ attribute: false }) hass!: HomeAssistant;
protected render(): TemplateResult {
return html`<ha-card header="Basic spinner">
<div class="card-content">
<ha-spinner></ha-spinner></div
></ha-card>
<ha-card header="Different spinner sizes">
<div class="card-content">
<ha-spinner size="tiny"></ha-spinner>
<ha-spinner size="small"></ha-spinner>
<ha-spinner size="medium"></ha-spinner>
<ha-spinner size="large"></ha-spinner></div
></ha-card>
<ha-card header="Spinner with an aria-label">
<div class="card-content">
<ha-spinner aria-label="Doing something..."></ha-spinner>
<ha-spinner .ariaLabel=${"Doing something..."}></ha-spinner></div
></ha-card>`;
}
static styles = css`
ha-card {
max-width: 600px;
margin: 24px auto;
}
`;
}
declare global {
interface HTMLElementTagNameMap {
"demo-components-ha-spinner": DemoHaSpinner;
}
}

View File

@@ -1,7 +1,7 @@
import type { CSSResultGroup, TemplateResult } from "lit";
import { css, html, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../../src/components/ha-circular-progress";
import "../../../../src/components/ha-spinner";
import type { HassioAddonDetails } from "../../../../src/data/hassio/addon";
import type { Supervisor } from "../../../../src/data/supervisor/supervisor";
import { haStyle } from "../../../../src/resources/styles";
@@ -21,7 +21,7 @@ class HassioAddonConfigDashboard extends LitElement {
protected render(): TemplateResult {
if (!this.addon) {
return html`<ha-circular-progress indeterminate></ha-circular-progress>`;
return html`<ha-spinner></ha-spinner>`;
}
const hasConfiguration =
(this.addon.options && Object.keys(this.addon.options).length) ||

View File

@@ -113,8 +113,9 @@ class HassioAddonConfig extends LitElement {
required: entry.required,
selector: {
text: {
type:
entry.format || MASKED_FIELDS.includes(entry.name)
type: entry.format
? entry.format
: MASKED_FIELDS.includes(entry.name)
? "password"
: "text",
},

View File

@@ -2,7 +2,7 @@ import "../../../../src/components/ha-card";
import type { CSSResultGroup, TemplateResult } from "lit";
import { css, html, LitElement } from "lit";
import "../../../../src/components/ha-alert";
import "../../../../src/components/ha-circular-progress";
import "../../../../src/components/ha-spinner";
import "../../../../src/components/ha-markdown";
import { customElement, property, state } from "lit/decorators";
import type { HassioAddonDetails } from "../../../../src/data/hassio/addon";
@@ -33,7 +33,7 @@ class HassioAddonDocumentationDashboard extends LitElement {
protected render(): TemplateResult {
if (!this.addon) {
return html`<ha-circular-progress indeterminate></ha-circular-progress>`;
return html`<ha-spinner></ha-spinner>`;
}
return html`
<div class="content">

View File

@@ -11,7 +11,6 @@ import memoizeOne from "memoize-one";
import { fireEvent } from "../../../src/common/dom/fire_event";
import { navigate } from "../../../src/common/navigate";
import { extractSearchParam } from "../../../src/common/url/search-params";
import "../../../src/components/ha-circular-progress";
import type { HassioAddonDetails } from "../../../src/data/hassio/addon";
import {
fetchAddonInfo,

View File

@@ -1,7 +1,7 @@
import type { CSSResultGroup, TemplateResult } from "lit";
import { css, html, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../../src/components/ha-circular-progress";
import "../../../../src/components/ha-spinner";
import type { HassioAddonDetails } from "../../../../src/data/hassio/addon";
import type { Supervisor } from "../../../../src/data/supervisor/supervisor";
import { haStyle } from "../../../../src/resources/styles";
@@ -23,7 +23,7 @@ class HassioAddonInfoDashboard extends LitElement {
protected render(): TemplateResult {
if (!this.addon) {
return html`<ha-circular-progress indeterminate></ha-circular-progress>`;
return html`<ha-spinner></ha-spinner>`;
}
return html`

View File

@@ -1331,6 +1331,12 @@ class HassioAddonInfo extends LitElement {
ha-alert mwc-button {
--mdc-theme-primary: var(--primary-text-color);
}
:host > ha-alert {
display: block;
margin-bottom: 16px;
}
a {
text-decoration: none;
}

View File

@@ -6,7 +6,7 @@ import {
type TemplateResult,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../../src/components/ha-circular-progress";
import "../../../../src/components/ha-spinner";
import type { HassioAddonDetails } from "../../../../src/data/hassio/addon";
import type { Supervisor } from "../../../../src/data/supervisor/supervisor";
import { haStyle } from "../../../../src/resources/styles";
@@ -28,9 +28,7 @@ class HassioAddonLogDashboard extends LitElement {
protected render(): TemplateResult {
if (!this.addon) {
return html`
<ha-circular-progress indeterminate></ha-circular-progress>
`;
return html` <ha-spinner></ha-spinner> `;
}
return html`
<div class="search">

View File

@@ -3,7 +3,6 @@ import type { TemplateResult } from "lit";
import { html, LitElement } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../../src/common/dom/fire_event";
import "../../../src/components/ha-circular-progress";
import "../../../src/components/ha-file-upload";
import type { HassioBackup } from "../../../src/data/hassio/backup";
import { uploadBackup } from "../../../src/data/hassio/backup";

View File

@@ -12,6 +12,7 @@ import "../../../../src/components/ha-md-dialog";
import "../../../../src/components/ha-dialog-header";
import "../../../../src/components/buttons/ha-progress-button";
import "../../../../src/components/ha-alert";
import "../../../../src/components/ha-spinner";
import "../../../../src/components/ha-button";
import "../../../../src/components/ha-button-menu";
import "../../../../src/components/ha-header-bar";
@@ -138,7 +139,7 @@ class HassioBackupDialog
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
: this._restoringBackup
? html`<div class="loading">
<ha-circular-progress indeterminate></ha-circular-progress>
<ha-spinner></ha-spinner>
</div>`
: html`
<supervisor-backup-content
@@ -310,10 +311,6 @@ class HassioBackupDialog
haStyle,
haStyleDialog,
css`
ha-circular-progress {
display: block;
text-align: center;
}
ha-header-bar {
--mdc-theme-on-primary: var(--primary-text-color);
--mdc-theme-primary: var(--mdc-theme-surface);

View File

@@ -5,6 +5,7 @@ import { customElement, property, query, state } from "lit/decorators";
import { fireEvent } from "../../../../src/common/dom/fire_event";
import "../../../../src/components/buttons/ha-progress-button";
import "../../../../src/components/ha-alert";
import "../../../../src/components/ha-spinner";
import { createCloseHeading } from "../../../../src/components/ha-dialog";
import {
createHassioFullBackup,
@@ -58,7 +59,7 @@ class HassioCreateBackupDialog extends LitElement {
)}
>
${this._creatingBackup
? html`<ha-circular-progress indeterminate></ha-circular-progress>`
? html`<ha-spinner></ha-spinner>`
: html`<supervisor-backup-content
.hass=${this.hass}
.supervisor=${this._dialogParams.supervisor}
@@ -142,10 +143,6 @@ class HassioCreateBackupDialog extends LitElement {
:host {
direction: var(--direction);
}
ha-circular-progress {
display: block;
text-align: center;
}
`,
];
}

View File

@@ -4,7 +4,7 @@ import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../../../src/common/dom/fire_event";
import "../../../../src/components/ha-circular-progress";
import "../../../../src/components/ha-spinner";
import "../../../../src/components/ha-select";
import "../../../../src/components/ha-dialog";
import {
@@ -69,12 +69,7 @@ class HassioDatadiskDialog extends LitElement {
?hideActions=${this.moving}
>
${this.moving
? html` <ha-circular-progress
aria-label="Moving"
size="large"
indeterminate
>
</ha-circular-progress>
? html`<ha-spinner aria-label="Moving" size="large"></ha-spinner>
<p class="progress-text">
${this.dialogParams.supervisor.localize(
"dialog.datadisk_move.moving_desc"
@@ -166,7 +161,7 @@ class HassioDatadiskDialog extends LitElement {
ha-select {
width: 100%;
}
ha-circular-progress {
ha-spinner {
display: block;
margin: 32px;
text-align: center;

View File

@@ -10,7 +10,7 @@ import { customElement, property, state } from "lit/decorators";
import { cache } from "lit/directives/cache";
import { fireEvent } from "../../../../src/common/dom/fire_event";
import "../../../../src/components/ha-alert";
import "../../../../src/components/ha-circular-progress";
import "../../../../src/components/ha-spinner";
import "../../../../src/components/ha-dialog";
import "../../../../src/components/ha-expansion-panel";
import "../../../../src/components/ha-formfield";
@@ -161,12 +161,8 @@ export class DialogHassioNetwork
.disabled=${this._scanning}
>
${this._scanning
? html`<ha-circular-progress
aria-label="Scanning"
indeterminate
size="small"
>
</ha-circular-progress>`
? html`<ha-spinner aria-label="Scanning" size="small">
</ha-spinner>`
: this.supervisor.localize("dialog.network.scan_ap")}
</mwc-button>
${this._accessPoints &&
@@ -282,8 +278,7 @@ export class DialogHassioNetwork
</mwc-button>
<mwc-button @click=${this._updateNetwork} .disabled=${!this._dirty}>
${this._processing
? html`<ha-circular-progress indeterminate size="small">
</ha-circular-progress>`
? html`<ha-spinner size="small"> </ha-spinner>`
: this.supervisor.localize("common.save")}
</mwc-button>
</div>`;

View File

@@ -8,7 +8,7 @@ import { fireEvent } from "../../../../src/common/dom/fire_event";
import { caseInsensitiveStringCompare } from "../../../../src/common/string/compare";
import "../../../../src/components/ha-alert";
import "../../../../src/components/ha-tooltip";
import "../../../../src/components/ha-circular-progress";
import "../../../../src/components/ha-spinner";
import { createCloseHeading } from "../../../../src/components/ha-dialog";
import "../../../../src/components/ha-icon-button";
import type {
@@ -161,10 +161,7 @@ class HassioRepositoriesDialog extends LitElement {
></ha-textfield>
<mwc-button @click=${this._addRepository}>
${this._processing
? html`<ha-circular-progress
indeterminate
size="small"
></ha-circular-progress>`
? html`<ha-spinner size="small"></ha-spinner>`
: this._dialogParams!.supervisor.localize(
"dialog.repositories.add"
)}
@@ -202,7 +199,7 @@ class HassioRepositoriesDialog extends LitElement {
margin-inline-start: 8px;
margin-inline-end: initial;
}
ha-circular-progress {
ha-spinner {
display: block;
margin: 32px;
text-align: center;

View File

@@ -1,5 +1,3 @@
// Compat needs to be first import
import "../../src/resources/compatibility";
import "./hassio-main";
import("../../src/resources/ha-style");

View File

@@ -15,6 +15,7 @@ import "../../../src/components/buttons/ha-progress-button";
import "../../../src/components/ha-alert";
import "../../../src/components/ha-button-menu";
import "../../../src/components/ha-card";
import "../../../src/components/ha-spinner";
import "../../../src/components/ha-checkbox";
import "../../../src/components/ha-faded";
import "../../../src/components/ha-icon-button";
@@ -192,12 +193,10 @@ class UpdateAvailableCard extends LitElement {
`
: nothing}
`
: html`<ha-circular-progress
: html`<ha-spinner
aria-label="Updating"
size="large"
indeterminate
>
</ha-circular-progress>
></ha-spinner>
<p class="progress-text">
${this.supervisor.localize("update_available.updating", {
name: this._name,
@@ -465,7 +464,7 @@ class UpdateAvailableCard extends LitElement {
justify-content: space-between;
}
ha-circular-progress {
ha-spinner {
display: block;
margin: 32px;
text-align: center;

View File

@@ -22,6 +22,8 @@ import {
import { fireEvent } from "../../../src/common/dom/fire_event";
import { fileDownload } from "../../../src/util/file_download";
import { getSupervisorLogs, getSupervisorLogsFollow } from "../data/supervisor";
import { waitForSeconds } from "../../../src/common/util/wait";
import { ASSUME_CORE_START_SECONDS } from "../ha-landing-page";
const ERROR_CHECK = /^[\d\s-:]+(ERROR|CRITICAL)(.*)/gm;
declare global {
@@ -216,7 +218,7 @@ class LandingPageLogs extends LitElement {
// eslint-disable-next-line no-console
console.error(err);
// fallback to observerlogs if there is a problem with supervisor
// fallback to observer logs if there is a problem with supervisor
this._loadObserverLogs();
}
}
@@ -251,6 +253,9 @@ class LandingPageLogs extends LitElement {
this._scheduleObserverLogs();
} catch (err) {
// wait because there is a moment where landingpage is down and core is not up yet
await waitForSeconds(ASSUME_CORE_START_SECONDS);
// eslint-disable-next-line no-console
console.error(err);
this._error = true;

View File

@@ -1,13 +1,7 @@
import "@material/mwc-linear-progress/mwc-linear-progress";
import {
type CSSResultGroup,
LitElement,
type PropertyValues,
css,
html,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { type CSSResultGroup, LitElement, css, html, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import type {
LandingPageKeys,
LocalizeFunc,
@@ -16,34 +10,24 @@ import "../../../src/components/ha-button";
import "../../../src/components/ha-alert";
import {
ALTERNATIVE_DNS_SERVERS,
getSupervisorNetworkInfo,
pingSupervisor,
setSupervisorNetworkDns,
type NetworkInfo,
} from "../data/supervisor";
import { fireEvent } from "../../../src/common/dom/fire_event";
import { showAlertDialog } from "../../../src/dialogs/generic/show-dialog-box";
const SCHEDULE_FETCH_NETWORK_INFO_SECONDS = 5;
import type { NetworkInterface } from "../../../src/data/hassio/network";
import { fireEvent } from "../../../src/common/dom/fire_event";
@customElement("landing-page-network")
class LandingPageNetwork extends LitElement {
@property({ attribute: false })
public localize!: LocalizeFunc<LandingPageKeys>;
@state() private _networkIssue = false;
@property({ attribute: false }) public networkInfo?: NetworkInfo;
@state() private _getNetworkInfoError = false;
@state() private _dnsPrimaryInterfaceNameservers?: string;
@state() private _dnsPrimaryInterface?: string;
@property({ type: Boolean }) public error = false;
protected render() {
if (!this._networkIssue && !this._getNetworkInfoError) {
return nothing;
}
if (this._getNetworkInfoError) {
if (this.error) {
return html`
<ha-alert alert-type="error">
<p>${this.localize("network_issue.error_get_network_info")}</p>
@@ -51,6 +35,16 @@ class LandingPageNetwork extends LitElement {
`;
}
let dnsPrimaryInterfaceNameservers: string | undefined;
const primaryInterface = this._getPrimaryInterface(
this.networkInfo?.interfaces
);
if (primaryInterface) {
dnsPrimaryInterfaceNameservers =
this._getPrimaryNameservers(primaryInterface);
}
return html`
<ha-alert
alert-type="warning"
@@ -58,11 +52,11 @@ class LandingPageNetwork extends LitElement {
>
<p>
${this.localize("network_issue.description", {
dns: this._dnsPrimaryInterfaceNameservers || "?",
dns: dnsPrimaryInterfaceNameservers || "?",
})}
</p>
<p>${this.localize("network_issue.resolve_different")}</p>
${!this._dnsPrimaryInterfaceNameservers
${!dnsPrimaryInterfaceNameservers
? html`
<p>
<b>${this.localize("network_issue.no_primary_interface")} </b>
@@ -74,7 +68,7 @@ class LandingPageNetwork extends LitElement {
({ translationKey }, key) =>
html`<ha-button
.index=${key}
.disabled=${!this._dnsPrimaryInterfaceNameservers}
.disabled=${!dnsPrimaryInterfaceNameservers}
@click=${this._setDns}
>${this.localize(translationKey)}</ha-button
>`
@@ -84,97 +78,40 @@ class LandingPageNetwork extends LitElement {
`;
}
protected firstUpdated(_changedProperties: PropertyValues): void {
super.firstUpdated(_changedProperties);
this._pingSupervisor();
}
private _getPrimaryInterface = memoizeOne((interfaces?: NetworkInterface[]) =>
interfaces?.find((intf) => intf.primary && intf.enabled)
);
private _schedulePingSupervisor() {
setTimeout(
() => this._pingSupervisor(),
SCHEDULE_FETCH_NETWORK_INFO_SECONDS * 1000
);
}
private async _pingSupervisor() {
try {
const response = await pingSupervisor();
if (!response.ok) {
throw new Error("Failed to ping supervisor, assume update in progress");
}
this._fetchSupervisorInfo();
} catch (err) {
// eslint-disable-next-line no-console
console.error(err);
this._schedulePingSupervisor();
}
}
private _scheduleFetchSupervisorInfo() {
setTimeout(
() => this._fetchSupervisorInfo(),
SCHEDULE_FETCH_NETWORK_INFO_SECONDS * 1000
);
}
private async _fetchSupervisorInfo() {
let data;
try {
const response = await getSupervisorNetworkInfo();
if (!response.ok) {
throw new Error("Failed to fetch network info");
}
({ data } = await response.json());
} catch (err) {
// eslint-disable-next-line no-console
console.error(err);
this._getNetworkInfoError = true;
this._dnsPrimaryInterfaceNameservers = undefined;
this._dnsPrimaryInterface = undefined;
return;
}
this._getNetworkInfoError = false;
const primaryInterface = data.interfaces.find(
(intf) => intf.primary && intf.enabled
);
if (primaryInterface) {
this._dnsPrimaryInterfaceNameservers = [
private _getPrimaryNameservers = memoizeOne(
(primaryInterface: NetworkInterface) =>
[
...(primaryInterface.ipv4?.nameservers || []),
...(primaryInterface.ipv6?.nameservers || []),
].join(", ");
this._dnsPrimaryInterface = primaryInterface.interface;
} else {
this._dnsPrimaryInterfaceNameservers = undefined;
this._dnsPrimaryInterface = undefined;
}
if (!data.host_internet) {
this._networkIssue = true;
} else {
this._networkIssue = false;
}
fireEvent(this, "value-changed", {
value: this._networkIssue,
});
this._scheduleFetchSupervisorInfo();
}
].join(", ")
);
private async _setDns(ev) {
const primaryInterface = this._getPrimaryInterface(
this.networkInfo?.interfaces
);
const index = ev.target?.index;
try {
const dnsPrimaryInterface = primaryInterface?.interface;
if (!dnsPrimaryInterface) {
throw new Error("No primary interface found");
}
const response = await setSupervisorNetworkDns(
index,
this._dnsPrimaryInterface!
dnsPrimaryInterface
);
if (!response.ok) {
throw new Error("Failed to set DNS");
}
this._networkIssue = false;
// notify landing page to trigger a network info reload
fireEvent(this, "dns-set");
} catch (err: any) {
// eslint-disable-next-line no-console
console.error(err);
@@ -205,4 +142,7 @@ declare global {
interface HTMLElementTagNameMap {
"landing-page-network": LandingPageNetwork;
}
interface HASSDomEvents {
"dns-set": undefined;
}
}

View File

@@ -1,4 +1,17 @@
import type { LandingPageKeys } from "../../../src/common/translations/localize";
import type { HassioResponse } from "../../../src/data/hassio/common";
import type {
DockerNetwork,
NetworkInterface,
} from "../../../src/data/hassio/network";
import { handleFetchPromise } from "../../../src/util/hass-call-api";
export interface NetworkInfo {
interfaces: NetworkInterface[];
docker: DockerNetwork;
host_internet: boolean;
supervisor_internet: boolean;
}
export const ALTERNATIVE_DNS_SERVERS: {
ipv4: string[];
@@ -37,8 +50,11 @@ export async function pingSupervisor() {
return fetch("/supervisor-api/supervisor/ping");
}
export async function getSupervisorNetworkInfo() {
return fetch("/supervisor-api/network/info");
export async function getSupervisorNetworkInfo(): Promise<NetworkInfo> {
const responseData = await handleFetchPromise<HassioResponse<NetworkInfo>>(
fetch("/supervisor-api/network/info")
);
return responseData?.data;
}
export const setSupervisorNetworkDns = async (

View File

@@ -10,36 +10,56 @@ import { extractSearchParam } from "../../src/common/url/search-params";
import { onBoardingStyles } from "../../src/onboarding/styles";
import { makeDialogManager } from "../../src/dialogs/make-dialog-manager";
import { LandingPageBaseElement } from "./landing-page-base-element";
import {
getSupervisorNetworkInfo,
pingSupervisor,
type NetworkInfo,
} from "./data/supervisor";
const SCHEDULE_CORE_CHECK_SECONDS = 5;
export const ASSUME_CORE_START_SECONDS = 60;
const SCHEDULE_CORE_CHECK_SECONDS = 1;
const SCHEDULE_FETCH_NETWORK_INFO_SECONDS = 5;
@customElement("ha-landing-page")
class HaLandingPage extends LandingPageBaseElement {
@property({ attribute: false }) public translationFragment = "landing-page";
@state() private _networkIssue = false;
@state() private _supervisorError = false;
@state() private _networkInfo?: NetworkInfo;
@state() private _coreStatusChecked = false;
@state() private _networkInfoError = false;
@state() private _coreCheckActive = false;
private _mobileApp =
extractSearchParam("redirect_uri") === "homeassistant://auth-callback";
render() {
const networkIssue = this._networkInfo && !this._networkInfo.host_internet;
return html`
<ha-card>
<div class="card-content">
<h1>${this.localize("header")}</h1>
${!this._networkIssue && !this._supervisorError
${!networkIssue && !this._supervisorError
? html`
<p>${this.localize("subheader")}</p>
<mwc-linear-progress indeterminate></mwc-linear-progress>
`
: nothing}
<landing-page-network
@value-changed=${this._networkInfoChanged}
.localize=${this.localize}
></landing-page-network>
${networkIssue || this._networkInfoError
? html`
<landing-page-network
.localize=${this.localize}
.networkInfo=${this._networkInfo}
.error=${this._networkInfoError}
@dns-set=${this._fetchSupervisorInfo}
></landing-page-network>
`
: nothing}
${this._supervisorError
? html`
<ha-alert
@@ -88,24 +108,66 @@ class HaLandingPage extends LandingPageBaseElement {
}
import("../../src/components/ha-language-picker");
this._scheduleCoreCheck();
this._fetchSupervisorInfo(true);
}
private _scheduleCoreCheck() {
private _scheduleFetchSupervisorInfo() {
setTimeout(
() => this._checkCoreAvailability(),
SCHEDULE_CORE_CHECK_SECONDS * 1000
() => this._fetchSupervisorInfo(true),
// on assumed core start check every second, otherwise every 5 seconds
(this._coreCheckActive
? SCHEDULE_CORE_CHECK_SECONDS
: SCHEDULE_FETCH_NETWORK_INFO_SECONDS) * 1000
);
}
private _scheduleTurnOffCoreCheck() {
setTimeout(() => {
this._coreCheckActive = false;
}, ASSUME_CORE_START_SECONDS * 1000);
}
private async _fetchSupervisorInfo(schedule = false) {
try {
const response = await pingSupervisor();
if (!response.ok) {
throw new Error("ping-failed");
}
this._networkInfo = await getSupervisorNetworkInfo();
this._networkInfoError = false;
this._coreStatusChecked = false;
} catch (err: any) {
if (!this._coreStatusChecked) {
// wait before show errors, because we assume that core is starting
this._coreCheckActive = true;
this._scheduleTurnOffCoreCheck();
}
await this._checkCoreAvailability();
// assume supervisor update if ping fails -> don't show an error
if (!this._coreCheckActive && err.message !== "ping-failed") {
// eslint-disable-next-line no-console
console.error(err);
this._networkInfoError = true;
}
}
if (schedule) {
this._scheduleFetchSupervisorInfo();
}
}
private async _checkCoreAvailability() {
try {
const response = await fetch("/manifest.json");
if (response.ok) {
location.reload();
} else {
throw new Error("Failed to fetch manifest");
}
} finally {
this._scheduleCoreCheck();
} catch (_err) {
this._coreStatusChecked = true;
}
}
@@ -113,10 +175,6 @@ class HaLandingPage extends LandingPageBaseElement {
this._supervisorError = true;
}
private _networkInfoChanged(ev: CustomEvent) {
this._networkIssue = ev.detail.value;
}
private _languageChanged(ev: CustomEvent) {
const language = ev.detail.value;
if (language !== this.language && language) {

View File

@@ -26,25 +26,25 @@
"license": "Apache-2.0",
"type": "module",
"dependencies": {
"@babel/runtime": "7.26.9",
"@babel/runtime": "7.27.0",
"@braintree/sanitize-url": "7.1.1",
"@codemirror/autocomplete": "6.18.6",
"@codemirror/commands": "6.8.0",
"@codemirror/language": "6.10.8",
"@codemirror/legacy-modes": "6.4.3",
"@codemirror/search": "6.5.9",
"@codemirror/language": "6.11.0",
"@codemirror/legacy-modes": "6.5.0",
"@codemirror/search": "6.5.10",
"@codemirror/state": "6.5.2",
"@codemirror/view": "6.36.3",
"@codemirror/view": "6.36.5",
"@egjs/hammerjs": "2.0.17",
"@formatjs/intl-datetimeformat": "6.17.3",
"@formatjs/intl-displaynames": "6.8.10",
"@formatjs/intl-durationformat": "0.7.3",
"@formatjs/intl-getcanonicallocales": "2.5.4",
"@formatjs/intl-listformat": "7.7.10",
"@formatjs/intl-locale": "4.2.10",
"@formatjs/intl-numberformat": "8.15.3",
"@formatjs/intl-pluralrules": "5.4.3",
"@formatjs/intl-relativetimeformat": "11.4.10",
"@formatjs/intl-datetimeformat": "6.18.0",
"@formatjs/intl-displaynames": "6.8.11",
"@formatjs/intl-durationformat": "0.7.4",
"@formatjs/intl-getcanonicallocales": "2.5.5",
"@formatjs/intl-listformat": "7.7.11",
"@formatjs/intl-locale": "4.2.11",
"@formatjs/intl-numberformat": "8.15.4",
"@formatjs/intl-pluralrules": "5.4.4",
"@formatjs/intl-relativetimeformat": "11.4.11",
"@fullcalendar/core": "6.1.15",
"@fullcalendar/daygrid": "6.1.15",
"@fullcalendar/interaction": "6.1.15",
@@ -81,7 +81,7 @@
"@material/mwc-top-app-bar": "0.27.0",
"@material/mwc-top-app-bar-fixed": "0.27.0",
"@material/top-app-bar": "=14.0.0-canary.53b3cad2f.0",
"@material/web": "2.2.0",
"@material/web": "2.3.0",
"@mdi/js": "7.4.47",
"@mdi/svg": "7.4.47",
"@polymer/paper-item": "3.0.1",
@@ -89,19 +89,21 @@
"@polymer/paper-tabs": "3.1.0",
"@polymer/polymer": "3.5.2",
"@replit/codemirror-indentation-markers": "6.5.3",
"@shoelace-style/shoelace": "2.20.0",
"@shoelace-style/shoelace": "2.20.1",
"@thomasloven/round-slider": "0.6.0",
"@vaadin/combo-box": "24.6.5",
"@vaadin/vaadin-themable-mixin": "24.6.5",
"@tsparticles/engine": "3.8.1",
"@tsparticles/preset-links": "3.2.0",
"@vaadin/combo-box": "24.7.1",
"@vaadin/vaadin-themable-mixin": "24.7.1",
"@vibrant/color": "4.0.0",
"@vue/web-component-wrapper": "1.3.0",
"@webcomponents/scoped-custom-element-registry": "0.0.9",
"@webcomponents/scoped-custom-element-registry": "0.0.10",
"@webcomponents/webcomponentsjs": "2.8.0",
"app-datepicker": "5.1.1",
"barcode-detector": "3.0.0",
"barcode-detector": "3.0.1",
"color-name": "2.0.0",
"comlink": "4.4.2",
"core-js": "3.40.0",
"core-js": "3.41.0",
"cropperjs": "1.6.2",
"date-fns": "4.1.0",
"date-fns-tz": "3.2.0",
@@ -109,21 +111,21 @@
"deep-freeze": "0.0.1",
"dialog-polyfill": "0.5.6",
"echarts": "5.6.0",
"element-internals-polyfill": "1.3.13",
"element-internals-polyfill": "3.0.1",
"fuse.js": "7.1.0",
"google-timezones-json": "1.2.0",
"gulp-zopfli-green": "6.0.2",
"hls.js": "patch:hls.js@npm%3A1.5.7#~/.yarn/patches/hls.js-npm-1.5.7-f5bbd3d060.patch",
"home-assistant-js-websocket": "9.4.0",
"idb-keyval": "6.2.1",
"intl-messageformat": "10.7.15",
"intl-messageformat": "10.7.16",
"js-yaml": "4.1.0",
"leaflet": "1.9.4",
"leaflet-draw": "patch:leaflet-draw@npm%3A1.0.4#./.yarn/patches/leaflet-draw-npm-1.0.4-0ca0ebcf65.patch",
"leaflet.markercluster": "1.5.3",
"lit": "2.8.0",
"lit-html": "2.8.0",
"luxon": "3.5.0",
"luxon": "3.6.0",
"marked": "15.0.7",
"memoize-one": "6.0.0",
"node-vibrant": "4.0.3",
@@ -137,9 +139,7 @@
"stacktrace-js": "2.0.2",
"superstruct": "2.0.2",
"tinykeys": "3.0.0",
"tsparticles-engine": "2.12.0",
"tsparticles-preset-links": "2.12.0",
"ua-parser-js": "2.0.2",
"ua-parser-js": "2.0.3",
"vis-data": "7.1.9",
"vis-network": "9.1.9",
"vue": "2.7.16",
@@ -154,20 +154,20 @@
"xss": "1.0.15"
},
"devDependencies": {
"@babel/core": "7.26.9",
"@babel/helper-define-polyfill-provider": "0.6.3",
"@babel/core": "7.26.10",
"@babel/helper-define-polyfill-provider": "0.6.4",
"@babel/plugin-proposal-decorators": "7.25.9",
"@babel/plugin-transform-runtime": "7.26.9",
"@babel/plugin-transform-runtime": "7.26.10",
"@babel/preset-env": "7.26.9",
"@babel/preset-typescript": "7.26.0",
"@bundle-stats/plugin-webpack-filter": "4.18.2",
"@lokalise/node-api": "13.2.1",
"@octokit/auth-oauth-device": "7.1.3",
"@octokit/plugin-retry": "7.1.4",
"@babel/preset-typescript": "7.27.0",
"@bundle-stats/plugin-webpack-filter": "4.19.1",
"@lokalise/node-api": "14.2.0",
"@octokit/auth-oauth-device": "7.1.4",
"@octokit/plugin-retry": "7.2.0",
"@octokit/rest": "21.1.1",
"@rsdoctor/rspack-plugin": "0.4.13",
"@rspack/cli": "1.2.5",
"@rspack/core": "1.2.5",
"@rsdoctor/rspack-plugin": "1.0.1",
"@rspack/cli": "1.2.8",
"@rspack/core": "1.2.8",
"@types/babel__plugin-transform-runtime": "7.9.5",
"@types/chromecast-caf-receiver": "6.0.21",
"@types/chromecast-caf-sender": "1.0.11",
@@ -175,7 +175,7 @@
"@types/glob": "8.1.0",
"@types/html-minifier-terser": "7.0.2",
"@types/js-yaml": "4.0.9",
"@types/leaflet": "1.9.16",
"@types/leaflet": "1.9.17",
"@types/leaflet-draw": "1.0.11",
"@types/leaflet.markercluster": "1.5.5",
"@types/lodash.merge": "4.6.9",
@@ -186,20 +186,20 @@
"@types/tar": "6.1.13",
"@types/ua-parser-js": "0.7.39",
"@types/webspeechapi": "0.0.29",
"@vitest/coverage-v8": "3.0.6",
"babel-loader": "9.2.1",
"@vitest/coverage-v8": "3.0.9",
"babel-loader": "10.0.0",
"babel-plugin-template-html-minifier": "4.1.0",
"browserslist-useragent-regexp": "4.1.3",
"del": "8.0.0",
"eslint": "9.21.0",
"eslint": "9.23.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "10.0.1",
"eslint-config-prettier": "10.1.1",
"eslint-import-resolver-webpack": "0.13.10",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-lit": "1.15.0",
"eslint-plugin-lit": "2.0.0",
"eslint-plugin-lit-a11y": "4.1.4",
"eslint-plugin-unused-imports": "4.1.4",
"eslint-plugin-wc": "2.2.1",
"eslint-plugin-wc": "3.0.0",
"fancy-log": "2.0.0",
"fs-extra": "11.3.0",
"glob": "11.0.1",
@@ -211,23 +211,23 @@
"husky": "9.1.7",
"jsdom": "26.0.0",
"jszip": "3.10.1",
"lint-staged": "15.4.3",
"lint-staged": "15.5.0",
"lit-analyzer": "2.0.3",
"lodash.merge": "4.6.2",
"lodash.template": "4.5.0",
"map-stream": "0.0.7",
"pinst": "3.0.0",
"prettier": "3.5.2",
"prettier": "3.5.3",
"rspack-manifest-plugin": "5.0.3",
"serve": "14.2.4",
"sinon": "19.0.2",
"sinon": "20.0.0",
"tar": "7.4.3",
"terser-webpack-plugin": "5.3.11",
"terser-webpack-plugin": "5.3.14",
"ts-lit-plugin": "2.0.2",
"typescript": "5.7.3",
"typescript-eslint": "8.24.1",
"typescript": "5.8.2",
"typescript-eslint": "8.28.0",
"vite-tsconfig-paths": "5.1.4",
"vitest": "3.0.6",
"vitest": "3.0.9",
"webpack-stats-plugin": "1.1.3",
"webpackbar": "7.0.0",
"workbox-build": "patch:workbox-build@npm%3A7.1.1#~/.yarn/patches/workbox-build-npm-7.1.1-a854f3faae.patch"
@@ -244,5 +244,5 @@
"globals": "16.0.0",
"tslib": "2.8.1"
},
"packageManager": "yarn@4.6.0"
"packageManager": "yarn@4.8.1"
}

View File

@@ -1,11 +1,12 @@
[build-system]
requires = ["setuptools~=75.1"]
requires = ["setuptools~=77.0"]
build-backend = "setuptools.build_meta"
[project]
name = "home-assistant-frontend"
version = "20250228.0"
license = {text = "Apache-2.0"}
version = "20250326.0"
license = "Apache-2.0"
license-files = ["LICENSE*"]
description = "The Home Assistant frontend"
readme = "README.md"
authors = [
@@ -17,8 +18,6 @@ requires-python = ">=3.13.0"
"Homepage" = "https://github.com/home-assistant/frontend"
[tool.setuptools]
platforms = ["any"]
zip-safe = false
include-package-data = true
[tool.setuptools.packages.find]

View File

@@ -37,7 +37,7 @@
{
"description": "Group tsparticles engine and presets",
"groupName": "tsparticles",
"matchPackageNames": ["tsparticles-engine", "tsparticles-preset-{/,}**"]
"matchPackageNames": ["@tsparticles/engine", "@tsparticles/preset-{/,}**"]
},
{
"description": "Group date-fns with dependent timezone package",

View File

@@ -132,6 +132,15 @@ export const hs2rgb = (hs: [number, number]): [number, number, number] =>
export function theme2hex(themeColor: string): string {
if (themeColor.startsWith("#")) {
if (themeColor.length === 4 || themeColor.length === 5) {
const c = themeColor;
// Convert short-form hex (#abc) to 6 digit (#aabbcc). Ignore alpha channel.
return `#${c[1]}${c[1]}${c[2]}${c[2]}${c[3]}${c[3]}`;
}
if (themeColor.length === 9) {
// Ignore alpha channel.
return themeColor.substring(0, 7);
}
return themeColor;
}

View File

@@ -6,6 +6,10 @@ import {
differenceInMilliseconds,
differenceInMonths,
endOfMonth,
startOfDay,
endOfDay,
differenceInDays,
addDays,
} from "date-fns";
import { toZonedTime, fromZonedTime } from "date-fns-tz";
import type { HassConfig } from "home-assistant-js-websocket";
@@ -100,6 +104,32 @@ export const shiftDateRange = (
locale,
config
);
} else if (
calcDateProperty(
startDate,
(date) => startOfDay(date).getMilliseconds() === date.getMilliseconds(),
locale,
config
) &&
calcDateProperty(
endDate,
(date) => endOfDay(date).getMilliseconds() === date.getMilliseconds(),
locale,
config
)
) {
const difference =
((calcDateDifferenceProperty(
endDate,
startDate,
differenceInDays,
locale,
config
) as number) +
1) *
(forward ? 1 : -1);
start = calcDate(startDate, addDays, locale, config, difference);
end = calcDate(endDate, addDays, locale, config, difference);
} else {
const difference =
((calcDateDifferenceProperty(

View File

@@ -0,0 +1,116 @@
import {
addDays,
subHours,
endOfDay,
endOfMonth,
endOfWeek,
endOfYear,
startOfDay,
startOfMonth,
startOfWeek,
startOfYear,
startOfQuarter,
endOfQuarter,
subDays,
subMonths,
} from "date-fns";
import type { HomeAssistant } from "../../types";
import { calcDate } from "./calc_date";
import { firstWeekdayIndex } from "./first_weekday";
export type DateRange =
| "today"
| "yesterday"
| "this_week"
| "this_month"
| "this_quarter"
| "this_year"
| "now-7d"
| "now-30d"
| "now-12m"
| "now-1h"
| "now-12h"
| "now-24h";
export const calcDateRange = (
hass: HomeAssistant,
range: DateRange
): [Date, Date] => {
const today = new Date();
const weekStartsOn = firstWeekdayIndex(hass.locale);
switch (range) {
case "today":
return [
calcDate(today, startOfDay, hass.locale, hass.config, {
weekStartsOn,
}),
calcDate(today, endOfDay, hass.locale, hass.config, {
weekStartsOn,
}),
];
case "yesterday":
return [
calcDate(addDays(today, -1), startOfDay, hass.locale, hass.config, {
weekStartsOn,
}),
calcDate(addDays(today, -1), endOfDay, hass.locale, hass.config, {
weekStartsOn,
}),
];
case "this_week":
return [
calcDate(today, startOfWeek, hass.locale, hass.config, {
weekStartsOn,
}),
calcDate(today, endOfWeek, hass.locale, hass.config, {
weekStartsOn,
}),
];
case "this_month":
return [
calcDate(today, startOfMonth, hass.locale, hass.config),
calcDate(today, endOfMonth, hass.locale, hass.config),
];
case "this_quarter":
return [
calcDate(today, startOfQuarter, hass.locale, hass.config),
calcDate(today, endOfQuarter, hass.locale, hass.config),
];
case "this_year":
return [
calcDate(today, startOfYear, hass.locale, hass.config),
calcDate(today, endOfYear, hass.locale, hass.config),
];
case "now-7d":
return [
calcDate(today, subDays, hass.locale, hass.config, 7),
calcDate(today, subDays, hass.locale, hass.config, 1),
];
case "now-30d":
return [
calcDate(today, subDays, hass.locale, hass.config, 30),
calcDate(today, subDays, hass.locale, hass.config, 1),
];
case "now-12m":
return [
calcDate(subMonths(today, 12), startOfMonth, hass.locale, hass.config),
calcDate(subMonths(today, 1), endOfMonth, hass.locale, hass.config),
];
case "now-1h":
return [
calcDate(today, subHours, hass.locale, hass.config, 1),
calcDate(today, subHours, hass.locale, hass.config, 0),
];
case "now-12h":
return [
calcDate(today, subHours, hass.locale, hass.config, 12),
calcDate(today, subHours, hass.locale, hass.config, 0),
];
case "now-24h":
return [
calcDate(today, subHours, hass.locale, hass.config, 24),
calcDate(today, subHours, hass.locale, hass.config, 0),
];
}
return [today, today];
};

View File

@@ -0,0 +1,4 @@
import type { AreaRegistryEntry } from "../../data/area_registry";
export const computeAreaName = (area: AreaRegistryEntry): string | undefined =>
area.name?.trim();

View File

@@ -34,7 +34,7 @@ export const computeAttributeValueDisplay = (
value !== undefined ? value : stateObj.attributes[attribute];
// Null value, the state is unknown
if (attributeValue === null) {
if (attributeValue === null || attributeValue === undefined) {
return localize("state.default.unknown");
}

View File

@@ -0,0 +1,38 @@
import type { DeviceRegistryEntry } from "../../data/device_registry";
import type {
EntityRegistryDisplayEntry,
EntityRegistryEntry,
} from "../../data/entity_registry";
import type { HomeAssistant } from "../../types";
import { computeStateName } from "./compute_state_name";
export const computeDeviceName = (
device: DeviceRegistryEntry
): string | undefined => (device.name_by_user || device.name)?.trim();
export const computeDeviceNameDisplay = (
device: DeviceRegistryEntry,
hass: HomeAssistant,
entities?: EntityRegistryEntry[] | EntityRegistryDisplayEntry[] | string[]
) =>
computeDeviceName(device) ||
(entities && fallbackDeviceName(hass, entities)) ||
hass.localize("ui.panel.config.devices.unnamed_device", {
type: hass.localize(
`ui.panel.config.devices.type.${device.entry_type || "device"}`
),
});
export const fallbackDeviceName = (
hass: HomeAssistant,
entities: EntityRegistryEntry[] | EntityRegistryDisplayEntry[] | string[]
) => {
for (const entity of entities || []) {
const entityId = typeof entity === "string" ? entity : entity.entity_id;
const stateObj = hass.states[entityId];
if (stateObj) {
return computeStateName(stateObj);
}
}
return undefined;
};

View File

@@ -0,0 +1,59 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type {
EntityRegistryDisplayEntry,
EntityRegistryEntry,
} from "../../data/entity_registry";
import type { HomeAssistant } from "../../types";
import { computeDeviceName } from "./compute_device_name";
import { computeStateName } from "./compute_state_name";
import { stripPrefixFromEntityName } from "./strip_prefix_from_entity_name";
export const computeEntityName = (
stateObj: HassEntity,
hass: HomeAssistant
): string | undefined => {
const entry = hass.entities[stateObj.entity_id] as
| EntityRegistryDisplayEntry
| undefined;
if (!entry) {
// Fall back to state name if not in the entity registry (friendly name)
return computeStateName(stateObj);
}
return computeEntityEntryName(entry, hass);
};
export const computeEntityEntryName = (
entry: EntityRegistryDisplayEntry | EntityRegistryEntry,
hass: HomeAssistant
): string | undefined => {
const name =
entry.name || ("original_name" in entry ? entry.original_name : undefined);
const device = entry.device_id ? hass.devices[entry.device_id] : undefined;
if (!device) {
if (name) {
return name;
}
const stateObj = hass.states[entry.entity_id] as HassEntity | undefined;
if (stateObj) {
return computeStateName(stateObj);
}
return undefined;
}
const deviceName = computeDeviceName(device);
// If the device name is the same as the entity name, consider empty entity name
if (deviceName === name) {
return undefined;
}
// Remove the device name from the entity name if it starts with it
if (deviceName && name) {
return stripPrefixFromEntityName(name, deviceName) || name;
}
return name;
};

View File

@@ -0,0 +1,4 @@
import type { FloorRegistryEntry } from "../../data/floor_registry";
export const computeFloorName = (floor: FloorRegistryEntry): string =>
floor.name?.trim();

View File

@@ -0,0 +1,30 @@
import type { AreaRegistryEntry } from "../../../data/area_registry";
import type { FloorRegistryEntry } from "../../../data/floor_registry";
import type { HomeAssistant } from "../../../types";
interface AreaContext {
area: AreaRegistryEntry | null;
floor: FloorRegistryEntry | null;
}
export const getAreaContext = (
areaId: string,
hass: HomeAssistant
): AreaContext => {
const area = (hass.areas[areaId] as AreaRegistryEntry | undefined) || null;
if (!area) {
return {
area: null,
floor: null,
};
}
const floorId = area?.floor_id;
const floor = floorId ? hass.floors[floorId] : null;
return {
area: area,
floor: floor,
};
};

View File

@@ -0,0 +1,43 @@
import type { AreaRegistryEntry } from "../../../data/area_registry";
import type { DeviceRegistryEntry } from "../../../data/device_registry";
import type { EntityRegistryDisplayEntry } from "../../../data/entity_registry";
import type { FloorRegistryEntry } from "../../../data/floor_registry";
import type { HomeAssistant } from "../../../types";
interface EntityContext {
entity: EntityRegistryDisplayEntry | null;
device: DeviceRegistryEntry | null;
area: AreaRegistryEntry | null;
floor: FloorRegistryEntry | null;
}
export const getEntityContext = (
entityId: string,
hass: HomeAssistant
): EntityContext => {
const entity =
(hass.entities[entityId] as EntityRegistryDisplayEntry | undefined) || null;
if (!entity) {
return {
entity: null,
device: null,
area: null,
floor: null,
};
}
const deviceId = entity?.device_id;
const device = deviceId ? hass.devices[deviceId] : null;
const areaId = entity?.area_id || device?.area_id;
const area = areaId ? hass.areas[areaId] : null;
const floorId = area?.floor_id;
const floor = floorId ? hass.floors[floorId] : null;
return {
entity: entity,
device: device,
area: area,
floor: floor,
};
};

View File

@@ -0,0 +1,78 @@
import { computeDomain } from "./compute_domain";
export type EntityDomainFilterFunc = (entityId: string) => boolean;
export interface EntityDomainFilter {
include_domains: string[];
include_entities: string[];
exclude_domains: string[];
exclude_entities: string[];
}
export const isEmptyEntityDomainFilter = (filter: EntityDomainFilter) =>
filter.include_domains.length +
filter.include_entities.length +
filter.exclude_domains.length +
filter.exclude_entities.length ===
0;
export const generateEntityDomainFilter = (
includeDomains?: string[],
includeEntities?: string[],
excludeDomains?: string[],
excludeEntities?: string[]
): EntityDomainFilterFunc => {
const includeDomainsSet = new Set(includeDomains);
const includeEntitiesSet = new Set(includeEntities);
const excludeDomainsSet = new Set(excludeDomains);
const excludeEntitiesSet = new Set(excludeEntities);
const haveInclude = includeDomainsSet.size > 0 || includeEntitiesSet.size > 0;
const haveExclude = excludeDomainsSet.size > 0 || excludeEntitiesSet.size > 0;
// Case 1 - no includes or excludes - pass all entities
if (!haveInclude && !haveExclude) {
return () => true;
}
// Case 2 - includes, no excludes - only include specified entities
if (haveInclude && !haveExclude) {
return (entityId) =>
includeEntitiesSet.has(entityId) ||
includeDomainsSet.has(computeDomain(entityId));
}
// Case 3 - excludes, no includes - only exclude specified entities
if (!haveInclude && haveExclude) {
return (entityId) =>
!excludeEntitiesSet.has(entityId) &&
!excludeDomainsSet.has(computeDomain(entityId));
}
// Case 4 - both includes and excludes specified
// Case 4a - include domain specified
// - if domain is included, pass if entity not excluded
// - if domain is not included, pass if entity is included
// note: if both include and exclude domains specified,
// the exclude domains are ignored
if (includeDomainsSet.size) {
return (entityId) =>
includeDomainsSet.has(computeDomain(entityId))
? !excludeEntitiesSet.has(entityId)
: includeEntitiesSet.has(entityId);
}
// Case 4b - exclude domain specified
// - if domain is excluded, pass if entity is included
// - if domain is not excluded, pass if entity not excluded
if (excludeDomainsSet.size) {
return (entityId) =>
excludeDomainsSet.has(computeDomain(entityId))
? includeEntitiesSet.has(entityId)
: !excludeEntitiesSet.has(entityId);
}
// Case 4c - neither include or exclude domain specified
// - Only pass if entity is included. Ignore entity excludes.
return (entityId) => includeEntitiesSet.has(entityId);
};

View File

@@ -1,78 +1,121 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { HomeAssistant } from "../../types";
import { ensureArray } from "../array/ensure-array";
import { computeDomain } from "./compute_domain";
import { getEntityContext } from "./context/get_entity_context";
export type FilterFunc = (entityId: string) => boolean;
type EntityCategory = "none" | "config" | "diagnostic";
export interface EntityFilter {
include_domains: string[];
include_entities: string[];
exclude_domains: string[];
exclude_entities: string[];
domain?: string | string[];
device_class?: string | string[];
device?: string | string[];
area?: string | string[];
floor?: string | string[];
label?: string | string[];
entity_category?: EntityCategory | EntityCategory[];
hidden_platform?: string | string[];
}
export const isEmptyFilter = (filter: EntityFilter) =>
filter.include_domains.length +
filter.include_entities.length +
filter.exclude_domains.length +
filter.exclude_entities.length ===
0;
export type EntityFilterFunc = (entityId: string) => boolean;
export const generateFilter = (
includeDomains?: string[],
includeEntities?: string[],
excludeDomains?: string[],
excludeEntities?: string[]
): FilterFunc => {
const includeDomainsSet = new Set(includeDomains);
const includeEntitiesSet = new Set(includeEntities);
const excludeDomainsSet = new Set(excludeDomains);
const excludeEntitiesSet = new Set(excludeEntities);
export const generateEntityFilter = (
hass: HomeAssistant,
filter: EntityFilter
): EntityFilterFunc => {
const domains = filter.domain
? new Set(ensureArray(filter.domain))
: undefined;
const deviceClasses = filter.device_class
? new Set(ensureArray(filter.device_class))
: undefined;
const floors = filter.floor ? new Set(ensureArray(filter.floor)) : undefined;
const areas = filter.area ? new Set(ensureArray(filter.area)) : undefined;
const devices = filter.device
? new Set(ensureArray(filter.device))
: undefined;
const entityCategories = filter.entity_category
? new Set(ensureArray(filter.entity_category))
: undefined;
const labels = filter.label ? new Set(ensureArray(filter.label)) : undefined;
const hiddenPlatforms = filter.hidden_platform
? new Set(ensureArray(filter.hidden_platform))
: undefined;
const haveInclude = includeDomainsSet.size > 0 || includeEntitiesSet.size > 0;
const haveExclude = excludeDomainsSet.size > 0 || excludeEntitiesSet.size > 0;
return (entityId: string) => {
const stateObj = hass.states[entityId] as HassEntity | undefined;
if (!stateObj) {
return false;
}
if (domains) {
const domain = computeDomain(entityId);
if (!domains.has(domain)) {
return false;
}
}
if (deviceClasses) {
const dc = stateObj.attributes.device_class || "none";
if (!deviceClasses.has(dc)) {
return false;
}
}
// Case 1 - no includes or excludes - pass all entities
if (!haveInclude && !haveExclude) {
return () => true;
}
const { area, floor, device, entity } = getEntityContext(entityId, hass);
// Case 2 - includes, no excludes - only include specified entities
if (haveInclude && !haveExclude) {
return (entityId) =>
includeEntitiesSet.has(entityId) ||
includeDomainsSet.has(computeDomain(entityId));
}
if (entity && entity.hidden) {
return false;
}
// Case 3 - excludes, no includes - only exclude specified entities
if (!haveInclude && haveExclude) {
return (entityId) =>
!excludeEntitiesSet.has(entityId) &&
!excludeDomainsSet.has(computeDomain(entityId));
}
if (floors) {
if (!floor) {
return false;
}
if (!floors) {
return false;
}
}
if (areas) {
if (!area) {
return false;
}
if (!areas.has(area.area_id)) {
return false;
}
}
if (devices) {
if (!device) {
return false;
}
if (!devices.has(device.id)) {
return false;
}
}
if (labels) {
if (!entity) {
return false;
}
if (!entity.labels.some((label) => labels.has(label))) {
return false;
}
}
if (entityCategories) {
if (!entity) {
return false;
}
const category = entity?.entity_category || "none";
if (!entityCategories.has(category)) {
return false;
}
}
if (hiddenPlatforms) {
if (!entity) {
return false;
}
if (entity.platform && hiddenPlatforms.has(entity.platform)) {
return false;
}
}
// Case 4 - both includes and excludes specified
// Case 4a - include domain specified
// - if domain is included, pass if entity not excluded
// - if domain is not included, pass if entity is included
// note: if both include and exclude domains specified,
// the exclude domains are ignored
if (includeDomainsSet.size) {
return (entityId) =>
includeDomainsSet.has(computeDomain(entityId))
? !excludeEntitiesSet.has(entityId)
: includeEntitiesSet.has(entityId);
}
// Case 4b - exclude domain specified
// - if domain is excluded, pass if entity is included
// - if domain is not excluded, pass if entity not excluded
if (excludeDomainsSet.size) {
return (entityId) =>
excludeDomainsSet.has(computeDomain(entityId))
? includeEntitiesSet.has(entityId)
: !excludeEntitiesSet.has(entityId);
}
// Case 4c - neither include or exclude domain specified
// - Only pass if entity is included. Ignore entity excludes.
return (entityId) => includeEntitiesSet.has(entityId);
return true;
};
};

View File

@@ -0,0 +1,18 @@
import type { AreaRegistryEntry } from "../../data/area_registry";
import type { FloorRegistryEntry } from "../../data/floor_registry";
import type { HomeAssistant } from "../../types";
interface AreaContext {
floor: FloorRegistryEntry | null;
}
export const getAreaContext = (
area: AreaRegistryEntry,
hass: HomeAssistant
): AreaContext => {
const floorId = area.floor_id;
const floor = floorId ? hass.floors[floorId] : null;
return {
floor: floor,
};
};

View File

@@ -0,0 +1,24 @@
import type { AreaRegistryEntry } from "../../data/area_registry";
import type { DeviceRegistryEntry } from "../../data/device_registry";
import type { FloorRegistryEntry } from "../../data/floor_registry";
import type { HomeAssistant } from "../../types";
interface DeviceContext {
area: AreaRegistryEntry | null;
floor: FloorRegistryEntry | null;
}
export const getDeviceContext = (
device: DeviceRegistryEntry,
hass: HomeAssistant
): DeviceContext => {
const areaId = device.area_id;
const area = areaId ? hass.areas[areaId] : null;
const floorId = area?.floor_id;
const floor = floorId ? hass.floors[floorId] : null;
return {
area: area,
floor: floor,
};
};

View File

@@ -0,0 +1,55 @@
import type { HassEntity } from "home-assistant-js-websocket";
import type { AreaRegistryEntry } from "../../data/area_registry";
import type { DeviceRegistryEntry } from "../../data/device_registry";
import type {
EntityRegistryDisplayEntry,
EntityRegistryEntry,
ExtEntityRegistryEntry,
} from "../../data/entity_registry";
import type { FloorRegistryEntry } from "../../data/floor_registry";
import type { HomeAssistant } from "../../types";
interface EntityContext {
device: DeviceRegistryEntry | null;
area: AreaRegistryEntry | null;
floor: FloorRegistryEntry | null;
}
export const getEntityContext = (
stateObj: HassEntity,
hass: HomeAssistant
): EntityContext => {
const entry = hass.entities[stateObj.entity_id] as
| EntityRegistryDisplayEntry
| undefined;
if (!entry) {
return {
device: null,
area: null,
floor: null,
};
}
return getEntityEntryContext(entry, hass);
};
export const getEntityEntryContext = (
entry:
| EntityRegistryDisplayEntry
| EntityRegistryEntry
| ExtEntityRegistryEntry,
hass: HomeAssistant
): EntityContext => {
const deviceId = entry?.device_id;
const device = deviceId ? hass.devices[deviceId] : null;
const areaId = entry?.area_id || device?.area_id;
const area = areaId ? hass.areas[areaId] : null;
const floorId = area?.floor_id;
const floor = floorId ? hass.floors[floorId] : null;
return {
device: device,
area: area,
floor: floor,
};
};

View File

@@ -1,17 +1,17 @@
const SUFFIXES = [" ", ": "];
const SUFFIXES = [" ", ": ", " - "];
/**
* Strips a device name from an entity name.
* @param entityName the entity name
* @param lowerCasedPrefix the prefix to strip, lower cased
* @param prefix the prefix to strip
* @returns
*/
export const stripPrefixFromEntityName = (
entityName: string,
lowerCasedPrefix: string
prefix: string
) => {
const lowerCasedEntityName = entityName.toLowerCase();
const lowerCasedPrefix = prefix.toLowerCase();
for (const suffix of SUFFIXES) {
const lowerCasedPrefixWithSuffix = `${lowerCasedPrefix}${suffix}`;

View File

@@ -1,2 +1 @@
export const webComponentsSupported =
"customElements" in window && "content" in document.createElement("template");
export const webComponentsSupported = "attachShadow" in Element.prototype;

View File

@@ -45,3 +45,22 @@ export const caseInsensitiveStringCompare = (
return fallbackStringCompare(a.toLowerCase(), b.toLowerCase());
};
export const orderCompare = (order: string[]) => (a: string, b: string) => {
const idxA = order.indexOf(a);
const idxB = order.indexOf(b);
if (idxA === idxB) {
return 0;
}
if (idxA === -1) {
return 1;
}
if (idxB === -1) {
return -1;
}
return idxA - idxB;
};

6
src/common/util/wait.ts Normal file
View File

@@ -0,0 +1,6 @@
export const waitForMs = (ms: number) =>
new Promise((resolve) => {
setTimeout(resolve, ms);
});
export const waitForSeconds = (seconds: number) => waitForMs(seconds * 1000);

View File

@@ -1,31 +1,38 @@
import "@material/mwc-button";
import { mdiAlertOctagram, mdiCheckBold } from "@mdi/js";
import type { TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../ha-circular-progress";
import "../ha-button";
import "../ha-spinner";
import "../ha-svg-icon";
@customElement("ha-progress-button")
export class HaProgressButton extends LitElement {
@property() public label?: string;
@property({ type: Boolean }) public disabled = false;
@property({ type: Boolean }) public progress = false;
@property({ type: Boolean }) public raised = false;
@property({ type: Boolean }) public unelevated = false;
@state() private _result?: "success" | "error";
public render(): TemplateResult {
const overlay = this._result || this.progress;
return html`
<mwc-button
?raised=${this.raised}
<ha-button
.raised=${this.raised}
.label=${this.label}
.unelevated=${this.unelevated}
.disabled=${this.disabled || this.progress}
class=${this._result || ""}
>
<slot name="icon" slot="icon"></slot>
<slot></slot>
</mwc-button>
</ha-button>
${!overlay
? nothing
: html`
@@ -35,12 +42,7 @@ export class HaProgressButton extends LitElement {
: this._result === "error"
? html`<ha-svg-icon .path=${mdiAlertOctagram}></ha-svg-icon>`
: this.progress
? html`
<ha-circular-progress
size="small"
indeterminate
></ha-circular-progress>
`
? html`<ha-spinner size="small"></ha-spinner>`
: nothing}
</div>
`}
@@ -70,12 +72,12 @@ export class HaProgressButton extends LitElement {
pointer-events: none;
}
mwc-button {
ha-button {
transition: all 1s;
pointer-events: initial;
}
mwc-button.success {
ha-button.success {
--mdc-theme-primary: white;
background-color: var(--success-color);
transition: none;
@@ -83,12 +85,13 @@ export class HaProgressButton extends LitElement {
pointer-events: none;
}
mwc-button[raised].success {
ha-button[unelevated].success,
ha-button[raised].success {
--mdc-theme-primary: var(--success-color);
--mdc-theme-on-primary: white;
}
mwc-button.error {
ha-button.error {
--mdc-theme-primary: white;
background-color: var(--error-color);
transition: none;
@@ -96,7 +99,8 @@ export class HaProgressButton extends LitElement {
pointer-events: none;
}
mwc-button[raised].error {
ha-button[unelevated].error,
ha-button[raised].error {
--mdc-theme-primary: var(--error-color);
--mdc-theme-on-primary: white;
}
@@ -113,8 +117,8 @@ export class HaProgressButton extends LitElement {
color: white;
}
mwc-button.success slot,
mwc-button.error slot {
ha-button.success slot,
ha-button.error slot {
visibility: hidden;
}
:host([destructive]) {

View File

@@ -108,7 +108,10 @@ export class HaChartBase extends LitElement {
// Add keyboard event listeners
const handleKeyDown = (ev: KeyboardEvent) => {
if ((isMac && ev.key === "Meta") || (!isMac && ev.key === "Control")) {
if (
!this._modifierPressed &&
((isMac && ev.key === "Meta") || (!isMac && ev.key === "Control"))
) {
this._modifierPressed = true;
if (!this.options?.dataZoom) {
this._setChartOptions({ dataZoom: this._getDataZoomConfig() });
@@ -123,7 +126,10 @@ export class HaChartBase extends LitElement {
};
const handleKeyUp = (ev: KeyboardEvent) => {
if ((isMac && ev.key === "Meta") || (!isMac && ev.key === "Control")) {
if (
this._modifierPressed &&
((isMac && ev.key === "Meta") || (!isMac && ev.key === "Control"))
) {
this._modifierPressed = false;
if (!this.options?.dataZoom) {
this._setChartOptions({ dataZoom: this._getDataZoomConfig() });
@@ -220,7 +226,12 @@ export class HaChartBase extends LitElement {
const overflowLimit = isMobile
? LEGEND_OVERFLOW_LIMIT_MOBILE
: LEGEND_OVERFLOW_LIMIT;
return html`<div class="chart-legend">
return html`<div
class=${classMap({
"chart-legend": true,
"multiple-items": items.length > 1,
})}
>
<ul>
${items.map((item: string, index: number) => {
if (!this.expandLegend && index >= overflowLimit) {
@@ -252,9 +263,13 @@ export class HaChartBase extends LitElement {
<ha-assist-chip
@click=${this._toggleExpandedLegend}
filled
label=${`${this.hass.localize(
`ui.components.history_charts.${this.expandLegend ? "collapse_legend" : "expand_legend"}`
)} (${items.length})`}
label=${this.expandLegend
? this.hass.localize(
"ui.components.history_charts.collapse_legend"
)
: `${this.hass.localize(
"ui.components.history_charts.expand_legend"
)} (${items.length - overflowLimit})`}
>
<ha-svg-icon
slot="trailing-icon"
@@ -316,6 +331,16 @@ export class HaChartBase extends LitElement {
}
});
}
const legend = ensureArray(this.options?.legend || [])[0] as
| LegendComponentOption
| undefined;
Object.entries(legend?.selected || {}).forEach(([stat, selected]) => {
if (selected === false) {
this._hiddenDatasets.add(stat);
}
});
this.chart.setOption({
...this._createOptions(),
series: this._getSeries(),
@@ -562,8 +587,8 @@ export class HaChartBase extends LitElement {
fontSize: 12,
},
axisPointer: {
lineStyle: { color: style.getPropertyValue("--divider-color") },
crossStyle: { color: style.getPropertyValue("--divider-color") },
lineStyle: { color: style.getPropertyValue("--info-color") },
crossStyle: { color: style.getPropertyValue("--info-color") },
},
},
timeline: {},
@@ -689,7 +714,7 @@ export class HaChartBase extends LitElement {
.chart-legend {
max-height: 60%;
overflow-y: auto;
margin: 12px 0 0;
padding: 12px 0 0;
font-size: 12px;
color: var(--primary-text-color);
}
@@ -709,10 +734,10 @@ export class HaChartBase extends LitElement {
align-items: center;
padding: 0 2px;
box-sizing: border-box;
max-width: 220px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.chart-legend.multiple-items li {
max-width: 220px;
}
.chart-legend .hidden {
color: var(--secondary-text-color);

View File

@@ -124,7 +124,7 @@ export class StateHistoryChartLine extends LitElement {
const data = dataset.data || [];
for (let i = data.length - 1; i >= 0; i--) {
const point = data[i];
if (point && point[0] <= time && point[1]) {
if (point && point[0] <= time && typeof point[1] === "number") {
lastData = point;
break;
}

View File

@@ -296,7 +296,11 @@ export class StatisticsChart extends LitElement {
align: "left",
},
position: computeRTL(this.hass) ? "right" : "left",
scale: true,
scale:
this.chartType !== "bar" ||
this.logarithmicScale ||
minYAxis !== undefined ||
maxYAxis !== undefined,
min: this._clampYAxis(minYAxis),
max: this._clampYAxis(maxYAxis),
splitLine: {

View File

@@ -5,6 +5,7 @@ import { LitElement, html } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../common/dom/fire_event";
import { computeDeviceNameDisplay } from "../../common/entity/compute_device_name";
import { computeDomain } from "../../common/entity/compute_domain";
import { stringCompare } from "../../common/string/compare";
import type { ScorableTextItem } from "../../common/string/filter/sequence-matching";
@@ -13,10 +14,7 @@ import type {
DeviceEntityDisplayLookup,
DeviceRegistryEntry,
} from "../../data/device_registry";
import {
computeDeviceName,
getDeviceEntityDisplayLookup,
} from "../../data/device_registry";
import { getDeviceEntityDisplayLookup } from "../../data/device_registry";
import type { EntityRegistryDisplayEntry } from "../../data/entity_registry";
import type { HomeAssistant, ValueChangedEvent } from "../../types";
import "../ha-combo-box";
@@ -214,7 +212,7 @@ export class HaDevicePicker extends LitElement {
}
const outputDevices = inputDevices.map((device) => {
const name = computeDeviceName(
const name = computeDeviceNameDisplay(
device,
this.hass,
deviceEntityLookup[device.id]

View File

@@ -371,6 +371,7 @@ export class HaEntityPicker extends LitElement {
.renderer=${this._rowRenderer}
.required=${this.required}
.disabled=${this.disabled}
.hideClearIcon=${this.hideClearIcon}
@opened-changed=${this._openedChanged}
@value-changed=${this._valueChanged}
@filter-changed=${this._filterChanged}

View File

@@ -193,17 +193,16 @@ export class StateBadge extends LitElement {
css`
:host {
position: relative;
display: inline-block;
display: inline-flex;
width: 40px;
color: var(--paper-item-icon-color, #44739e);
border-radius: 50%;
height: 40px;
text-align: center;
background-size: cover;
line-height: 40px;
vertical-align: middle;
box-sizing: border-box;
--state-inactive-color: initial;
align-items: center;
justify-content: center;
}
:host(:focus) {
outline: none;

View File

@@ -1,95 +0,0 @@
import { mdiTextureBox } from "@mdi/js";
import type { TemplateResult } from "lit";
import { LitElement, css, html } from "lit";
import { customElement, property } from "lit/decorators";
import { fireEvent } from "../common/dom/fire_event";
import { showAreaFilterDialog } from "../dialogs/area-filter/show-area-filter-dialog";
import type { HomeAssistant } from "../types";
import "./ha-icon-next";
import "./ha-svg-icon";
import "./ha-textfield";
export interface AreaFilterValue {
hidden?: string[];
order?: string[];
}
@customElement("ha-area-filter")
export class HaAreaPicker extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property() public label?: string;
@property({ attribute: false }) public value?: AreaFilterValue;
@property() public helper?: string;
@property({ type: Boolean }) public disabled = false;
@property({ type: Boolean }) public required = false;
protected render(): TemplateResult {
const allAreasCount = Object.keys(this.hass.areas).length;
const hiddenAreasCount = this.value?.hidden?.length ?? 0;
const description =
hiddenAreasCount === 0
? this.hass.localize("ui.components.area-filter.all_areas")
: allAreasCount === hiddenAreasCount
? this.hass.localize("ui.components.area-filter.no_areas")
: this.hass.localize("ui.components.area-filter.area_count", {
count: allAreasCount - hiddenAreasCount,
});
return html`
<ha-list-item
tabindex="0"
role="button"
hasMeta
twoline
graphic="icon"
@click=${this._edit}
@keydown=${this._edit}
.disabled=${this.disabled}
>
<ha-svg-icon slot="graphic" .path=${mdiTextureBox}></ha-svg-icon>
<span>${this.label}</span>
<span slot="secondary">${description}</span>
<ha-icon-next
slot="meta"
.label=${this.hass.localize("ui.common.edit")}
></ha-icon-next>
</ha-list-item>
`;
}
private async _edit(ev) {
if (ev.defaultPrevented) {
return;
}
if (ev.type === "keydown" && ev.key !== "Enter" && ev.key !== " ") {
return;
}
ev.preventDefault();
ev.stopPropagation();
const value = await showAreaFilterDialog(this, {
title: this.label,
initialValue: this.value,
});
if (!value) return;
fireEvent(this, "value-changed", { value });
}
static styles = css`
ha-list-item {
--mdc-list-side-padding-left: 8px;
--mdc-list-side-padding-right: 8px;
}
`;
}
declare global {
interface HTMLElementTagNameMap {
"ha-area-filter": HaAreaPicker;
}
}

View File

@@ -0,0 +1,102 @@
import { mdiTextureBox } from "@mdi/js";
import type { TemplateResult } from "lit";
import { LitElement, html } from "lit";
import { customElement, property } from "lit/decorators";
import { fireEvent } from "../common/dom/fire_event";
import { getAreaContext } from "../common/entity/context/get_area_context";
import { areaCompare } from "../data/area_registry";
import type { HomeAssistant } from "../types";
import "./ha-expansion-panel";
import "./ha-items-display-editor";
import type { DisplayItem, DisplayValue } from "./ha-items-display-editor";
import "./ha-svg-icon";
import "./ha-textfield";
export interface AreasDisplayValue {
hidden?: string[];
order?: string[];
}
@customElement("ha-areas-display-editor")
export class HaAreasDisplayEditor extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property() public label?: string;
@property({ attribute: false }) public value?: AreasDisplayValue;
@property() public helper?: string;
@property({ type: Boolean }) public expanded = false;
@property({ type: Boolean }) public disabled = false;
@property({ type: Boolean }) public required = false;
@property({ type: Boolean, attribute: "show-navigation-button" })
public showNavigationButton = false;
protected render(): TemplateResult {
const compare = areaCompare(this.hass.areas);
const areas = Object.values(this.hass.areas).sort((areaA, areaB) =>
compare(areaA.area_id, areaB.area_id)
);
const items: DisplayItem[] = areas.map((area) => {
const { floor } = getAreaContext(area.area_id, this.hass!);
return {
value: area.area_id,
label: area.name,
icon: area.icon ?? undefined,
iconPath: mdiTextureBox,
description: floor?.name,
};
});
const value: DisplayValue = {
order: this.value?.order ?? [],
hidden: this.value?.hidden ?? [],
};
return html`
<ha-expansion-panel
outlined
.header=${this.label}
.expanded=${this.expanded}
>
<ha-svg-icon slot="leading-icon" .path=${mdiTextureBox}></ha-svg-icon>
<ha-items-display-editor
.hass=${this.hass}
.items=${items}
.value=${value}
@value-changed=${this._areaDisplayChanged}
.showNavigationButton=${this.showNavigationButton}
></ha-items-display-editor>
</ha-expansion-panel>
`;
}
private async _areaDisplayChanged(ev) {
ev.stopPropagation();
const value = ev.detail.value as DisplayValue;
const newValue: AreasDisplayValue = {
...this.value,
...value,
};
if (newValue.hidden?.length === 0) {
delete newValue.hidden;
}
if (newValue.order?.length === 0) {
delete newValue.order;
}
fireEvent(this, "value-changed", { value: newValue });
}
}
declare global {
interface HTMLElementTagNameMap {
"ha-areas-display-editor": HaAreasDisplayEditor;
}
}

View File

@@ -295,6 +295,7 @@ export class HaAssistChat extends LitElement {
this._addMessage(userMessage);
this.requestUpdate("_audioRecorder");
let continueConversation = false;
let hassMessage = {
who: "hass",
text: "…",
@@ -369,6 +370,8 @@ export class HaAssistChat extends LitElement {
if (event.type === "intent-end") {
this._conversationId = event.data.intent_output.conversation_id;
continueConversation =
event.data.intent_output.continue_conversation;
const plain = event.data.intent_output.response.speech?.plain;
if (plain) {
hassMessage.text = plain.speech;
@@ -380,7 +383,12 @@ export class HaAssistChat extends LitElement {
const url = event.data.tts_output.url;
this._audio = new Audio(url);
this._audio.play();
this._audio.addEventListener("ended", this._unloadAudio);
this._audio.addEventListener("ended", () => {
this._unloadAudio();
if (continueConversation) {
this._startListening();
}
});
this._audio.addEventListener("pause", this._unloadAudio);
this._audio.addEventListener("canplaythrough", this._playAudio);
this._audio.addEventListener("error", this._audioError);

View File

@@ -1,49 +0,0 @@
import { MdCircularProgress } from "@material/web/progress/circular-progress";
import type { PropertyValues } from "lit";
import { css } from "lit";
import { customElement, property } from "lit/decorators";
@customElement("ha-circular-progress")
export class HaCircularProgress extends MdCircularProgress {
@property({ attribute: "aria-label", type: String }) public ariaLabel =
"Loading";
@property() public size?: "tiny" | "small" | "medium" | "large";
protected updated(changedProps: PropertyValues) {
super.updated(changedProps);
if (changedProps.has("size")) {
switch (this.size) {
case "tiny":
this.style.setProperty("--md-circular-progress-size", "16px");
break;
case "small":
this.style.setProperty("--md-circular-progress-size", "28px");
break;
case "medium":
this.style.setProperty("--md-circular-progress-size", "48px");
break;
case "large":
this.style.setProperty("--md-circular-progress-size", "68px");
break;
}
}
}
static override styles = [
...super.styles,
css`
:host {
--md-sys-color-primary: var(--primary-color);
--md-circular-progress-size: 48px;
}
`,
];
}
declare global {
interface HTMLElementTagNameMap {
"ha-circular-progress": HaCircularProgress;
}
}

View File

@@ -105,6 +105,9 @@ export class HaComboBox extends LitElement {
@property({ type: Boolean, reflect: true }) public opened = false;
@property({ type: Boolean, attribute: "hide-clear-icon" })
public hideClearIcon = false;
@query("vaadin-combo-box-light", true) private _comboBox!: ComboBoxLight;
@query("ha-textfield", true) private _inputElement!: HaTextField;
@@ -187,7 +190,7 @@ export class HaComboBox extends LitElement {
>
<slot name="icon" slot="leadingIcon"></slot>
</ha-textfield>
${this.value
${this.value && !this.hideClearIcon
? html`<ha-svg-icon
role="button"
tabindex="-1"
@@ -204,6 +207,7 @@ export class HaComboBox extends LitElement {
aria-expanded=${this.opened ? "true" : "false"}
class="toggle-button"
.path=${this.opened ? mdiMenuUp : mdiMenuDown}
?disabled=${this.disabled}
@click=${this._toggleOpen}
></ha-svg-icon>
</vaadin-combo-box-light>
@@ -356,6 +360,10 @@ export class HaComboBox extends LitElement {
:host([opened]) .toggle-button {
color: var(--primary-color);
}
.toggle-button[disabled] {
color: var(--disabled-text-color);
pointer-events: none;
}
.clear-button {
--mdc-icon-size: 20px;
top: -7px;

View File

@@ -1,5 +1,6 @@
import { SelectBase } from "@material/mwc-select/mwc-select-base";
import { mdiMenuDown } from "@mdi/js";
import type { PropertyValues } from "lit";
import { css, html, nothing } from "lit";
import { customElement, property, query } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
@@ -24,6 +25,16 @@ export class HaControlSelectMenu extends SelectBase {
@property({ type: Boolean, attribute: "hide-label" })
public hideLabel = false;
@property() public options;
protected updated(changedProps: PropertyValues) {
super.updated(changedProps);
if (changedProps.get("options")) {
this.layoutOptions();
this.selectByValue(this.value);
}
}
public override render() {
const classes = {
"select-disabled": this.disabled,

View File

@@ -1,4 +1,4 @@
import { DIRECTION_ALL, Manager, Pan, Tap } from "@egjs/hammerjs";
import { DIRECTION_ALL, Manager, Pan, Press, Tap } from "@egjs/hammerjs";
import type { PropertyValues, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
@@ -159,6 +159,7 @@ export class HaControlSlider extends LitElement {
);
this._mc.add(new Tap({ event: "singletap" }));
this._mc.add(new Press());
let savedValue;
this._mc.on("panstart", () => {
@@ -190,7 +191,7 @@ export class HaControlSlider extends LitElement {
fireEvent(this, "value-changed", { value: this.value });
});
this._mc.on("singletap", (e) => {
this._mc.on("singletap pressup", (e) => {
if (this.disabled) return;
const percentage = this._getPercentageFromEvent(e);
this.value = this.steppedValue(this.percentageToValue(percentage));

View File

@@ -2,6 +2,7 @@ import {
DIRECTION_HORIZONTAL,
DIRECTION_VERTICAL,
Manager,
Press,
Swipe,
Tap,
} from "@egjs/hammerjs";
@@ -79,6 +80,7 @@ export class HaControlSwitch extends LitElement {
);
this._mc.add(new Tap({ event: "singletap" }));
this._mc.add(new Press());
if (this.vertical) {
this._mc.on("swipeup", () => {
@@ -106,10 +108,11 @@ export class HaControlSwitch extends LitElement {
});
}
this._mc.on("singletap", () => {
this._mc.on("singletap pressup", () => {
if (this.disabled) return;
this._toggle();
});
this.addEventListener("keydown", this._keydown);
}
}

View File

@@ -8,7 +8,7 @@ import "./ha-list-item";
import "./ha-select";
import type { HaSelect } from "./ha-select";
const COUNTRIES = [
export const COUNTRIES = [
"AD",
"AE",
"AF",

View File

@@ -3,25 +3,13 @@ import "@material/mwc-list/mwc-list";
import type { ActionDetail } from "@material/mwc-list/mwc-list-foundation";
import "@material/mwc-list/mwc-list-item";
import { mdiCalendar } from "@mdi/js";
import {
addDays,
subHours,
endOfDay,
endOfMonth,
endOfWeek,
endOfYear,
startOfDay,
startOfMonth,
startOfWeek,
startOfYear,
isThisYear,
} from "date-fns";
import { isThisYear } from "date-fns";
import { fromZonedTime, toZonedTime } from "date-fns-tz";
import type { PropertyValues, TemplateResult } from "lit";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import { calcDate, shiftDateRange } from "../common/datetime/calc_date";
import { shiftDateRange } from "../common/datetime/calc_date";
import { firstWeekdayIndex } from "../common/datetime/first_weekday";
import {
formatShortDateTime,
@@ -36,9 +24,28 @@ import "./ha-icon-button";
import "./ha-icon-button-next";
import "./ha-icon-button-prev";
import "./ha-textarea";
import { calcDateRange } from "../common/datetime/calc_date_range";
import type { DateRange } from "../common/datetime/calc_date_range";
export type DateRangePickerRanges = Record<string, [Date, Date]>;
declare global {
interface HASSDomEvents {
"preset-selected": { index: number };
}
}
const RANGE_KEYS: DateRange[] = ["today", "yesterday", "this_week"];
const EXTENDED_RANGE_KEYS: DateRange[] = [
"this_month",
"this_year",
"now-1h",
"now-12h",
"now-24h",
"now-7d",
"now-30d",
];
@customElement("ha-date-range-picker")
export class HaDateRangePicker extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@@ -84,194 +91,16 @@ export class HaDateRangePicker extends LitElement {
(changedProps.has("hass") &&
this.hass?.localize !== changedProps.get("hass")?.localize)
) {
const today = new Date();
const weekStartsOn = firstWeekdayIndex(this.hass.locale);
const weekStart = calcDate(
today,
startOfWeek,
this.hass.locale,
this.hass.config,
{
weekStartsOn,
}
);
const weekEnd = calcDate(
today,
endOfWeek,
this.hass.locale,
this.hass.config,
{
weekStartsOn,
}
);
const rangeKeys = this.extendedPresets
? [...RANGE_KEYS, ...EXTENDED_RANGE_KEYS]
: RANGE_KEYS;
this._ranges = {
[this.hass.localize("ui.components.date-range-picker.ranges.today")]: [
calcDate(today, startOfDay, this.hass.locale, this.hass.config, {
weekStartsOn,
}),
calcDate(today, endOfDay, this.hass.locale, this.hass.config, {
weekStartsOn,
}),
],
[this.hass.localize(
"ui.components.date-range-picker.ranges.yesterday"
)]: [
calcDate(
addDays(today, -1),
startOfDay,
this.hass.locale,
this.hass.config,
{
weekStartsOn,
}
),
calcDate(
addDays(today, -1),
endOfDay,
this.hass.locale,
this.hass.config,
{
weekStartsOn,
}
),
],
[this.hass.localize(
"ui.components.date-range-picker.ranges.this_week"
)]: [weekStart, weekEnd],
...(this.extendedPresets
? {
[this.hass.localize(
"ui.components.date-range-picker.ranges.this_month"
)]: [
calcDate(
today,
startOfMonth,
this.hass.locale,
this.hass.config,
{
weekStartsOn,
}
),
calcDate(
today,
endOfMonth,
this.hass.locale,
this.hass.config,
{
weekStartsOn,
}
),
],
[this.hass.localize(
"ui.components.date-range-picker.ranges.this_year"
)]: [
calcDate(
today,
startOfYear,
this.hass.locale,
this.hass.config,
{
weekStartsOn,
}
),
calcDate(today, endOfYear, this.hass.locale, this.hass.config, {
weekStartsOn,
}),
],
[this.hass.localize(
"ui.components.date-range-picker.ranges.now-1h"
)]: [
calcDate(
today,
subHours,
this.hass.locale,
this.hass.config,
1
),
calcDate(
today,
subHours,
this.hass.locale,
this.hass.config,
0
),
],
[this.hass.localize(
"ui.components.date-range-picker.ranges.now-12h"
)]: [
calcDate(
today,
subHours,
this.hass.locale,
this.hass.config,
12
),
calcDate(
today,
subHours,
this.hass.locale,
this.hass.config,
0
),
],
[this.hass.localize(
"ui.components.date-range-picker.ranges.now-24h"
)]: [
calcDate(
today,
subHours,
this.hass.locale,
this.hass.config,
24
),
calcDate(
today,
subHours,
this.hass.locale,
this.hass.config,
0
),
],
[this.hass.localize(
"ui.components.date-range-picker.ranges.now-7d"
)]: [
calcDate(
today,
subHours,
this.hass.locale,
this.hass.config,
24 * 7
),
calcDate(
today,
subHours,
this.hass.locale,
this.hass.config,
0
),
],
[this.hass.localize(
"ui.components.date-range-picker.ranges.now-30d"
)]: [
calcDate(
today,
subHours,
this.hass.locale,
this.hass.config,
24 * 30
),
calcDate(
today,
subHours,
this.hass.locale,
this.hass.config,
0
),
],
}
: {}),
};
this._ranges = {};
rangeKeys.forEach((key) => {
this._ranges![
this.hass.localize(`ui.components.date-range-picker.ranges.${key}`)
] = calcDateRange(this.hass, key);
});
}
}
@@ -410,6 +239,10 @@ export class HaDateRangePicker extends LitElement {
const dateRange = Object.values(this.ranges || this._ranges!)[
ev.detail.index
];
fireEvent(this, "preset-selected", {
index: ev.detail.index,
});
const dateRangePicker = this._dateRangePicker;
dateRangePicker.clickRange(dateRange);
dateRangePicker.clickedApply();

View File

@@ -139,6 +139,7 @@ export class HaDialog extends DialogBase {
:host([flexContent]) .mdc-dialog .mdc-dialog__content {
display: flex;
flex-direction: column;
scrollbar-color: var(--scrollbar-thumb-color) transparent;
}
.header_title {
display: flex;

View File

@@ -0,0 +1,50 @@
import { css, html, LitElement, nothing } from "lit";
import { ifDefined } from "lit/directives/if-defined";
import { customElement, property } from "lit/decorators";
@customElement("ha-divider")
export class HaMdDivider extends LitElement {
@property() public label?: string;
public render() {
return html`
<div
role=${ifDefined(this.label ? "separator" : undefined)}
aria-label=${ifDefined(this.label)}
>
<span class="line"></span>
${this.label
? html`
<span class="label">${this.label}</span>
<span class="line"></span>
`
: nothing}
</div>
`;
}
static styles = css`
:host {
width: var(--ha-divider-width, 100%);
}
div {
display: flex;
align-items: center;
justify-content: center;
}
.label {
padding: var(--ha-divider-label-padding, 0 16px);
}
.line {
flex: 1;
background-color: var(--divider-color);
height: var(--ha-divider-line-height, 1px);
}
`;
}
declare global {
interface HTMLElementTagNameMap {
"ha-divider": HaMdDivider;
}
}

View File

@@ -0,0 +1,81 @@
import type { TemplateResult } from "lit";
import { LitElement, html } from "lit";
import { customElement, property } from "lit/decorators";
import { fireEvent } from "../common/dom/fire_event";
import { computeStateName } from "../common/entity/compute_state_name";
import { entityIcon } from "../data/icons";
import type { HomeAssistant } from "../types";
import "./ha-items-display-editor";
import type { DisplayItem, DisplayValue } from "./ha-items-display-editor";
export interface EntitiesDisplayValue {
hidden?: string[];
order?: string[];
}
@customElement("ha-entities-display-editor")
export class HaEntitiesDisplayEditor extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property() public label?: string;
@property({ attribute: false }) public value?: EntitiesDisplayValue;
@property({ attribute: false }) public entitiesIds: string[] = [];
@property() public helper?: string;
@property({ type: Boolean }) public expanded = false;
@property({ type: Boolean }) public disabled = false;
@property({ type: Boolean }) public required = false;
protected render(): TemplateResult {
const entities = this.entitiesIds
.map((entityId) => this.hass.states[entityId])
.filter(Boolean);
const items: DisplayItem[] = entities.map((entity) => ({
value: entity.entity_id,
label: computeStateName(entity),
icon: entityIcon(this.hass, entity),
}));
const value: DisplayValue = {
order: this.value?.order ?? [],
hidden: this.value?.hidden ?? [],
};
return html`
<ha-items-display-editor
.hass=${this.hass}
.items=${items}
.value=${value}
@value-changed=${this._itemDisplayChanged}
></ha-items-display-editor>
`;
}
private _itemDisplayChanged(ev) {
ev.stopPropagation();
const value = ev.detail.value as DisplayValue;
const newValue: EntitiesDisplayValue = {
...this.value,
...value,
};
if (newValue.hidden?.length === 0) {
delete newValue.hidden;
}
if (newValue.order?.length === 0) {
delete newValue.order;
}
fireEvent(this, "value-changed", { value: newValue });
}
}
declare global {
interface HTMLElementTagNameMap {
"ha-entities-display-editor": HaEntitiesDisplayEditor;
}
}

View File

@@ -1,6 +1,6 @@
import { mdiChevronDown } from "@mdi/js";
import type { PropertyValues, TemplateResult } from "lit";
import { css, html, LitElement } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { fireEvent } from "../common/dom/fire_event";
@@ -13,11 +13,11 @@ export class HaExpansionPanel extends LitElement {
@property({ type: Boolean, reflect: true }) outlined = false;
@property({ attribute: false, type: Boolean, reflect: true }) leftChevron =
false;
@property({ attribute: "left-chevron", type: Boolean, reflect: true })
public leftChevron = false;
@property({ attribute: false, type: Boolean, reflect: true }) noCollapse =
false;
@property({ attribute: "no-collapse", type: Boolean, reflect: true })
public noCollapse = false;
@property() header?: string;
@@ -28,6 +28,14 @@ export class HaExpansionPanel extends LitElement {
@query(".container") private _container!: HTMLDivElement;
protected render(): TemplateResult {
const chevronIcon = this.noCollapse
? nothing
: html`
<ha-svg-icon
.path=${mdiChevronDown}
class="summary-icon ${classMap({ expanded: this.expanded })}"
></ha-svg-icon>
`;
return html`
<div class="top ${classMap({ expanded: this.expanded })}">
<div
@@ -42,28 +50,15 @@ export class HaExpansionPanel extends LitElement {
aria-expanded=${this.expanded}
aria-controls="sect1"
>
${this.leftChevron && !this.noCollapse
? html`
<ha-svg-icon
.path=${mdiChevronDown}
class="summary-icon ${classMap({ expanded: this.expanded })}"
></ha-svg-icon>
`
: ""}
${this.leftChevron ? chevronIcon : nothing}
<slot name="leading-icon"></slot>
<slot name="header">
<div class="header">
${this.header}
<slot class="secondary" name="secondary">${this.secondary}</slot>
</div>
</slot>
${!this.leftChevron && !this.noCollapse
? html`
<ha-svg-icon
.path=${mdiChevronDown}
class="summary-icon ${classMap({ expanded: this.expanded })}"
></ha-svg-icon>
`
: ""}
${!this.leftChevron ? chevronIcon : nothing}
<slot name="icons"></slot>
</div>
</div>
@@ -177,7 +172,8 @@ export class HaExpansionPanel extends LitElement {
margin-inline-end: initial;
}
:host([leftchevron]) .summary-icon {
:host([left-chevron]) .summary-icon,
::slotted([slot="leading-icon"]) {
margin-left: 0;
margin-right: 8px;
margin-inline-start: 0;

View File

@@ -0,0 +1,19 @@
import SlAnimation from "@shoelace-style/shoelace/dist/components/animation/animation.component";
import { customElement, property } from "lit/decorators";
@customElement("ha-fade-in")
export class HaFadeIn extends SlAnimation {
@property() public name = "fadeIn";
@property() public fill: FillMode = "both";
@property({ type: Boolean }) public play = true;
@property({ type: Number }) public iterations = 1;
}
declare global {
interface HTMLElementTagNameMap {
"ha-fade-in": HaFadeIn;
}
}

View File

@@ -45,7 +45,7 @@ export class HaFilterBlueprints extends LitElement {
protected render() {
return html`
<ha-expansion-panel
leftChevron
left-chevron
.expanded=${this.expanded}
@expanded-will-change=${this._expandedWillChange}
@expanded-changed=${this._expandedChanged}

View File

@@ -65,7 +65,7 @@ export class HaFilterCategories extends SubscribeMixin(LitElement) {
protected render() {
return html`
<ha-expansion-panel
leftChevron
left-chevron
.expanded=${this.expanded}
@expanded-will-change=${this._expandedWillChange}
@expanded-changed=${this._expandedChanged}

View File

@@ -5,8 +5,8 @@ import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../common/dom/fire_event";
import { computeDeviceNameDisplay } from "../common/entity/compute_device_name";
import { stringCompare } from "../common/string/compare";
import { computeDeviceName } from "../data/device_registry";
import type { RelatedResult } from "../data/search";
import { findRelated } from "../data/search";
import { haStyleScrollbar } from "../resources/styles";
@@ -46,7 +46,7 @@ export class HaFilterDevices extends LitElement {
protected render() {
return html`
<ha-expansion-panel
leftChevron
left-chevron
.expanded=${this.expanded}
@expanded-will-change=${this._expandedWillChange}
@expanded-changed=${this._expandedChanged}
@@ -95,7 +95,7 @@ export class HaFilterDevices extends LitElement {
.value=${device.id}
.selected=${this.value?.includes(device.id) ?? false}
>
${computeDeviceName(device, this.hass)}
${computeDeviceNameDisplay(device, this.hass)}
</ha-check-list-item>`;
private _handleItemClick(ev) {
@@ -142,12 +142,14 @@ export class HaFilterDevices extends LitElement {
.filter(
(device) =>
!filter ||
computeDeviceName(device, this.hass).toLowerCase().includes(filter)
computeDeviceNameDisplay(device, this.hass)
.toLowerCase()
.includes(filter)
)
.sort((a, b) =>
stringCompare(
computeDeviceName(a, this.hass),
computeDeviceName(b, this.hass),
computeDeviceNameDisplay(a, this.hass),
computeDeviceNameDisplay(b, this.hass),
this.hass.locale.language
)
);

View File

@@ -33,7 +33,7 @@ export class HaFilterDomains extends LitElement {
protected render() {
return html`
<ha-expansion-panel
leftChevron
left-chevron
.expanded=${this.expanded}
@expanded-will-change=${this._expandedWillChange}
@expanded-changed=${this._expandedChanged}

View File

@@ -48,7 +48,7 @@ export class HaFilterEntities extends LitElement {
protected render() {
return html`
<ha-expansion-panel
leftChevron
left-chevron
.expanded=${this.expanded}
@expanded-will-change=${this._expandedWillChange}
@expanded-changed=${this._expandedChanged}

View File

@@ -54,7 +54,7 @@ export class HaFilterFloorAreas extends LitElement {
return html`
<ha-expansion-panel
leftChevron
left-chevron
.expanded=${this.expanded}
@expanded-will-change=${this._expandedWillChange}
@expanded-changed=${this._expandedChanged}

View File

@@ -35,7 +35,7 @@ export class HaFilterIntegrations extends LitElement {
protected render() {
return html`
<ha-expansion-panel
leftChevron
left-chevron
.expanded=${this.expanded}
@expanded-will-change=${this._expandedWillChange}
@expanded-changed=${this._expandedChanged}

View File

@@ -71,7 +71,7 @@ export class HaFilterLabels extends SubscribeMixin(LitElement) {
protected render() {
return html`
<ha-expansion-panel
leftChevron
left-chevron
.expanded=${this.expanded}
@expanded-will-change=${this._expandedWillChange}
@expanded-changed=${this._expandedChanged}

View File

@@ -41,7 +41,7 @@ export class HaFilterStates extends LitElement {
const hasIcon = this.states.find((item) => item.icon);
return html`
<ha-expansion-panel
leftChevron
left-chevron
.expanded=${this.expanded}
@expanded-will-change=${this._expandedWillChange}
@expanded-changed=${this._expandedChanged}

View File

@@ -13,6 +13,12 @@ export const computeInitialHaFormData = (
data[field.name] = field.description.suggested_value;
} else if ("default" in field) {
data[field.name] = field.default;
} else if (field.type === "expandable") {
const expandableData = computeInitialHaFormData(field.schema);
if (field.required || Object.keys(expandableData).length) {
// Only add expandable data if it's required or any of its children have initial values.
data[field.name] = expandableData;
}
} else if (!field.required) {
// Do nothing.
} else if (field.type === "boolean") {
@@ -36,8 +42,6 @@ export const computeInitialHaFormData = (
minutes: 0,
seconds: 0,
};
} else if (field.type === "expandable") {
data[field.name] = computeInitialHaFormData(field.schema);
} else if ("selector" in field) {
const selector: Selector = field.selector;

View File

@@ -67,18 +67,23 @@ export class HaFormExpendable extends LitElement implements HaFormElement {
protected render() {
return html`
<ha-expansion-panel outlined .expanded=${Boolean(this.schema.expanded)}>
${this.schema.icon
? html`
<ha-icon slot="leading-icon" .icon=${this.schema.icon}></ha-icon>
`
: this.schema.iconPath
? html`
<ha-svg-icon
slot="leading-icon"
.path=${this.schema.iconPath}
></ha-svg-icon>
`
: nothing}
<div
slot="header"
role="heading"
aria-level=${this.schema.headingLevel?.toString() ?? "3"}
>
${this.schema.icon
? html` <ha-icon .icon=${this.schema.icon}></ha-icon> `
: this.schema.iconPath
? html`
<ha-svg-icon .path=${this.schema.iconPath}></ha-svg-icon>
`
: nothing}
${this.schema.title || this.computeLabel?.(this.schema)}
</div>
<div class="content">

View File

@@ -38,6 +38,7 @@ export class HaFormFloat extends LitElement implements HaFormElement {
<ha-textfield
type="number"
inputMode="decimal"
step="any"
.label=${this.label}
.helper=${this.helper}
helperPersistent

View File

@@ -0,0 +1,166 @@
import type { PropertyValues, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { stopPropagation } from "../../common/dom/stop_propagation";
import type { LocalizeFunc } from "../../common/translations/localize";
import type { HomeAssistant } from "../../types";
import "./ha-form";
import type {
HaFormOptionalActionsSchema,
HaFormDataContainer,
HaFormElement,
HaFormSchema,
} from "./types";
const NO_ACTIONS = [];
@customElement("ha-form-optional_actions")
export class HaFormOptionalActions extends LitElement implements HaFormElement {
@property({ attribute: false }) public localize?: LocalizeFunc;
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public data!: HaFormDataContainer;
@property({ attribute: false }) public schema!: HaFormOptionalActionsSchema;
@property({ type: Boolean }) public disabled = false;
@property({ attribute: false }) public computeLabel?: (
schema: HaFormSchema,
data?: HaFormDataContainer
) => string;
@property({ attribute: false }) public computeHelper?: (
schema: HaFormSchema
) => string;
@property({ attribute: false }) public localizeValue?: (
key: string
) => string;
@state() private _displayActions?: string[];
public async focus() {
await this.updateComplete;
this.renderRoot.querySelector("ha-form")?.focus();
}
protected updated(changedProps: PropertyValues): void {
super.updated(changedProps);
if (changedProps.has("data")) {
const displayActions = this._displayActions ?? NO_ACTIONS;
const hiddenActions = this._hiddenActions(
this.schema.schema,
displayActions
);
this._displayActions = [
...displayActions,
...hiddenActions.filter((name) => name in this.data),
];
}
}
private _hiddenActions = memoizeOne(
(schema: readonly HaFormSchema[], displayActions: string[]): string[] =>
schema
.map((item) => item.name)
.filter((name) => !displayActions.includes(name))
);
private _displaySchema = memoizeOne(
(
schema: readonly HaFormSchema[],
displayActions: string[]
): HaFormSchema[] =>
schema.filter((item) => displayActions.includes(item.name))
);
public render(): TemplateResult {
const displayActions = this._displayActions ?? NO_ACTIONS;
const schema = this._displaySchema(
this.schema.schema,
this._displayActions ?? []
);
const hiddenActions = this._hiddenActions(
this.schema.schema,
displayActions
);
const schemaMap = new Map<string, HaFormSchema>(
this.computeLabel
? this.schema.schema.map((item) => [item.name, item])
: []
);
return html`
${schema.length > 0
? html`
<ha-form
.hass=${this.hass}
.data=${this.data}
.schema=${schema}
.disabled=${this.disabled}
.computeLabel=${this.computeLabel}
.computeHelper=${this.computeHelper}
.localizeValue=${this.localizeValue}
></ha-form>
`
: nothing}
${hiddenActions.length > 0
? html`
<ha-button-menu
@action=${this._handleAddAction}
fixed
@closed=${stopPropagation}
>
<ha-button slot="trigger">
${this.localize?.("ui.components.form-optional-actions.add") ||
"Add interaction"}
</ha-button>
${hiddenActions.map((action) => {
const actionSchema = schemaMap.get(action);
return html`
<ha-list-item>
${this.computeLabel && actionSchema
? this.computeLabel(actionSchema)
: action}
</ha-list-item>
`;
})}
</ha-button-menu>
`
: nothing}
`;
}
private _handleAddAction(ev: CustomEvent) {
const hiddenActions = this._hiddenActions(
this.schema.schema,
this._displayActions ?? NO_ACTIONS
);
const index = ev.detail.index;
const action = hiddenActions[index];
this._displayActions = [...(this._displayActions ?? []), action];
}
static styles = css`
:host {
display: flex !important;
flex-direction: column;
gap: 24px;
}
:host ha-form {
display: block;
}
`;
}
declare global {
interface HTMLElementTagNameMap {
"ha-form-optional_actions": HaFormOptionalActions;
}
}

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