Hi. I’m using action mealie.get_mealplan to receive a list of dictionaries (as I assume). From this List I want to find the dict with a certain attribute (entityType=‘breakfast’). But as it seems, the dict is only received as a string, so I can’t access the key/value pairs.
Ultimately I want to iterate over the meals and list them on the dashboard.
Pretty please do not post screenshots. Always post code, input, output, etc. as properly marked up text.
Your sensor attribute appears to be neither a list nor a dict, it is a string. When you are accessing index 1, you get the second character of the string which is the { in your template results. When you attempt to access item “mealplan_id”, well that obviously won’t work.
Either you need to fix your sensor so that it outputs a list or dict depending on what you want to achieve further down the line (I have no idea), or process the current value as-is through the from_json filter.
It’s because your output ({{ todays_meals.mealplan }}) has an enum in it, which means it won’t validate as a dictionary and | as_json will not work. You either need to reject that attribute (entry_type) or come up with a different plan.
this template should work to turn it into a usable dictionary while retaining entry_type: