-
Notifications
You must be signed in to change notification settings - Fork 278
feat(variables): variables can depend on any other variable (no alphabetical dependency anymore) #1089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Nice use of proxy. 👏 To really make variables adhere to standard programming principles, I suggest to proceed with not evaluating all variables always at render. Perhaps use |
## [7.0.0-dev.1](v6.1.0-dev.2...v7.0.0-dev.1) (2025-11-01) ### ⚠ BREAKING CHANGES * **triggers_update:** `triggers_update` is deprecated and will not have any effect if set. Entities are discovered automatically. If there is no suitable entities in your configuration, consider using `update_timer` to update the card on interval. * **variables:** `variables` are only evaluated if they are "used" so hacks using variables to run javascript code during card init for eg. should read the updated documentation section. It is still possible with the `force_eval` variables configuration option. ```yaml type: custom:button-card entity: switch.skylight update_timer: 1s variables: always_evaled: value: '[[[ window.alwaysEvaled = `${new Date().getTime()}`; ]]]' force_eval: true never_evaled: '[[[ window.neverEvaled = `${new Date().getTime()}`; ]]]' name: 'always should update every second,<br/>never should be unset' show_label: true label: | [[[ return `always: ${window.alwaysEvaled || "not set"} <br/>never: ${window.neverEvaled || "not set"}`; ]]] ``` ```yaml type: custom:button-card variables: never_evaled: '[[[ throw new Error("This variable should never be evaluated") ]]]' aa: value: '[[[ return "Test variables dependencies: OK" ]]]' test1: '[[[ return variables.aa ]]]' name: '[[[ return variables.test1; ]]]' ``` ### Features * **spin:** Make `spin` available as a main config option and support JS templates ([#1084](#1084)) ([3c92a5d](3c92a5d)), closes [#1081](#1081) * **triggers_update:** `triggers_update` is deprecated and will not have any effect. This is now automatic. ([#1095](#1095)) ([45a6b69](45a6b69)) * **variables:** variables can depend on any other variable (no alphabetical dependency anymore) ([#1089](#1089)) ([f372ce4](f372ce4)) ### Documentation * Add Browser Mod nested templates example ([#1092](#1092)) ([18a8f21](18a8f21)) * fix several typos ([#1090](#1090)) ([6dc25ab](6dc25ab)) * fix tooltip part naming conventions in doco ([#1085](#1085)) ([b0aa2a9](b0aa2a9))
|
🎉 This PR is included in version 7.0.0-dev.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
|
The elimination of alphabetical dependency is great! As for the second change, I'm not super enthusiastic but I was able to get along with it :) |
## [7.0.0](v6.0.0...v7.0.0) (2025-11-10) ### ⚠ BREAKING CHANGES * `spin` (to make the icon/entity_picture rotate) has been renamed to `rotate`, please update your configurations * **triggers_update:** `triggers_update` is deprecated and will not have any effect if set. Entities are discovered automatically. If there is no suitable entities in your configuration, consider using `update_timer` to update the card on interval. * **variables:** `variables` are only evaluated if they are "used" so hacks using variables to run javascript code during card init for eg. should read the updated documentation section. It is still possible with the `force_eval` variables configuration option. ```yaml type: custom:button-card entity: switch.skylight update_timer: 1s variables: always_evaled: value: '[[[ window.alwaysEvaled = `${new Date().getTime()}`; ]]]' force_eval: true never_evaled: '[[[ window.neverEvaled = `${new Date().getTime()}`; ]]]' name: 'always should update every second,<br/>never should be unset' show_label: true label: | [[[ return `always: ${window.alwaysEvaled || "not set"} <br/>never: ${window.neverEvaled || "not set"}`; ]]] ``` ```yaml type: custom:button-card variables: never_evaled: '[[[ throw new Error("This variable should never be evaluated") ]]]' aa: value: '[[[ return "Test variables dependencies: OK" ]]]' test1: '[[[ return variables.aa ]]]' name: '[[[ return variables.test1; ]]]' ``` ### Features * `triggers_update` is not required anymore, all entities used in JS templates are now discovered automatically. ([#1080](#1080)) ([ccb5766](ccb5766)), closes [#1074](#1074) * **custom_fields:** New `force_recreate: true` to recreate the nested card on each config update ([#1102](#1102)) ([0a85dff](0a85dff)), closes [#1086](#1086) * **extra_styles:** `extra_styles` is now merged when using config templates instead of being overriden by the last one set ([#1108](#1108)) ([a4d78e1](a4d78e1)), closes [#name](https://github.com/custom-cards/button-card/issues/name) [#name](https://github.com/custom-cards/button-card/issues/name) [#name](https://github.com/custom-cards/button-card/issues/name) * new `helpers.runAction` to run any action supported by button-card ([#1075](#1075)) ([295afcc](295afcc)) * rename `spin` to `rotate` ([#1098](#1098)) ([d26bae2](d26bae2)), closes [#1081](#1081) * **ripple:** `show_ripple` to disable or enable the ripple/hover effect (undefined = auto) ([#1076](#1076)) ([1964f4b](1964f4b)) * **spin:** Make `spin` available as a main config option and support JS templates ([#1084](#1084)) ([3c92a5d](3c92a5d)), closes [#1081](#1081) * **triggers_update:** `triggers_update` is deprecated and will not have any effect. This is now automatic. ([#1095](#1095)) ([45a6b69](45a6b69)) * **variables:** variables can depend on any other variable (no alphabetical dependency anymore) ([#1089](#1089)) ([f372ce4](f372ce4)) ### Bug Fixes * `press_action` would not work on touchscreen ([#1100](#1100)) ([ea71b3d](ea71b3d)), closes [#1097](#1097) * **actions:** Haptic support. Requires Home Assistant 2025.11 to correctly override native Home Assistant Haptics ([#1091](#1091)) ([6d9457d](6d9457d)), closes [#956](#956) [#565](#565) * **variables:** Fixed a type error when a variable is `null` ([#1110](#1110)) ([05f1631](05f1631)), closes [#1109](#1109) * **variables:** read only error in some cases ([#1101](#1101)) ([a316aa2](a316aa2)), closes [#1099](#1099) * **variables:** storing objects or functions in variables would fail in specific cases ([#1103](#1103)) ([4778c4a](4778c4a)) * **variables:** variables loops would not be detected anymore ([80206ba](80206ba)) ### Documentation * Add Browser Mod nested templates example ([#1092](#1092)) ([18a8f21](18a8f21)) * Fix action config table format ([f65b2a6](f65b2a6)) * fix several typos ([#1090](#1090)) ([6dc25ab](6dc25ab)) * Fix toast action table formating ([af8c932](af8c932)) * fix tooltip part naming conventions in doco ([#1085](#1085)) ([b0aa2a9](b0aa2a9)) * Remove uneeded `-` from code examples ([b202a09](b202a09)) * Update variables link ([d6bc9f5](d6bc9f5))
|
🎉 This PR is included in version 7.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
BREAKING CHANGE:
variablesare only evaluated if they are "used" so hacks using variables to run javascript code during card init for eg. should read the updated documentation section. It is still possible with theforce_evalvariables configuration option.