You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix hassfest validation: move URLs from translations to placeholders (#249)
* Fix hassfest validation: move URLs from translations to placeholders
Home Assistant PR #154224 (merged Jan 27, 2026) introduced validation
that prevents URLs from being directly embedded in translation strings.
This commit implements the proper solution using description placeholders:
- Created strings.json with URL placeholders for form steps
- Added URL constants and placeholder functions in config_flow.py
- Updated SchemaFlowFormStep instances to inject URLs via description_placeholders
- Removed URLs from menu step descriptions (SchemaFlowMenuStep doesn't support placeholders)
This keeps the URLs maintainable in code while allowing translators to
work with clean, locale-agnostic strings.
Fixes hassfest validation failures reported in issue #154226
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Fix unit tests: pass hass parameter to Template constructor
Home Assistant now requires the hass parameter when creating Template
objects (will be mandatory in 2025.10). Updated three failing tests to
pass coordinator.hass to Template constructor.
Fixes test_start_with_counter, test_start_with_source, and test_start_with_time.
All 126 tests now passing.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Remove translations/en.json in favor of strings.json
Home Assistant now uses strings.json as the primary translation file.
The old translations/en.json with embedded URLs is no longer needed.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Use translations/en.json for custom integration (remove strings.json)
strings.json is for core HA integrations. Custom integrations use
translations/en.json at runtime. URLs are removed from translations
and injected via description_placeholders in config_flow.py.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Add URL placeholders to translations
The placeholders {buymeacoffee_url}, {device_class_url}, and
{state_class_url} are now in the translation strings and will be
replaced with actual URLs by the description_placeholders functions
at runtime.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: custom_components/measureit/translations/en.json
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
"step": {
4
4
"user": {
5
5
"title": "Choose what you want to measure (what)",
6
-
"description": "Thank you for setting up MeasureIt!\nIf you need help with the configuration have a look at the [readme](https://github.com/danieldotnl/ha-measureit) or ask a question on the [community forum](https://community.home-assistant.io/t/measureit-measure-all-you-need-based-on-time-and-templates/660614).\n\nChoose what you want to measure:\n**Time:** Measure the elapsed time while conditions are met.\n**Source:** Measure the state changes of a source entity, while conditions are met.\n**Counter:** Measure the number of times something (described in a template) occurs, while conditions are met.",
6
+
"description": "Thank you for setting up MeasureIt!\nIf you need help with the configuration, have a look at the readme or ask a question on the community forum.\n\nChoose what you want to measure:\n**Time:** Measure the elapsed time while conditions are met.\n**Source:** Measure the state changes of a source entity, while conditions are met.\n**Counter:** Measure the number of times something (described in a template) occurs, while conditions are met.",
7
7
"menu_options": {
8
8
"time": "Time",
9
9
"source": "Source",
@@ -45,7 +45,7 @@
45
45
},
46
46
"sensors": {
47
47
"title": "Configure the sensors (how)",
48
-
"description": "Configure the sensors. When in doubt, stick to the defaults. Individual sensor settings can be adjusted after this setup via 'configure'.\n\n**Reset periods:** Select a predefined period to measure (when the meter will reset). Alternatively, provide a custom cron expression. Each period becomes a separate sensor.\n**Value template:** A template that is applied on the output of the sensor. Use `value` to refer to the sensor state.\n**Unit of measurement:** The unit of what your are measuring. E.g.: m3\n**Device class:** Find more about device classes [here](https://www.home-assistant.io/integrations/sensor/#device-class).\n**State class**: Find more about state classes [here](https://developers.home-assistant.io/docs/core/entity/sensor/#available-state-classes).",
48
+
"description": "Configure the sensors. When in doubt, stick to the defaults. Individual sensor settings can be adjusted after this setup via 'configure'.\n\n**Reset periods:** Select a predefined period to measure (when the meter will reset). Alternatively, provide a custom cron expression. Each period becomes a separate sensor.\n**Value template:** A template that is applied on the output of the sensor. Use `value` to refer to the sensor state.\n**Unit of measurement:** The unit of what your are measuring. E.g.: m3\n**Device class:** Find more about device classes [{device_class_url}].\n**State class**: Find more about state classes [{state_class_url}].",
49
49
"data": {
50
50
"periods": "Reset periods:",
51
51
"unit_of_measurement": "Unit of measurement",
@@ -56,7 +56,7 @@
56
56
},
57
57
"thank_you": {
58
58
"title": "Thank you for setting up MeasureIt!",
59
-
"description": "Did you know that I'm incredibly motivated by coffee? ☕\nIf you like using MeasureIt, please consider buying me a coffee!\nhttps://www.buymeacoffee.com/danieldotnl 🙏"
59
+
"description": "Did you know that I'm incredibly motivated by coffee? ☕\nIf you like using MeasureIt, please consider buying me a coffee!\n{buymeacoffee_url} 🙏"
60
60
}
61
61
},
62
62
"error": {
@@ -77,7 +77,7 @@
77
77
},
78
78
"add_sensors": {
79
79
"title": "Add sensor(s)",
80
-
"description": "Add and configure one or more sensors. When in doubt, stick to the defaults.\n\n**Reset periods:** Select the periods you want to measure (when the meter will reset). Each period becomes a separate sensor.\n**Value template:** A template that is applied on the output of the sensor. Use `value` to refer to the sensor state.\n**Unit of measurement:** The unit of what your are measuring. E.g.: m3\n**Device class:** Find more about device classes [here](https://www.home-assistant.io/integrations/sensor/#device-class).\n**State class**: Find more about state classes [here](https://developers.home-assistant.io/docs/core/entity/sensor/#available-state-classes).",
80
+
"description": "Add and configure one or more sensors. When in doubt, stick to the defaults.\n\n**Reset periods:** Select the periods you want to measure (when the meter will reset). Each period becomes a separate sensor.\n**Value template:** A template that is applied on the output of the sensor. Use `value` to refer to the sensor state.\n**Unit of measurement:** The unit of what your are measuring. E.g.: m3\n**Device class:** Find more about device classes [{device_class_url}].\n**State class**: Find more about state classes [{state_class_url}].",
81
81
"data": {
82
82
"period": "Reset periods:",
83
83
"unit_of_measurement": "Unit of measurement",
@@ -97,7 +97,7 @@
97
97
},
98
98
"thank_you": {
99
99
"title": "Thank you for setting up MeasureIt!",
100
-
"description": "Did you know that I'm incredibly motivated by coffee? ☕\nIf you like using MeasureIt, please consider buying me a coffee!\nhttps://www.buymeacoffee.com/danieldotnl 🙏"
100
+
"description": "Did you know that I'm incredibly motivated by coffee? ☕\nIf you like using MeasureIt, please consider buying me a coffee!\n{buymeacoffee_url} 🙏"
0 commit comments