@123 Sure, there’s lot of things that come into play with a seeming small issue!
Ok, that was an indentation problem. Works now.
So response_variable gives me this:
context:
id: 01HSBKT7E1Q926KWQVJB1GRE7D
parent_id: 01HSBKT7DA8P89BJX3JX7MQZCZ
user_id: null
response_variable:
content:
- 'Lunch Menu Week commencing: Monday 4th March 2024'
- >-
Monday Meatfree monday Pasta Homemade tomalolcheese sauce 1,13 Sweelcorn
Soup of the day 1,6,13
- >-
Tuesday Chicken curry 13,14 Vegetarian coconut curry 13.14 Sliced carrots
petit poIS Rice Soup of the day 1,6,13
- >-
Wednesday Savoury mince 13,14 Savoury quorn 6,11,13,14 New potatoes
Broccoli Soup of the day 1,6,.13.
- >-
Thursday Egg Noodles 11,13,14, Peppers, Broccoli and leeks Petit pois Soup
of the day 1,6,13
- Friday Pizza bakes French fries Petit pois Sweetcorn Baked beans
- >-
Everyday Wholewheat fusilli 3,15 JacketSweet potatoes Fresh fruitl 1/
Jelly (V) Fresh salad bar
- >-
Allergen Key: Milk , 2. Fish; 3 Gluten; 4. Peanuts; 5. Tree nuts Soya
Sesame 8 , Lupin, Shellfish , 10. Molluscs, 11, Egg; 12. Sulphite , 13.
Celery; Mustard "MENU IS SUBJECT TO CHANGE SHOULD INGREDIENTS BE
UNAVAILABLE" 15 Wheat:
I can index this like response_variable.content[now().weekday()+1] which would be today. If i do I then get a long string with all the menu items for today.
I can see both solutions work great on a list with separate words/entries, but as mine is a long string (below indexed string without the comma’s), I get this instead:
Hi person, good Afternoon. You are having T, u, e, s, d, a, y, , C, h, i,
c, k, e, n, , c, u, r, r, y, , , , , , , , V, e, g, e, t, a, r, i, a, n, ,
c, o, c, o, n, u, t, , c, u, r, r, y, , , , ., , , , S, l, i, c, e, d, ,
c, a, r, r, o, t, s, , p, e, t, i, t, , p, o, I, S, , R, i, c, e, , S, o,
u, p, , o, f, , t, h, e, , d, a, y, , , , , , , for lunch today
I can think of the only way to apply these solutions is by putting every word found in the entry in a list, and then doing all of the maps and joins.
Something I guess like (pseudocode I need to look up the exact format)
{% for every word in response_variable.content[I] add_to_list %}
I was hoping I could apply your :
{%- set menu = (response_variable.content[now().isoweekday()]
| map('regex_replace', ' ?[0-9]+|,', '') | list)[1:]
| join(', ') | capitalize -%}| replace('Monday','')|replace('Tuesday','')|replace('Wednesday','')|replace('Thursday','')|replace('Friday','')
}}
Hi person, good {{ states('sensor.time_of_day') }}. You are having {{ menu }} for lunch today.
on response_variable.content instead and it would work. But it doesn’t seem to. If I do that I get:
service_data:
message: >-
Hi person, good Afternoon. You are having Lunch Menu Week commencing: th
March, Meatfree monday Pasta Homemade tomalolcheese sauce Sweelcorn Soup
of the day, Chicken curry Vegetarian coconut curry . Sliced carrots
petit poIS Rice Soup of the day, Savoury mince Savoury quorn New
potatoes Broccoli Soup of the day .., Egg Noodles Peppers Broccoli and
leeks Petit pois Soup of the day, Pizza bakes French fries Petit pois
Sweetcorn Baked beans, Everyday Wholewheat fusilli JacketSweet potatoes
Fresh fruitl / Jelly (V) Fresh salad bar, Allergen Key: Milk . Fish;
Gluten; . Peanuts; . Tree nuts Soya Sesame Lupin Shellfish . Molluscs
Egg; . Sulphite . Celery; Mustard "MENU IS SUBJECT TO CHANGE SHOULD
INGREDIENTS BE UNAVAILABLE" Wheat: for lunch today
Instead, e.g. all the content of the list. Anyway, I’m happy with the solution I have for now, and I don’t want to take up more of anyone’s time. Thanks all so far!