From b0a069a9a7002235058a1a259c4ec1770ebaf7a7 Mon Sep 17 00:00:00 2001 From: paulfantom Date: Sun, 15 Oct 2023 00:07:06 +0200 Subject: [PATCH] apps/homassistant: better tandoor sensor --- apps/homeassistant/config/configuration.yaml | 20 ++++++++++++------- .../manifests/homeassistant/configs.yaml | 20 ++++++++++++------- .../manifests/homeassistant/statefulSet.yaml | 2 +- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/apps/homeassistant/config/configuration.yaml b/apps/homeassistant/config/configuration.yaml index 8308a1785..ff3de6e5e 100644 --- a/apps/homeassistant/config/configuration.yaml +++ b/apps/homeassistant/config/configuration.yaml @@ -184,16 +184,22 @@ sensor: authorization: !secret recipes_token resource: https://recipes.krupa.net.pl/api/meal-plan params: - from_date: '{{ now().strftime("%Y-%m-%d") }}' - to_date: '{{ now().strftime("%Y-%m-%d") }}' + from_date: > + {{ now().strftime("%Y-%m-%d") }} + to_date: > + {{ (now().date() + timedelta(days=1)).strftime("%Y-%m-%d") }} value_template: > {% if value_json is none or value_json == [] %} - No meal plan - {% elif value_json[0].title %} - {{ value_json[0].title }} - {% elif value_json[0].recipe_name %} - {{ value_json[0].recipe_name }} + No meal plan found + {% else %} + {% for date, dish in value_json | groupby('date') -%} + {% for type in ['Breakfast', 'Lunch', 'Snack', 'Dinner'] %} + {% set curr = (dish|selectattr('meal_type_name', 'eq', type)|first) -%} + {{ date }}: {{ curr.meal_type_name | default('Meal') }}: {{ curr.title | default('') }}{{ curr.recipe_name | default('') -}} + {% endfor %} + {% endfor %} {% endif %} + #- name: we_wash_w1 # platform: imap_email_content # server: imap.gmail.com diff --git a/apps/homeassistant/manifests/homeassistant/configs.yaml b/apps/homeassistant/manifests/homeassistant/configs.yaml index b10232f7a..ed1b3d158 100644 --- a/apps/homeassistant/manifests/homeassistant/configs.yaml +++ b/apps/homeassistant/manifests/homeassistant/configs.yaml @@ -187,16 +187,22 @@ data: authorization: !secret recipes_token resource: https://recipes.krupa.net.pl/api/meal-plan params: - from_date: '{{ now().strftime("%Y-%m-%d") }}' - to_date: '{{ now().strftime("%Y-%m-%d") }}' + from_date: > + {{ now().strftime("%Y-%m-%d") }} + to_date: > + {{ (now().date() + timedelta(days=1)).strftime("%Y-%m-%d") }} value_template: > {% if value_json is none or value_json == [] %} - No meal plan - {% elif value_json[0].title %} - {{ value_json[0].title }} - {% elif value_json[0].recipe_name %} - {{ value_json[0].recipe_name }} + No meal plan found + {% else %} + {% for date, dish in value_json | groupby('date') -%} + {% for type in ['Breakfast', 'Lunch', 'Snack', 'Dinner'] %} + {% set curr = (dish|selectattr('meal_type_name', 'eq', type)|first) -%} + {{ date }}: {{ curr.meal_type_name | default('Meal') }}: {{ curr.title | default('') }}{{ curr.recipe_name | default('') -}} + {% endfor %} + {% endfor %} {% endif %} + #- name: we_wash_w1 # platform: imap_email_content # server: imap.gmail.com diff --git a/apps/homeassistant/manifests/homeassistant/statefulSet.yaml b/apps/homeassistant/manifests/homeassistant/statefulSet.yaml index bd4988750..417ea5667 100644 --- a/apps/homeassistant/manifests/homeassistant/statefulSet.yaml +++ b/apps/homeassistant/manifests/homeassistant/statefulSet.yaml @@ -19,7 +19,7 @@ spec: template: metadata: annotations: - checksum.config/md5: 3fcc0108a83a5756750840f271420bf9 + checksum.config/md5: 186af01be41ae4a1ee8806dfa07fe137 labels: app.kubernetes.io/component: server app.kubernetes.io/name: homeassistant