From c0611608da367fddeb974bc1f8492272af2ea85c Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Fri, 19 Jul 2024 09:49:04 +0100 Subject: [PATCH] Mealie - Add example template sensor and tip (#33704) * Add example and tip * Update source/_integrations/mealie.markdown Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Correct capitlization * Refine example template sensor * Typos * Remove quotes They don't render in a details section * Fix line wrap * Update services to actions * Tiny tweak --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Franck Nijhof --- source/_integrations/mealie.markdown | 38 +++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/source/_integrations/mealie.markdown b/source/_integrations/mealie.markdown index dcab5821113..3239a8802bd 100644 --- a/source/_integrations/mealie.markdown +++ b/source/_integrations/mealie.markdown @@ -81,4 +81,40 @@ Import the recipe into Mealie from a URL. |------------------------|----------|-----------------------------------------------------------------| | `config_entry_id` | No | The ID of the Mealie config entry to get data from. | | `url` | No | The URL of the recipe. | -| `include_tags` | Yes | Include tags from the website to the recipe. (false by default) | \ No newline at end of file +| `include_tags` | Yes | Include tags from the website to the recipe. (false by default) | + +{% tip %} +You can get your `config_entry_id` by using actions within [Developer Tools](/docs/tools/dev-tools/), using one of the above actions and viewing the YAML. +{% endtip %} + +## Examples + +{% details "Example template sensor using get_mealplan" %} + +Example template sensor that contains today's dinner meal plan entries: + +{% raw %} + +```yaml +template: + - trigger: + - platform: time_pattern + hours: /1 + action: + - service: mealie.get_mealplan + data: + config_entry_id: YOUR_MEALIE_CONFIG_ENTITY_ID + response_variable: result + sensor: + - name: "Dinner today" + unique_id: mealie_dinner_today + state: > + {% for meal in result.mealplan if meal.entry_type == "dinner" -%} + {{ meal.recipe['name'] if meal.recipe is not none else meal.title }} + {{ ", " if not loop.last }} + {%- endfor %} +``` + +{% endraw %} + +{% enddetails %}